Commit ca25dc00 authored by linwenqing's avatar linwenqing

Merge remote-tracking branch 'remotes/origin/dev-fix-auth' into test

parents 31a658e1 75016146
......@@ -21,15 +21,19 @@ function getPhoto(type, token) {
reject(msg)
})
},
complete: function() {
uni.hideLoading()
},
})
})
}
//上传七牛
function upload(filePath, token) {
console.log('filePath', filePath)
console.log('token', token)
return new Promise((resolve, reject) => {
uni.showLoading({
title: '上传中...',
})
let key =
new Date().getTime() + Math.random(1000) + filePath.split('/').pop() //key为自定义文件名
uni.uploadFile({
......
......@@ -36,7 +36,7 @@
</view>
</u-cell-item>
<u-cell-item title="手机号">
<view slot="right-icon">
<view slot="right-icon" @click.capture="refleshCode">
<button
open-type="getPhoneNumber"
@getphonenumber="getPhonenumber"
......@@ -118,7 +118,6 @@ export default {
},
onLoad() {
getApp().trackPage('我的信息')
this.refleshCode()
this.$u.api.getQiNiuToken({ bucketName: 'wsy-exam' }).then((res) => {
this.qiToken = res
getApp().globalData.qiNiuToken = res
......@@ -150,7 +149,12 @@ export default {
let params = {}
if (e && e.detail) {
if (e.detail.errMsg.indexOf('user deny') > -1) {
//拒绝授权
uni.hideLoading()
this.$refs.uToast.show({
title: '用户拒绝授权',
type: 'warning',
duration: 2000,
})
return
} else if (e.detail.encryptedData && e.detail.iv) {
//允许授权-解析-更新手机号
......@@ -159,17 +163,19 @@ export default {
iv: e.detail.iv,
}
} else {
uni.hideLoading()
this.$refs.uToast.show({
title: e.detail.errMsg,
type: 'error',
title: '用户取消授权',
type: 'warning',
duration: 2000,
})
return
}
} else {
uni.hideLoading()
this.$refs.uToast.show({
title: '授权失败,请重新授权',
type: 'error',
type: 'warning',
duration: 2000,
})
return
......@@ -195,16 +201,23 @@ export default {
},
fail() {
// session_key 已经失效,需要重新执行登录流程
setTimeout(() => {
uni.navigateTo({
url: 'pages/login/index',
})
}, 800)
that.toLogin()
},
})
},
inGetPhone() {
uni.showLoading({
title: '授权中...',
})
},
inUpload() {
uni.showLoading({
title: '上传中...',
})
},
refleshCode() {
let that = this
this.inGetPhone()
uni.login({
provider: 'weixin',
success: (code_res) => {
......@@ -220,11 +233,13 @@ export default {
.loginWechatAuth(params)
.then((res) => {
this.student.phoneNumber = res.phoneNumber
this.inGetPhone()
this.$u.api
.updateUserInfo({
phoneNumber: res.phoneNumber,
})
.then((ret) => {
uni.hideLoading()
this.$refs.uToast.show({
title: '绑定成功!',
type: 'success',
......@@ -233,20 +248,11 @@ export default {
})
})
.catch((err) => {
this.$refs.uToast.show({
title: '请登录后再绑定',
type: 'warning',
duration: 2000,
})
this.$u.route({
url: 'pages/login/index',
params: {
path: 'pages/mine/info',
},
})
this.toLogin()
})
},
changeHead() {
this.inUpload()
//更换头像
upload.getPhoto(2, this.qiToken).then((res) => {
this.student.avatarPath = process.uniEnv.qn_asset_url + res.key
......@@ -259,10 +265,14 @@ export default {
...params,
}
getApp().track('changeAvatar', trackParams)
this.$u.api.updateUserInfo(params)
this.inUpload()
this.$u.api.updateUserInfo(params).then(() => {
uni.hideLoading()
})
})
},
changeCertPhoto() {
this.inUpload()
//更换证件头像
upload.getPhoto(2, this.qiToken).then((res) => {
this.student.certificatePhotoPath =
......@@ -276,7 +286,17 @@ export default {
...params,
}
getApp().track('changeCertPhoto', trackParams)
this.$u.api.updateUserInfo(params)
this.inUpload()
this.$u.api.updateUserInfo(params).then(() => {
uni.hideLoading()
})
})
},
userRefuseTip() {
this.$refs.uToast.show({
title: '用户拒绝授权',
type: 'warning',
duration: 2000,
})
},
toLogin() {
......@@ -288,6 +308,9 @@ export default {
setTimeout(() => {
uni.navigateTo({
url: 'pages/login/index',
params: {
path: 'pages/mine/info',
},
})
}, 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