h5唤起APP
function tryOpenApp() { event.stopPropagation(); statisimage("49.145.1295",3); var androidurl = 'jiayuan://com.jiayuan?from_scheme=true' ; var iosurl='jiayuan://com.jiayuan?jsonValue=1'; if (uais('ios')) { surl=iosurl; } else{ surl=androidurl; } if (uais('ios')) { var loadDateTime = new Date(); window.location = surl;//schema链接或者universal link window.setTimeout(function() { //如果没有安装app,便会执行setTimeout跳转下载页 var timeOutDateTime = new Date(); if (timeOutDateTime - loadDateTime < 5000) { window.location = "<{$smarty.const.TOUCHCFG_BASEURL}>/?MMIPN=download&event_id="+event_id; //ios下载地址 } else { window.close(); } }, 500); } else { // location.href = surl; // setTimeout(function() { // location.href = "https://d.jiayuan.com"; // }, 2000); //创建iframe var ifr=document.createElement("iframe"); //iframe设置为app的协议打开方式地址 ifr.src=surl;//安卓协议启动地址 ifr.style.display="none";//隐藏 var t=Date.now();//取当前时间戳 //延迟执行iframe 实现访问app协议打开app setTimeout(function(){ document.body.appendChild(ifr); },96); //延迟执行 如果1s没响应,就表示你手机中没有该app。就可以去下载了 setTimeout(function(){ if(Date.now() - t < 2000){ // document.body.appendChild(ifr); location.href="<{$smarty.const.TOUCHCFG_BASEURL}>/?MMIPN=download";//安卓下载地址 } },1001); } } function uais(name) { var ua = navigator.userAgent.toLowerCase(); var is = false; switch (name) { case 'weixin': is = ua.match(/(micromessenger|qq|txmicroblog);?/i) break; case 'ios': is = ua.match(/(iphone|ipod|ipad);?/i) break; case 'browser': is = ua.match(/(applewebkit);?/i) break; default: is = ua.indexOf(name) > -1; } return is; } function closeLoadApp(){ event.stopPropagation(); $('#load_app').removeClass('app_show'); JY_PublicFn.requestData("<{getPageUrl mod='ajax' act='newindex' func='closeLoadBtn'}>", {'page':'index'}).then(res=>{ }) return; }