Commit 1e812d41 authored by linwenqing's avatar linwenqing

fix:绑定手机 提示系统繁忙,前段先获取code再点获取手机授权,最后一起传给接口,保证code和加密串一致

parent b3468d79
......@@ -28,8 +28,8 @@
<view slot="right-icon">
<u-image
v-if="headCertPhoto"
width="92rpx"
height="120rpx"
width="92"
height="120"
:src="headCertPhoto"
></u-image>
<text v-else style="color:#2953FF">去上传</text>
......@@ -87,7 +87,7 @@ export default {
isCertify: false,
},
qiToken: null,
code: '',
sessionCode: '',
count: 0,
}
},
......@@ -98,10 +98,6 @@ export default {
)
},
headCertPhoto() {
console.log(
'touxiang bianle',
this.student ? this.student.certificatePhotoPath : 'kong'
)
return (this.student && this.student.certificatePhotoPath) || false
},
getMobile() {
......@@ -117,20 +113,18 @@ export default {
return (this.student && this.student.workUnit) || '去填写'
},
getCertifyStatus() {
console.log('is cert', this.student.isCertify)
return this.student.isCertify ? '已认证' : '去认证'
},
},
onLoad() {
this.refleshCode()
this.$u.api
.getQiNiuToken({ bucketName: 'banshou-userprofile' })
.then((res) => {
console.log('chushihua token', res)
this.qiToken = res //token为七牛云的token一般由后台接口提供
this.qiToken = res
getApp().globalData.qiNiuToken = res
})
this.$u.api.getUserInfo().then((res) => {
console.log('huoqu userinfo', res)
if (res) {
res.isCertify =
res && res.identityNumber && res.identityNumber.length > 5
......@@ -140,10 +134,6 @@ export default {
}
})
},
onShow() {
console.log('iddd', this.student)
console.log('iddd global', getApp().globalData.student)
},
methods: {
goCertify() {
getApp().globalData.student = this.student
......@@ -158,7 +148,6 @@ export default {
})
},
getPhonenumber(e) {
console.log('eeeee', e)
let params = {}
if (e && e.detail) {
if (e.detail.errMsg.indexOf('user deny') > -1) {
......@@ -182,25 +171,16 @@ export default {
},
syncUserinfo(params) {
let that = this
if (!that.sessionCode) {
that.toLogin()
}
uni.checkSession({
success() {
console.log('走的第一个1')
//session_key 未过期,并且在本生命周期一直有效
uni.login({
provider: 'weixin',
success: (code_res) => {
//获取code
if (code_res.errMsg == 'login:ok') {
console.log('走的第一个2')
params.code = code_res.code
//传参到服务器解析
that.sendInfo(params)
}
},
})
params.code = that.sessionCode
//传参到服务器解析
that.sendInfo(params)
},
fail() {
console.log('走的第二个1', params)
// session_key 已经失效,需要重新执行登录流程
setTimeout(() => {
uni.navigateTo({
......@@ -210,6 +190,18 @@ export default {
},
})
},
refleshCode() {
let that = this
uni.login({
provider: 'weixin',
success: (code_res) => {
//获取code
if (code_res.errMsg == 'login:ok') {
that.sessionCode = code_res.code
}
},
})
},
sendInfo(params) {
this.$u.api
.loginWechatAuth(params)
......@@ -224,6 +216,7 @@ export default {
})
})
.catch((err) => {
this.$u.toast('请登录后再绑定')
this.$u.route({
url: 'pages/login/index',
params: {
......@@ -252,10 +245,13 @@ export default {
})
})
},
toUrl(url) {
this.$u.route({
url: url,
})
toLogin() {
this.$u.toast('登录信息已失效,请重新登录')
setTimeout(() => {
uni.navigateTo({
url: 'pages/login/index',
})
}, 800)
},
},
}
......
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