小程序授权后更新
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<div class="wrap" @click="handleLogin()">
|
<div class="wrap" @click="handleLogin()">
|
||||||
<div class="user-img-div">
|
<div class="user-img-div">
|
||||||
<img :src="user.avatarUrl" alt="" class="user-img" v-if="user.id && user.avatarUrl"/>
|
<img :src="user.avatarUrl" alt="" class="user-img" v-if="user.id && user.avatarUrl"/>
|
||||||
<open-data type="userAvatarUrl" lang="zh_CN" class="user-img" v-else/>
|
<img class="user-img" src="https://cdn.cunwuyun.cn/dvcp/myFamily/tx.png" v-else alt="">
|
||||||
</div>
|
</div>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<div class="option">
|
<div class="option">
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
<div class="item solid">
|
<div class="item solid">
|
||||||
<p class="mar-t22">头像</p>
|
<p class="mar-t22">头像</p>
|
||||||
<button class="user-img-div" open-type="chooseAvatar" @chooseavatar="handleWeixinSync">
|
<button class="user-img-div" open-type="chooseAvatar" @chooseavatar="handleWeixinSync">
|
||||||
<img :src="user.avatarUrl" class="user-img">
|
<img v-if="user.avatarUrl" :src="user.avatarUrl" class="user-img">
|
||||||
|
<!-- <img src="https://cdn.cunwuyun.cn/dvcp/myFamily/tx.png" alt="" class="user-img" > -->
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
@@ -45,18 +46,33 @@ export default {
|
|||||||
const {nickName} = this.user
|
const {nickName} = this.user
|
||||||
return nickName
|
return nickName
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.getUserInfo()
|
this.getUserInfo()
|
||||||
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editNickName: false
|
editNickName: false,
|
||||||
|
avatar: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['getUserInfo', 'autoLogin']),
|
...mapActions(['getUserInfo', 'autoLogin']),
|
||||||
|
updateInfo() {
|
||||||
|
this.$instance.post(`/app/appwechatuser/update-nickName`,null,{
|
||||||
|
params: {
|
||||||
|
id: this.user.id,
|
||||||
|
nickName: this.nickName,
|
||||||
|
avatarUrl: this.avatar? this.avatar : this.user.avatarUrl,
|
||||||
|
}
|
||||||
|
}).then(res=> {
|
||||||
|
if(res?.code==0) {
|
||||||
|
this.$u.toast('修改成功')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
upLoad(img) {
|
upLoad(img) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
@@ -68,6 +84,8 @@ export default {
|
|||||||
Authorization: uni.getStorageSync('token')
|
Authorization: uni.getStorageSync('token')
|
||||||
},
|
},
|
||||||
success: uploadFileRes => {
|
success: uploadFileRes => {
|
||||||
|
this.avatar = JSON.parse(uploadFileRes.data).data[0].split(';')[0]
|
||||||
|
console.log(JSON.parse(uploadFileRes.data).data[0].split(';')[0])
|
||||||
resolve(uploadFileRes)
|
resolve(uploadFileRes)
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
@@ -94,8 +112,16 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleWeixinSync({detail}) {
|
handleWeixinSync({detail}) {
|
||||||
const {value: nickName, avatarUrl} = detail
|
const { value: nickName, avatarUrl } = detail
|
||||||
this.autoLogin({nickName, avatarUrl})
|
this.autoLogin({ nickName, avatarUrl })
|
||||||
|
if(avatarUrl?.length) {
|
||||||
|
this.upLoad(avatarUrl).then(() => {
|
||||||
|
this.updateInfo()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if(nickName) {
|
||||||
|
this.updateInfo()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user