小程序授权后更新
This commit is contained in:
		@@ -5,7 +5,7 @@
 | 
			
		||||
        <div class="wrap" @click="handleLogin()">
 | 
			
		||||
          <div class="user-img-div">
 | 
			
		||||
            <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 class="user-info">
 | 
			
		||||
            <div class="option">
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,8 @@
 | 
			
		||||
        <div class="item solid">
 | 
			
		||||
          <p class="mar-t22">头像</p>
 | 
			
		||||
          <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>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="item">
 | 
			
		||||
@@ -45,18 +46,33 @@ export default {
 | 
			
		||||
        const {nickName} = this.user
 | 
			
		||||
        return nickName
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  onLoad() {
 | 
			
		||||
    this.getUserInfo()
 | 
			
		||||
    
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      editNickName: false
 | 
			
		||||
      editNickName: false,
 | 
			
		||||
      avatar: '',
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    ...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) {
 | 
			
		||||
      return new Promise((resolve, reject) => {
 | 
			
		||||
        uni.uploadFile({
 | 
			
		||||
@@ -68,6 +84,8 @@ export default {
 | 
			
		||||
            Authorization: uni.getStorageSync('token')
 | 
			
		||||
          },
 | 
			
		||||
          success: uploadFileRes => {
 | 
			
		||||
            this.avatar = JSON.parse(uploadFileRes.data).data[0].split(';')[0]
 | 
			
		||||
            console.log(JSON.parse(uploadFileRes.data).data[0].split(';')[0])
 | 
			
		||||
            resolve(uploadFileRes)
 | 
			
		||||
          },
 | 
			
		||||
          fail: err => {
 | 
			
		||||
@@ -94,8 +112,16 @@ export default {
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    handleWeixinSync({detail}) {
 | 
			
		||||
      const {value: nickName, avatarUrl} = detail
 | 
			
		||||
      this.autoLogin({nickName, avatarUrl})
 | 
			
		||||
      const { value: nickName, avatarUrl } = detail
 | 
			
		||||
      this.autoLogin({ nickName, avatarUrl })
 | 
			
		||||
      if(avatarUrl?.length) {
 | 
			
		||||
        this.upLoad(avatarUrl).then(() => {
 | 
			
		||||
          this.updateInfo()
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
      if(nickName) {
 | 
			
		||||
        this.updateInfo()
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user