1、H5跳转APP方法
//跳转app方法
toPage: function(str) {
if(window.Page) {
window.Page.toNativeDetails(str, str);
}
},
//跳转链接 -- 和app协商好跳转对应值
link: function(type,num) {
if(type==1){
if(num==1){
this.toPage('artFirstSingle');
}else{
this.toPage('artShopping');
}
}else if(type==2){
if(num==1){
location.href = "../../activity/inviteFriends.html";
}
}
},
2、微信H5不能直接跳转到APP的相应页面,只能引导下载APP,或者打开app
isFromApp是判断,是app进入该页面,再跳进app的(app,则直接打开app),还是直接从h5跳入app的(微信h5,则判断是否下载该app,提示下载,若已有app,则打开)
link: function(type,num) {
if(!this.isFromApp) {
this.$toast('请下载App');
setTimeout(function() {
openApp();
return;
}, 1500);
}
//判断是否跳h5页面,没有则在下一步打开app
if(type == 2) {
if(num == 4) {
if(this.isFromApp) {
location.href = "../../activity/inviteFriends.html";
}else{
location.href = "../../activity/inviteFriends.html?fromh5=true";
}
return;
}
}
//从app打开(若是app进入h5,再从h5回到app,就走这段)
//if(window.Page) {
// window.Page.toNativeDetails("cash", "cash");
//}
if(num==1){
this.toPage('artFirstSingle');
}else{
this.toPage('artShopping');
}
},
打开app的方法
function openApp() {
// if(env.isWechat) {
// showGuid();
// return;
// }
window.location.href = "yfg://m.native.com/visitor/webView";
setTimeout(function() {
if(env.isIos) {
forward(iosDownLoadUrl);
} else {
forward(androidDownLoadUrl);
}
}, 1000);
}
//跳转ios 安卓下载
function forward(uri, params) {
var to;
if(/http/.test(uri) || /yfg:/.test(uri)) {
to = uri;
} else {
to = resolvePath(uri);
}
if(window.Page) {
if(!params) {
window.Page.forward(JSON.stringify({
url: to
}));
} else {
window.Page.forward(JSON.stringify({
url: to,
nparams: JSON.stringify(params)
}));
}
} else {
location.href = to;
}
}