quanyawei
2023-10-31 5fecc9e46d448df3de987504440c4fdd582f858e
pages/actionChange/myInfor/index.vue
@@ -2,15 +2,17 @@
   <view class="mainContent">
      <view class="headerAvatar">
         <view class="">
            <u-avatar :text="firstFont" fontSize="40" randomBgColor size='100'></u-avatar>
            <u-avatar :src="avatarUrl" fontSize="40" randomBgColor size='100'></u-avatar>
         </view>
      </view>
      <view class="inforBox">
         <u-cell-group>
         <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 icon="clock-fill" title="查看秒级数据" v-if="userInfor.device===1" isLink
               url="/pages/actionChange/secondLevelData/index"></u-cell>
         </u-cell-group>
      </view>
      <view class="bunts">
@@ -19,38 +21,49 @@
   </view>
</template>
<script>
   import {
      created
   } from '../../../uni_modules/uview-ui/libs/mixin/mixin'
   import store from '@/store/index.js'
   export default {
      data() {
         return {
            loading: false,
            userInfor: {},
            unitList: []
            avatarUrl: '',
            unitList: [],
            fontStyleobj: {
               'fontSize': '16px'
            }
         }
      },
      computed: {
         unitName() {
            let data = ''
            if (this.unitList.length > 0) {
               data = this.unitList.find(a => parseInt(a.unitId) === this.userInfor.unitId).unitName
            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() {
            return this.userInfor.userName[0] || '七'
         }
         // 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 = this.$storage.getJson('userInfo')
         console.log('userInfor', this.userInfor.userName[0])
         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: '确认退出吗?',
@@ -60,10 +73,11 @@
                        userId: this.userInfor.userId
                     }).then(res => {
                        uni.clearStorageSync()
                        uni.setStorageSync('openId', openId)
                        uni.reLaunch({
                           url: '/pages/login/login',
                        })
                     }).catch(uni.$u.toast('退出失败'))
                     })
                  }
               }
            })
@@ -88,4 +102,9 @@
   .bunts {
      margin-top: 57.69rpx;
   }
   /deep/ .u-cell__title-text,
   /deep/.u-cell__value {
      font-size: 30.77rpx !important;
   }
</style>