vue内判断是通过andriod还是ios 打开,若有app则唤醒打开,若无则跳转下载页

let ua = navigator.userAgent.toLowerCase();

//android终端

let isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1; //ios终端

let isiOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

if (ua.match(/MicroMessenger/i) == "micromessenger") {

if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {//判断进入的是不是微信

this.osafai = true

} else {

this.olead = true

}

} else {

if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {//判断是ios还是android

//ios

console.log('ios')

// window.location.href = 'http://www.baidu.com'

this.$router.push('/OpenAppleApp')

} else if (/(Android)/i.test(navigator.userAgent)) {

window.location.href = '***' ;//打开调整的地址

console.log(window.location.href)

setTimeout(() => {//如果未安装app则跳转下载页下载

this.$router.push('/OpenAndroidApp')

}, 3000);

}

function isWeixinBrowser() {

return (/micromessenger/.test(ua)) ? true : false;

}

}

猜你喜欢

转载自blog.csdn.net/qq_43671996/article/details/102804757