doum
昨天 14e7b7fcf0b9ca0432257116a26e9ed324e89328
mini-program/pages/settings/settings.vue
@@ -10,19 +10,19 @@
         <view class="list-item">
            <view class="list-item-label">昵称</view>
            <view class="list-item-val">
               <input type="nickname" v-model="form.nickname" placeholder="请输入" />
               <input type="text" v-model="form.nickname" @blur="updateUserInfo" placeholder="请输入" />
            </view>
         </view>
         <view class="list-item">
            <view class="list-item-label">真实姓名</view>
            <view class="list-item-val">
               <input type="text" v-model="form.name" placeholder="请输入" />
               <input type="text" v-model="form.name" @blur="updateUserInfo" placeholder="请输入" />
            </view>
         </view>
         <view class="list-item">
            <view class="list-item-label">绑定手机</view>
            <view class="list-item-val" @click="show = true">
               <text>{{form.phone}}</text>
               <text>{{form.phone1}}</text>
               <image src="/static/icon/ar_next@2x.png" mode="widthFix"></image>
            </view>
         </view>
@@ -39,19 +39,19 @@
            </view>
         </view>
      </view>
      <view class="loginOut">退出登录</view>
      <view class="loginOut" @click="tuichu">退出登录</view>
      <!-- 更换手机号 -->
      <u-popup :show="show" round="15" :safeAreaInsetBottom="false" mode="center">
         <view class="tc">
            <view class="tc-contemt">
               <view class="tc-contemt-title">更换绑定手机号?</view>
               <view class="tc-contemt-nr">
                  更换后现手机号130****9696将不能用于登录,180天内只可更换一次
                  更换后现手机号{{returnPhone(form.phone)}}将不能用于登录,180天内只可更换一次
               </view>
            </view>
            <view class="tc-btn">
               <view class="tc-btn-item" @click="show = false">我再想想</view>
               <view class="tc-btn-item" style="color: #004096;">确认更换</view>
               <view class="tc-btn-item" style="color: #004096;" @click="jumpPhone">确认更换</view>
            </view>
         </view>
      </u-popup>
@@ -60,9 +60,10 @@
<script>
   import { mapState } from 'vuex'
   import { formatPhoneStar } from '@/utils/utils.js'
   export default {
      computed: {
         ...mapState(['userInfo'])
         ...mapState(['userInfo', 'token'])
      },
      data() {
         return {
@@ -71,6 +72,7 @@
               nickname: '',
               name: '',
               phone: '',
               phone1: '',
               imgFullUrl: '',
               imgurl: ''
            }
@@ -80,13 +82,63 @@
         this.form.nickname = this.userInfo.nickname
         this.form.name = this.userInfo.name
         this.form.phone = this.userInfo.phone
         this.form.phone1 = this.returnPhone(this.userInfo.phone)
         this.form.imgFullUrl = this.userInfo.imgFullUrl
         this.form.imgurl = this.userInfo.imgurl
      },
      methods: {
         getAvatar(e) {
            console.log(e)
         returnPhone(phone) {
            return formatPhoneStar(phone)
         },
         jumpPhone() {
            uni.navigateTo({
               url: '/pages/change-binding/change-binding'
            })
         },
         jumpAddr() {
            uni.navigateTo({
               url: '/pages/address/address'
            })
         },
         // 上传头像
         getAvatar(e) {
            var that = this;
            uni.uploadFile({
               url: `${this.$baseUrl}public/upload`,
               filePath: e.detail.avatarUrl,
               name: 'file',
               fileType: 'image',
               header: { 'token': this.token },
               formData: { folder: 'member' },
               success: (uploadFileRes) => {
                  let result = JSON.parse(uploadFileRes.data)
                  that.form.imgurl = result.data.imgaddr
                  that.form.imgFullUrl = result.data.url
                  that.updateUserInfo()
               }
            });
         },
         // 更新用户信息
         updateUserInfo() {
            this.$u.api.updateMember(this.form)
               .then(res => {
                  if (res.code === 200) {
                     console.log(res)
                  }
               })
         },
         // 退出登录
         tuichu() {
            this.$u.api.logOut()
               .then(res => {
                  if (res.code === 200) {
                     this.$store.commit('clear')
                     uni.switchTab({
                        url: '/pages/index/index'
                     })
                  }
               })
         }
      }
   }
</script>