quanyawei
2023-10-27 52d463e03c1f074099ed8e8a6b7c3ddde52d2708
pages/actionChange/myInfor/index.vue
@@ -1,8 +1,108 @@
<template>
   <view class="mainContent">
      <view class="headerAvatar">
         <view class="">
            <u-avatar :src="avatarUrl" fontSize="40" randomBgColor size='100'></u-avatar>
         </view>
      </view>
      <view class="inforBox">
         <u-cell-group :custom-style='fontStyleobj'>
            <u-cell icon="server-man" title="姓名" :value="userInfor.userName"></u-cell>
            <u-cell icon="account-fill" title="账号" :value="userInfor.account"></u-cell>
            <u-cell icon="integral-fill" title="责任单位" :value="unitName"></u-cell>
            <u-cell icon="phone-fill" title="手机号" :value="userInfor.mobile"></u-cell>
         </u-cell-group>
      </view>
      <view class="bunts">
         <u-button type="error" text="退出" @click="goOut"></u-button>
      </view>
   </view>
</template>
<script>
   import store from '@/store/index.js'
   export default {
      data() {
         return {
            loading: false,
            userInfor: {},
            avatarUrl: '',
            unitList: [],
            fontStyleobj: {
               'fontSize': '16px'
            }
         }
      },
      computed: {
         unitName() {
            let data = ''
            if (Object.values(this.userInfor).length > 0 && this.unitList.length > 0) {
               if (this.userInfor.unitId) {
                  data = this.unitList.find(a => parseInt(a.unitId) === this.userInfor.unitId).unitName
               }
            }
            return data || ''
         },
         // firstFont() {
         //    let data = ''
         //    if (Object.values(this.userInfor).length > 0) {
         //       data = this.userInfor.userName[0]
         //    }
         //    return data || '七'
         // }
      },
      created() {
         this.$http.httpGet('/allocation/unit').then(res => {
            this.unitList = res.data
         })
         this.userInfor = JSON.parse(uni.getStorageSync('userInfor') || '{}')
         console.log('this.userInforGet', this.userInfor)
         let baseUrl = this.$storage.get('baseUrl')
         this.avatarUrl = `${baseUrl}/file/preview/${this.userInfor.file.fileId}`
      },
      methods: {
         goOut() {
            let openId = uni.getStorageSync('openId')
            uni.showModal({
               title: '退出',
               content: '确认退出吗?',
               success: res => {
                  if (res.confirm) {
                     this.$http.httpGet('/AppUser/wx/exit', {
                        userId: this.userInfor.userId
                     }).then(res => {
                        uni.clearStorageSync()
                        uni.setStorageSync('openId', openId)
                        uni.reLaunch({
                           url: '/pages/login/login',
                        })
                     })
                  }
               }
            })
         }
      }
   }
</script>
<style lang="scss" scoped>
   .mainContent {
      padding: 20px;
   }
<style>
   .headerAvatar {
      display: flex;
      justify-content: center;
   }
   .inforBox {
      margin-top: 57.69rpx;
   }
   .bunts {
      margin-top: 57.69rpx;
   }
   /deep/ .u-cell__title-text,
   /deep/.u-cell__value {
      font-size: 30.77rpx !important;
   }
</style>