参考https://ask.dcloud.net.cn/article/409
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
var loadDateTime = new Date();
window.location = "test://abc";//schema链接或者universal link
window.setTimeout(function() { //如果没有安装app,便会执行setTimeout跳转下载页
var timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
window.location = "https://www.xxxx.com/"; //ios下载地址
} else {
window.close();
}
}, 2500);
} else if (navigator.userAgent.match(/android/i)) {
var loadDateTime = new Date();
window.location = "test://sb";//schema链接或者universal link
window.setTimeout(function() {//如果没有安装app,便会执行setTimeout跳转下载页
uni.hideLoading()
var timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
uni.showModal({
title: '你还没下载app',
content: '是否前去下载app?',
success: function (res) {
if (res.confirm) {
window.location = "https://www.xxxx.com/"; //ios下载地址
} else if (res.cancel) {
}
}
});
} else {
window.close();
}
}, 500);
}
在app.vue根据的值可进行页面跳转配置
var args= plus.runtime.arguments;
if(args){
if(args == 'test://sb') {
uni.navigateTo({
url: 'pages/mine/myCollection'
})
}
|