Browse Source

增加跳转方法

master
zq 4 months ago
parent
commit
4ea6ad5bcf
  1. 31
      main.js

31
main.js

@ -44,6 +44,7 @@ try{
}catch(e){ }catch(e){
} }
Vue.prototype.env_val = 'xcx'; Vue.prototype.env_val = 'xcx';
Vue.prototype.is_pc = false; Vue.prototype.is_pc = false;
Vue.prototype.isMobile = false; Vue.prototype.isMobile = false;
@ -244,7 +245,8 @@ function req(url, data={}, method = 'POST', header={}) {
var doctor_id = uni.getStorageSync('doctor_id'); var doctor_id = uni.getStorageSync('doctor_id');
req(getWxH5LoginConfigUri+'/?did='+doctor_id, logindatac, 'POST').then(data=>{ req(getWxH5LoginConfigUri+'/?did='+doctor_id, logindatac, 'POST').then(data=>{
if(data == -1 || !data.authurl) return; if(data == -1 || !data.authurl) return;
location.href = data.authurl; // location.href = data.authurl;
this.$nav.navToPath(data.authurl)
}); });
return; return;
} }
@ -260,9 +262,10 @@ function req(url, data={}, method = 'POST', header={}) {
const currentPage = pages[pages.length - 1]; const currentPage = pages[pages.length - 1];
let pageUrl = '/'+currentPage.route; let pageUrl = '/'+currentPage.route;
if(data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5){ if(data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5){
uni.navigateTo({ // uni.navigateTo({
url: '/pages/index/index' // url: '/pages/index/index'
}); // });
this.$nav.navToPath('/pages/index/index')
}else{ }else{
} }
return; return;
@ -345,6 +348,25 @@ function toPage(path){
} }
} }
function navToPath(path) {
// #ifdef MP-WEIXIN
if(path.indexOf('/pages/index/index') == -1){
wx.navigateTo({
url: path
});
}else{
wx.reLaunch({
url: path
});
}
// #endif
// #ifdef H5
location.href = path;
// #endif
}
function modelShow(content, path="",title="提示") { function modelShow(content, path="",title="提示") {
uni.showModal({ uni.showModal({
title: title, title: title,
@ -403,6 +425,7 @@ Vue.prototype.$trim = {trim}
Vue.prototype.$token = {getToken} Vue.prototype.$token = {getToken}
Vue.prototype.$settoken = {setToken} Vue.prototype.$settoken = {setToken}
Vue.prototype.$setuinfo = {setUinfo} Vue.prototype.$setuinfo = {setUinfo}
Vue.prototype.$nav = { navToPath };
app.$mount() app.$mount()
// #endif // #endif

Loading…
Cancel
Save