Commit c202011f authored by 刘用法's avatar 刘用法

Merge branch 'dev' of https://git.banshouhui.com/lijundan/self-support into dev

parents 35484f29 8ca8e38f
...@@ -45,6 +45,7 @@ export default { ...@@ -45,6 +45,7 @@ export default {
bindTitle: '立即绑定', bindTitle: '立即绑定',
bindPhone: '绑定手机', bindPhone: '绑定手机',
bindTips: '首次登录的用户需绑定手机才可接单', bindTips: '首次登录的用户需绑定手机才可接单',
code: ''
} }
}, },
computed: { computed: {
...@@ -63,8 +64,14 @@ export default { ...@@ -63,8 +64,14 @@ export default {
if (app.globalData.authUserInfo) { if (app.globalData.authUserInfo) {
this.needAuth = false this.needAuth = false
} }
this.getCode()
}, },
methods: { methods: {
async getCode() {
login.appLogin().then(res => {
this.code = res.code
})
},
// 微信授权用户信息 // 微信授权用户信息
getUserProfile() { getUserProfile() {
var that = this var that = this
...@@ -144,10 +151,12 @@ export default { ...@@ -144,10 +151,12 @@ export default {
encryptedData: e.detail.encryptedData, encryptedData: e.detail.encryptedData,
iv: e.detail.iv, iv: e.detail.iv,
} }
login.appLogin().then(res => { if (that.code) {
params.code = res.code uni.checkSession({
return login.signup(params); success () {
}).then(res => { //session_key 未过期,并且在本生命周期一直有效
params.code = that.code
login.signup(params).then(res => {
uni.hideLoading() uni.hideLoading()
if (res) { if (res) {
app.setUserData(res.data, that) app.setUserData(res.data, that)
...@@ -164,6 +173,15 @@ export default { ...@@ -164,6 +173,15 @@ export default {
uni.hideLoading() uni.hideLoading()
this.setLoginStatus(false) this.setLoginStatus(false)
}) })
},
fail () {
// session_key 已经失效,需要重新执行登录流程
that.toLogin(params)
}
})
} else {
this.toLogin(params)
}
} else { } else {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
...@@ -179,7 +197,29 @@ export default { ...@@ -179,7 +197,29 @@ export default {
}); });
} }
}, },
toLogin(params) {
login.appLogin().then(res => {
params.code = res.code
console.log("params3", params)
return login.signup(params);
}).then(res => {
uni.hideLoading()
if (res) {
app.setUserData(res.data, this)
app.getBaseInfo(this)
this.goBackPage()
} else {
uni.showToast({
title: '授权失败,请重新授权',
icon: 'none'
});
this.setLoginStatus(false)
}
}).catch(res => {
uni.hideLoading()
this.setLoginStatus(false)
})
},
goBackPage() { goBackPage() {
let pages = getCurrentPages(); let pages = getCurrentPages();
if(pages.length) { if(pages.length) {
...@@ -206,6 +246,7 @@ export default { ...@@ -206,6 +246,7 @@ export default {
}, },
setLoginStatus(authed = true) { setLoginStatus(authed = true) {
getApp().globalData.logout = false getApp().globalData.logout = false
this.code = ''
if (authed) { if (authed) {
this.needAuth = false this.needAuth = false
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
......
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