参考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'
})
}
该代码段检查用户设备类型,针对iOS和Android设备使用不同的schema链接或Universal Link尝试打开应用。若应用未安装,则在设定的时间间隔后跳转到相应的下载页面。在App.vue中,根据传递的参数值进行页面导航。
4685

被折叠的 条评论
为什么被折叠?



