Commit cfcbb836 by 李嘉林

修改登录报错问题

parent 96451a43
...@@ -37,6 +37,7 @@ export default { ...@@ -37,6 +37,7 @@ export default {
}, },
data() { data() {
return { return {
code: "",
session_key: "", session_key: "",
shopName: "", shopName: "",
logoUrl: "", logoUrl: "",
...@@ -66,6 +67,32 @@ export default { ...@@ -66,6 +67,32 @@ export default {
}; };
}, },
created() {}, created() {},
onShow() {
wx.checkSession({
success : () => {
//session_key 未过期,并且在本生命周期一直有效
wx.login({
success: res => {
this.code = res.code;
},
fail: err => {
reject(err);
}
}) //重新登录
},
fail : () => {
// session_key 已经失效,需要重新执行登录流程
wx.login({
success: res => {
this.code = res.code;
},
fail: err => {
reject(err);
}
}) //重新登录
}
})
},
onLoad(options) { onLoad(options) {
Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化 Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化
if (options.back) { if (options.back) {
...@@ -103,30 +130,21 @@ export default { ...@@ -103,30 +130,21 @@ export default {
}, },
init() { init() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.login({ login
success: res => { .miniLogin({ code: this.code,
if (res.code) { spokesmanRelId : this.$store.state.spokesmanRelId,
login spokesmanGroupId : this.$store.state.spokesmanGroupId,
.miniLogin({ code: res.code, spokesmanShopId : this.$store.state.spokesmanShopId
spokesmanRelId : this.$store.state.spokesmanRelId, })
spokesmanGroupId : this.$store.state.spokesmanGroupId, .then(res => {
spokesmanShopId : this.$store.state.spokesmanShopId if (res.data.code == 200) {
}) resolve(res);
.then(res => { } else {
if (res.data.code == 200) { reject(res.data.msg);
resolve(res);
} else {
reject(res.data.msg);
}
})
.catch(err => {
reject(err);
});
}
},
fail: err => {
reject(err);
} }
})
.catch(err => {
reject(err);
}); });
}); });
}, },
......
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