document.getElementById('openApp').onclick = function(e){
// 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为
// 否则打开a标签的href链接
var agent = navigator.userAgent.toLowerCase() ;
var version;
if(agent.indexOf("like mac os x") > 0){
//ios
var regStr_saf = /os [\d._]*/gi ;
var verinfo = agent.match(regStr_saf) ;
version = (verinfo+"").replace(/[^0-9|_.]/ig,"").replace(/_/ig,".");
}
var version_str = version+"";
if(version_str != "undefined" && version_str.length >0){
version=version.substring(0,1);
if(version > 8){
location.href = 'com.ywwy.MaiDian3://'+"=$shop['id']?>";
window.setTimeout(function(){
location.href = 'https://itunes.apple.com/cn/app/id1052060244';
},300)
} else{
var ifr = document.createElement('iframe');
ifr.src = 'com.ywwy.MaiDian3://'+"=$shop['id']?>";
ifr.style.display = 'none';
document.body.appendChild(ifr);
window.setTimeout(function(){
location.href = 'https://itunes.apple.com/cn/app/id1052060244';
},300)
}
}
};