quanyawei
2023-10-27 52d463e03c1f074099ed8e8a6b7c3ddde52d2708
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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;
    }
 
    .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>