Browse Source

登录后医生a的链接后换成b医生的登录失败问题

master
kuaileWu 9 months ago
parent
commit
3e22b41973
  1. 49
      main.js
  2. 17
      pages/index/index.vue
  3. 3
      pages/user_modify/user_modify.vue

49
main.js

@ -183,14 +183,10 @@ Vue.prototype.edit_preview = 2;
Vue.prototype.add_preview = 3; Vue.prototype.add_preview = 3;
Vue.prototype.edit_album = 4; Vue.prototype.edit_album = 4;
// function removeLogin() {
// uni.removeStorageSync('token');
// }
function removeLogin() { function removeLogin() {
uni.removeStorageSync("token"); removeToken()
uni.removeStorageSync("uinfo"); removeUinfo()
} }
function req(url, data={}, method = 'POST', header={}) { function req(url, data={}, method = 'POST', header={}) {
var domain = Vue.prototype.request_domain; var domain = Vue.prototype.request_domain;
@ -215,7 +211,7 @@ function req(url, data={}, method = 'POST', header={}) {
var isNeedLogin = !noNeedLoginFunc.includes(url); var isNeedLogin = !noNeedLoginFunc.includes(url);
var headerObj = {'content-type': 'application/x-www-form-urlencoded'}; var headerObj = {'content-type': 'application/x-www-form-urlencoded'};
var token = uni.getStorageSync('token'); var token = getToken();
if(token) headerObj.AUTH = token if(token) headerObj.AUTH = token
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -307,7 +303,7 @@ function xcx_login(url, eqdata={}, method = 'POST') {
var pdata = new Object(); var pdata = new Object();
pdata.code = res.code; pdata.code = res.code;
req('client/user/login', pdata, 'POST').then(data=>{ req('client/user/login', pdata, 'POST').then(data=>{
uni.setStorageSync('token', data.token); setToken(data.token)
eqdata.repeat = 1; eqdata.repeat = 1;
req(url, eqdata, method).then(data=>{ req(url, eqdata, method).then(data=>{
return resolve(data); return resolve(data);
@ -356,7 +352,39 @@ function modelShow(content, path="",title="提示") {
} }
} }
}); });
}
function getToken() {
var did = uni.getStorageSync('doctor_id')
if(!did) return ""
return uni.getStorageSync('token_'+did)
}
function removeToken() {
var did = uni.getStorageSync('doctor_id')
if(!did) return ""
uni.removeStorageSync('token_'+did)
}
function setToken(token) {
var did = uni.getStorageSync('doctor_id')
if(!did) return ""
uni.setStorageSync('token_'+did, token)
}
function removeUinfo(){
var did = uni.getStorageSync('doctor_id')
if(!did) return ""
uni.removeStorageSync('uinfo_'+did)
} }
function setUinfo(info){
var did = uni.getStorageSync('doctor_id')
if(!did) return;
uni.setStorageSync('uinfo_'+did, info)
}
//设置页main标题 //设置页main标题
function setTitlefFunc(title) { function setTitlefFunc(title) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
@ -368,6 +396,9 @@ Vue.prototype.$pop = {modelShow}
Vue.prototype.$func = {toPage} Vue.prototype.$func = {toPage}
Vue.prototype.$http = {req} Vue.prototype.$http = {req}
Vue.prototype.$trim = {trim} Vue.prototype.$trim = {trim}
Vue.prototype.$token = {getToken}
Vue.prototype.$settoken = {setToken}
Vue.prototype.$setuinfo = {setUinfo}
app.$mount() app.$mount()
// #endif // #endif

17
pages/index/index.vue

@ -24,10 +24,10 @@
<view class="con"> <view class="con">
<!-- <view class="con over2 over4"> --> <!-- <view class="con over2 over4"> -->
{{doctorInfo.doctor_info.doctor_detail}} {{doctorInfo.doctor_info.doctor_detail}}
</view> </view>
</view> </view>
<view class="block hospital-wrapper" v-if="hospitals"> <view class="block hospital-wrapper" v-if="hospitals">
<view class="item" v-for="(item,key) in hospitals"> <view class="item" v-for="(item,key) in hospitals">
<view class="top flex"> <view class="top flex">
@ -148,12 +148,6 @@
this.code = option.code this.code = option.code
this.state = option.state this.state = option.state
} }
// if(option.token) {
// this.loginToken = option.token
// uni.setStorageSync('token', this.loginToken)
// // var rebackPagePath = uni.getStorageSync('rebackPagePath')
// // if(!rebackPagePath)
// }
}, },
async onShow() { async onShow() {
this.doctor_id = getApp().globalData.doctorId this.doctor_id = getApp().globalData.doctorId
@ -164,7 +158,7 @@
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:title title:title
}) })
var token = uni.getStorageSync('token') var token = this.$token.getToken()
if(this.code && this.state && !token) { if(this.code && this.state && !token) {
var rebackPagePath = uni.getStorageSync('rebackPagePath') var rebackPagePath = uni.getStorageSync('rebackPagePath')
this.login() this.login()
@ -205,12 +199,13 @@
}, },
setLoginUserInfo(info) { setLoginUserInfo(info) {
var uinfo = new Object(); var uinfo = new Object();
uni.setStorageSync("uinfo", JSON.stringify(info)); this.$setuinfo.setUinfo(JSON.stringify(info))
}, },
login() { login() {
this.$http.req('common/get_user_info', {code:this.code,state:this.state}, 'POST').then(data=>{ this.$http.req('common/get_user_info', {code:this.code,state:this.state}, 'POST').then(data=>{
if(data == -1) return if(data == -1) return
uni.setStorageSync('token', data.jwttoken) this.$settoken.setToken(data.jwttoken)
this.setLoginUserInfo(data) this.setLoginUserInfo(data)
this.getDoctorInfo() this.getDoctorInfo()
// var rebackPagePath = uni.getStorageSync('rebackPagePath') // var rebackPagePath = uni.getStorageSync('rebackPagePath')

3
pages/user_modify/user_modify.vue

@ -59,7 +59,8 @@
}, },
save(){ save(){
var param = new Object() var param = new Object()
var token = uni.getStorageSync('token') var token = this.$token.getToken()
var that = this; var that = this;
param.nick = this.nick; param.nick = this.nick;
uni.uploadFile({ uni.uploadFile({

Loading…
Cancel
Save