Commit 1e812d41 authored by linwenqing's avatar linwenqing

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

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