|
|
@ -1,5 +1,6 @@ |
|
|
|
// 获取路径参数
|
|
|
|
import Vue from "vue"; |
|
|
|
import store from '@/store'; |
|
|
|
|
|
|
|
// 格式化富文本
|
|
|
|
Vue.prototype.formateRichText = str => { |
|
|
@ -235,40 +236,60 @@ Vue.prototype.getHeadImg = type => { |
|
|
|
|
|
|
|
// 判断君到苏州token是否生效
|
|
|
|
Vue.prototype.checkIsLoginJdsz = () => { |
|
|
|
Vue.prototype.Post({ |
|
|
|
apiType: 'jdsz', |
|
|
|
}, '/api/uservice/user/getMyInfo').then(res => { |
|
|
|
if(res.code == 1 || res.code == 200) { |
|
|
|
return res.data.token |
|
|
|
}else if(res.code == 401) { |
|
|
|
// 重新登陆
|
|
|
|
Vue.prototype.Post({}, '/api/user/getAuthCode').then(res => { |
|
|
|
if (res.code == 1 || res.code == 200) { |
|
|
|
Vue.prototype.Post({ |
|
|
|
apiType: 'jdsz', |
|
|
|
}, '/api/uservice/user/loginBykunshan').then(res => { |
|
|
|
if(res.data.code == 401) { |
|
|
|
this.$store.commit('changeLoginPath') |
|
|
|
return; |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
uni.request({ |
|
|
|
method: 'POST', |
|
|
|
url: 'https://api.cloud.sz-trip.com/api/uservice/user/getMyInfo', |
|
|
|
header: { |
|
|
|
'content-type': 'application/json', |
|
|
|
'token': uni.getStorageSync('jdszToken') || '' |
|
|
|
}, |
|
|
|
data: {}, |
|
|
|
success: res => { |
|
|
|
console.log(16516651,res) |
|
|
|
if (res.data.code == 1) { |
|
|
|
resolve(res.data.data.token) |
|
|
|
} else if (res.data.code == 401) { |
|
|
|
// 重新登陆
|
|
|
|
Vue.prototype.Post({}, '/api/user/getAuthCode').then(res => { |
|
|
|
if (res.code && res.code == 200 && res.data) { |
|
|
|
uni.request({ |
|
|
|
method: 'POST', |
|
|
|
url: 'https://api.cloud.sz-trip.com/api/uservice/user/loginByChangshu', |
|
|
|
header: { |
|
|
|
'content-type': 'application/json' |
|
|
|
}, |
|
|
|
data: { |
|
|
|
code: res.data |
|
|
|
}, |
|
|
|
success: res => { |
|
|
|
if(res.data.code == 401) { |
|
|
|
store.commit('changeLoginPath'); |
|
|
|
resolve('') |
|
|
|
return; |
|
|
|
} |
|
|
|
uni.setStorageSync('jdszToken', res.data.data.token) |
|
|
|
resolve(res.data.data.token) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}).catch(res => { |
|
|
|
if (res.data.code == 201) { |
|
|
|
uni.showToast({ |
|
|
|
title: '未授权手机号', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
// 去登录页面授权
|
|
|
|
setTimeout(()=>{ |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/login/login?needAuth=1' |
|
|
|
}) |
|
|
|
},400) |
|
|
|
} |
|
|
|
uni.setStorageSync('jdszToken', res.data.data.token) |
|
|
|
}) |
|
|
|
} |
|
|
|
}).catch(res => { |
|
|
|
if (res.data.code == 201) { |
|
|
|
uni.showToast({ |
|
|
|
title: '未授权手机号', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
// 去登录页面授权
|
|
|
|
setTimeout(()=>{ |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/login/login?needAuth=1' |
|
|
|
}) |
|
|
|
},400) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -345,11 +366,6 @@ Vue.prototype.gotoDetailByTypeToJdsz = item => { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
uni.navigateTo({ |
|
|
|
url: '/subPackages/webPage/webPage?url=' + encodeURIComponent(url) |
|
|
|
}); |
|
|
|
return; |
|
|
|
|
|
|
|
Vue.prototype.checkIsLoginJdsz().then(res => { |
|
|
|
if(res) { |
|
|
|
uni.navigateTo({ |
|
|
|