Commit 088c8bca by 尹烁恒

提交

parent 02b214b7
...@@ -96,7 +96,7 @@ export default { ...@@ -96,7 +96,7 @@ export default {
success(res) { success(res) {
that._jscode = res.code that._jscode = res.code
wx.setStorageSync('hasLogin', true) wx.setStorageSync('hasLogin', true)
resolve() resolve(res.code)
}, },
fail() { fail() {
console.log('login fail') console.log('login fail')
...@@ -124,10 +124,11 @@ export default { ...@@ -124,10 +124,11 @@ export default {
console.log(e) console.log(e)
if (e.target.errMsg === 'getUserInfo:ok') { if (e.target.errMsg === 'getUserInfo:ok') {
if (wx.getStorageSync('hasLogin')) { if (wx.getStorageSync('hasLogin')) {
this.getUserInfo(e.target) const code = await this.login()
this.getUserInfo(e.target, code)
} else { } else {
await this.login() const code = await this.login()
this.getUserInfo(e.target) this.getUserInfo(e.target, code)
} }
} else { } else {
wx.showModal({ wx.showModal({
...@@ -137,11 +138,15 @@ export default { ...@@ -137,11 +138,15 @@ export default {
}) })
} }
}, },
async getUserInfo(res) { async getUserInfo(res, code = '') {
console.log(code, 'userinfo code')
if (!code) {
code = this._jscode
}
fly.post('auth_login', { fly.post('auth_login', {
encrypted_data: res.encryptedData, encrypted_data: res.encryptedData,
iv: res.iv, iv: res.iv,
js_code: this._jscode js_code: code
}) })
.then(res => { .then(res => {
console.log(res.data.token, 'token') console.log(res.data.token, 'token')
...@@ -150,8 +155,9 @@ export default { ...@@ -150,8 +155,9 @@ export default {
this.handleSubmit() this.handleSubmit()
}) })
.catch(async res => { .catch(async res => {
await this.login() const code = await this.login()
this.getUserInfo(res) console.log('code is 11111', code)
this.getUserInfo(res, code)
}) })
}, },
getConfig() { getConfig() {
...@@ -230,7 +236,7 @@ export default { ...@@ -230,7 +236,7 @@ export default {
const contentType = res.header['content-type'] const contentType = res.header['content-type']
store.commit('setImage', 'data:' + contentType + ';base64,' + base64) store.commit('setImage', 'data:' + contentType + ';base64,' + base64)
wx.hideLoading() wx.hideLoading()
wx.redirectTo({ wx.navigateTo({
url: `/pages/logs/main` url: `/pages/logs/main`
}) })
} else { } else {
......
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