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