diff --git a/main.js b/main.js
index 896c89a..e52e121 100644
--- a/main.js
+++ b/main.js
@@ -183,14 +183,10 @@ Vue.prototype.edit_preview = 2;
Vue.prototype.add_preview = 3;
Vue.prototype.edit_album = 4;
-// function removeLogin() {
-// uni.removeStorageSync('token');
-// }
-
function removeLogin() {
- uni.removeStorageSync("token");
- uni.removeStorageSync("uinfo");
-}
+ removeToken()
+ removeUinfo()
+}
function req(url, data={}, method = 'POST', header={}) {
var domain = Vue.prototype.request_domain;
@@ -215,7 +211,7 @@ function req(url, data={}, method = 'POST', header={}) {
var isNeedLogin = !noNeedLoginFunc.includes(url);
var headerObj = {'content-type': 'application/x-www-form-urlencoded'};
- var token = uni.getStorageSync('token');
+ var token = getToken();
if(token) headerObj.AUTH = token
return new Promise((resolve, reject) => {
@@ -307,7 +303,7 @@ function xcx_login(url, eqdata={}, method = 'POST') {
var pdata = new Object();
pdata.code = res.code;
req('client/user/login', pdata, 'POST').then(data=>{
- uni.setStorageSync('token', data.token);
+ setToken(data.token)
eqdata.repeat = 1;
req(url, eqdata, method).then(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标题
function setTitlefFunc(title) {
uni.setNavigationBarTitle({
@@ -368,6 +396,9 @@ Vue.prototype.$pop = {modelShow}
Vue.prototype.$func = {toPage}
Vue.prototype.$http = {req}
Vue.prototype.$trim = {trim}
+Vue.prototype.$token = {getToken}
+Vue.prototype.$settoken = {setToken}
+Vue.prototype.$setuinfo = {setUinfo}
app.$mount()
// #endif
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 420dbd6..8f86ea4 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -24,10 +24,10 @@
- {{doctorInfo.doctor_info.doctor_detail}}
+ {{doctorInfo.doctor_info.doctor_detail}}
-
+
@@ -148,12 +148,6 @@
this.code = option.code
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() {
this.doctor_id = getApp().globalData.doctorId
@@ -164,7 +158,7 @@
uni.setNavigationBarTitle({
title:title
})
- var token = uni.getStorageSync('token')
+ var token = this.$token.getToken()
if(this.code && this.state && !token) {
var rebackPagePath = uni.getStorageSync('rebackPagePath')
this.login()
@@ -205,12 +199,13 @@
},
setLoginUserInfo(info) {
var uinfo = new Object();
- uni.setStorageSync("uinfo", JSON.stringify(info));
+ this.$setuinfo.setUinfo(JSON.stringify(info))
},
login() {
this.$http.req('common/get_user_info', {code:this.code,state:this.state}, 'POST').then(data=>{
if(data == -1) return
- uni.setStorageSync('token', data.jwttoken)
+ this.$settoken.setToken(data.jwttoken)
+
this.setLoginUserInfo(data)
this.getDoctorInfo()
// var rebackPagePath = uni.getStorageSync('rebackPagePath')
diff --git a/pages/user_modify/user_modify.vue b/pages/user_modify/user_modify.vue
index 6ebd4ca..1c527ae 100644
--- a/pages/user_modify/user_modify.vue
+++ b/pages/user_modify/user_modify.vue
@@ -59,7 +59,8 @@
},
save(){
var param = new Object()
- var token = uni.getStorageSync('token')
+ var token = this.$token.getToken()
+
var that = this;
param.nick = this.nick;
uni.uploadFile({