app下载

// //app下载
    toDownload() {
        if (app.isInApp()) {
            // window.location.href = "mceair://perfect.ceair/deeplink?typeKey=mainview";
        } else {
            //h5
            if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
                window.location = "https://itunes.apple.com/cn/app/dong-fang-hang-kong-dong-hang/id419275564?mt=8";
            } else if (navigator.userAgent.match(/android/i)) {
                //在iframe 中打开APP
                var ifr = document.createElement('iframe');
                ifr.src = "mceair://perfect.ceair/deeplink?typeKey=mainview";
                ifr.style.display = 'none';
                //客户端检测微信直接跳应用宝链接
                if (Boolean(navigator.userAgent.match(/MicroMessenger/ig))) {
                    window.location.href = 'https://sj.qq.com/myapp/detail.htm?apkName=com.rytong.ceair&android_schema=com.rytong.ceair';
                } else {
                    this.checkOpen(opened => {
                        // console.log(opened)
                        if (opened == 1) {
                            window.location = "http://mobile.ceair.com/dl.html"
                        }
                    }
                    );
                }
                document.body.appendChild(ifr);
                setTimeout(function () {
                    document.body.removeChild(ifr);
                }, 3000);
                // window.location = "https://mobile.ceair.com/";
            }
        }
    },
    checkOpen(cb) {
        var _clickTime = +(new Date());
        function check(elsTime) {
            if (elsTime > 3000 || document.hidden || document.webkitHidden) {
                cb(1);
            } else {
                cb(0);
            }
        }
        //启动间隔20ms运行的定时器,并检测累计消耗时间是否超过3000ms,超过则结束
        var _count = 0, intHandle;
        intHandle = setInterval(function () {
            _count++;
            var elsTime = +(new Date()) - _clickTime;
            if (_count >= 100 || elsTime > 3000) {
                clearInterval(intHandle);
                check(elsTime);
            }
        }, 100);
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值