SOURCE

console 命令行工具 X clear

                    
>
console
const CONFIG = {
    android: 'https://jp.himalaya.com/kikihodai-apple?partner-from=26380384&utm_content=kikihodaicom&utm_medium=kikihodaicom&utm_from=kikihodaicom&utm_campaign=kikihodaicom',
    ios: 'https://jp.himalaya.com/kikihodai-apple?partner-from=26380384&utm_content=kikihodaicom&utm_medium=kikihodaicom&utm_from=kikihodaicom&utm_campaign=kikihodaicom',
    scheme: 'xmly-intl://open?msg_type=13&album_id=192953'
};
window.onload = function () {
    let oBtn = document.getElementById('btn');
    oBtn.addEventListener('click', function () {
        console.log(Date.now());
        //打开app整套流程
        openApp(`${CONFIG.scheme}`, goConfirmAddr);
    });

};
/**
* 判断是否安装app
* @url ios,android 提供(打开app的链接)
* @callback (未安装app的回调)
* */
function openApp(url, callback) {
    // let { isAndroid, isIOS, isIOS9 } = judgePhoneType();
  

    // if (isAndroid || isIOS) {
    if (1) {
        let hasApp = true, t = 2000,
            t1 = Date.now();
            // ifr = document.createElement("iframe");
        setTimeout(function () {
            if (!hasApp) {
                callback && callback()
            }
            // document.body.removeChild(ifr);
        }, 2000);

        // ifr.setAttribute('src', url);
        // ifr.setAttribute('style', 'height:30px');
        // document.body.appendChild(ifr);

        window.location.href = url;

        setTimeout(function () { //启动app时间较长处理
            let t2 = Date.now();
            if (t2 - t1 < t + 100) {
                hasApp = false;
            }
        }, t);
    }
    // if (isIOS9) {
    //     location.href = url;
    //     setTimeout(function () {
    //         callback && callback()
    //     }, 250);
    //     setTimeout(function () {
    //         location.reload();
    //     }, 1000);
    // }
}

/**
 * 超时跳转h5页面
 * */
function goConfirmAddr() {
    alert('超时');
    // let { isAndroid } = judgePhoneType();
    window.location.href = !isAndroid ? CONFIG.ios : CONFIG.android;
}
/**
 * 判断是否为微信浏览器
 * 兼容ios
 * */

/**
 * 判断手机类型
 * return [ isAndroid, isIOS, isIOS9 ]
 * */
function judgePhoneType() {
    // let isAndroid = false, isIOS = false, isIOS9 = false, version,
    //     u = navigator.userAgent,
    //     ua = u.toLowerCase();
    // //Android系统
    // if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {   //android终端或者uc浏览器
    //     isAndroid = true
    // }
    // //ios
    // if (ua.indexOf("like mac os x") > 0) {
    //     let regStr_saf = /os [\d._]*/gi;
    //     let verinfo = ua.match(regStr_saf);
    //     version = (verinfo + "").replace(/[^0-9|_.]/ig, "").replace(/_/ig, ".");
    // }
    // let version_str = version + "";
    // // ios9以上
    // if (version_str !== "undefined" && version_str.length > 0) {
    //     version = parseInt(version);
    //     if (version >= 8) {
    //         isIOS9 = true
    //     } else {
    //         isIOS = true
    //     }
    // }
    // return { isAndroid, isIOS, isIOS9 };
    return true;
}



<button id="btn">sssssssss</button>