|
|
@@ -188,15 +188,19 @@ export default {
|
|
|
},
|
|
|
getUserInfo () {
|
|
|
this.error = false
|
|
|
- userinfo().then(data => {
|
|
|
- this.avatar = this.getOrCreateAttribute(data, 'avatar', '')
|
|
|
- this.phone = this.getOrCreateAttribute(data, 'phone', '')
|
|
|
- this.email = data.email ?? ''
|
|
|
- this.wechat = this.getOrCreateAttribute(data, 'wechat', '')
|
|
|
- this.user = data
|
|
|
- }, () => {
|
|
|
- this.error = true
|
|
|
- })
|
|
|
+ userinfo().then(
|
|
|
+ this.setUserInfo,
|
|
|
+ () => {
|
|
|
+ this.error = true
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ setUserInfo (data) {
|
|
|
+ this.avatar = this.getOrCreateAttribute(data, 'avatar', '')
|
|
|
+ this.phone = this.getOrCreateAttribute(data, 'phone', '')
|
|
|
+ this.email = data.email ?? ''
|
|
|
+ this.wechat = this.getOrCreateAttribute(data, 'wechat', '')
|
|
|
+ this.user = data
|
|
|
},
|
|
|
getOrCreateAttribute (user, key, defaults = '') {
|
|
|
if (!user.attributes[key]) {
|
|
|
@@ -277,7 +281,11 @@ export default {
|
|
|
},
|
|
|
onClickWechat () {
|
|
|
if (this.wechat) {
|
|
|
- this.$confirm('解除绑定后将无法再收到消息推送', '确定解绑微信?', { type: 'warning' }).then(
|
|
|
+ this.$confirm(
|
|
|
+ '解除绑定后将无法再收到消息推送',
|
|
|
+ '确定解绑微信?',
|
|
|
+ { type: 'warning' }
|
|
|
+ ).then(
|
|
|
() => {
|
|
|
this.changeAttribute('wechat', this.wechat = '', '解绑微信')
|
|
|
}
|
|
|
@@ -320,7 +328,7 @@ export default {
|
|
|
const { expire_seconds, ticket } = JSON.parse(data)
|
|
|
this.qr = `https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=${ticket}`
|
|
|
// 提前10秒重新获取
|
|
|
- this.$timer = setTimeout(this.fetchQr, (expire_seconds - 10) * 1000)
|
|
|
+ this.$timer = setTimeout(this.fetchQr, (expire_seconds > 10 ? expire_seconds - 10 : expire_seconds) * 1000)
|
|
|
this.checkBind()
|
|
|
} catch (e) {
|
|
|
console.warn(e)
|
|
|
@@ -350,8 +358,7 @@ export default {
|
|
|
type: 'success',
|
|
|
message: '绑定微信成功'
|
|
|
})
|
|
|
- this.wechat = wechat
|
|
|
- this.user.attributes.wechat[0] = wechat
|
|
|
+ this.setUserInfo(data)
|
|
|
this.onCloseQr()
|
|
|
this.resetQr()
|
|
|
}
|