Commit 983dfe1e authored by Morson's avatar Morson

修复页面回调问题

parent 0027a4a4
...@@ -129,10 +129,10 @@ export default { ...@@ -129,10 +129,10 @@ export default {
if (userInfo && userInfo.token) { if (userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息 // 如果已经登录则直接获取相关信息
util.setOpenid(userInfo.wxopenid); util.setOpenid(userInfo.wxopenid);
this.$u.vuex("vuex_token", userInfo.token); this.$u.vuex('vuex_token', userInfo.token);
uni.setStorageSync("user-info", userInfo); uni.setStorageSync("user-info", userInfo);
} else { } else {
this.$u.vuex("vuex_token", ""); this.$u.vuex('vuex_token', '');
} }
}, },
......
...@@ -144,7 +144,7 @@ export default { ...@@ -144,7 +144,7 @@ export default {
watch: { watch: {
vuex_token(val){ vuex_token(val){
// 监听token变化,如果更新则重新加载页面数据 // 监听token变化,如果更新则重新加载页面数据
this.initSettleInfo() val && this.initSettleInfo()
} }
}, },
computed: { computed: {
......
...@@ -90,6 +90,7 @@ export default { ...@@ -90,6 +90,7 @@ export default {
}).then(res => { }).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res) { if (res) {
that.setUserData(res.data)
that.goBackPage() that.goBackPage()
} else { } else {
this.setLoginStatus() this.setLoginStatus()
...@@ -124,6 +125,7 @@ export default { ...@@ -124,6 +125,7 @@ export default {
}).then(res => { }).then(res => {
uni.hideLoading() uni.hideLoading()
if (res) { if (res) {
that.setUserData(res.data)
that.goBackPage() that.goBackPage()
} else { } else {
uni.showToast({ uni.showToast({
...@@ -167,6 +169,16 @@ export default { ...@@ -167,6 +169,16 @@ export default {
} }
}, },
setUserData(userInfo) {
if (userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息
util.setOpenid(userInfo.wxopenid);
this.$u.vuex('vuex_token', userInfo.token);
uni.setStorageSync("user-info", userInfo);
} else {
this.$u.vuex('vuex_token', '');
}
},
setLoginStatus(authed = true) { setLoginStatus(authed = true) {
if (authed) { if (authed) {
......
...@@ -33,8 +33,8 @@ function authorization(data) { ...@@ -33,8 +33,8 @@ function authorization(data) {
const res = await app.$vm.$u.api.loginWechatAuth(data) const res = await app.$vm.$u.api.loginWechatAuth(data)
if (res) { if (res) {
if (res.code == 200 && res.data) { if (res.code == 200 && res.data) {
app.setUserData(res.data) // app.setUserData(res.data)
app.getBaseInfo(app.$vm) // app.getBaseInfo(app.$vm)
resolve(res); resolve(res);
} else { } else {
reject(res); reject(res);
...@@ -55,8 +55,8 @@ function signup(data) { ...@@ -55,8 +55,8 @@ function signup(data) {
const res = await app.$vm.$u.api.loginWechatAuth(data) const res = await app.$vm.$u.api.loginWechatAuth(data)
if (res) { if (res) {
if (res.code == 200 && res.data) { if (res.code == 200 && res.data) {
app.setUserData(res.data) // app.setUserData(res.data)
app.getBaseInfo(app.$vm) // app.getBaseInfo(app.$vm)
resolve(res); resolve(res);
} else { } else {
uni.showModal({ uni.showModal({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment