quanyawei
2023-10-20 d8b41fff43a2cee6a8f714ffa807623b15803786
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
<template>
    <view class="mainContent">
        <view class="headerAvatar">
            <view class="">
                <u-avatar :text="firstFont" fontSize="40" randomBgColor size='100'></u-avatar>
            </view>
        </view>
        <view class="inforBox">
            <u-cell-group>
                <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 {
        created
    } from '../../../uni_modules/uview-ui/libs/mixin/mixin'
    export default {
        data() {
            return {
                loading: false,
                userInfor: {},
                unitList: []
            }
        },
        computed: {
            unitName() {
                let data = ''
                if (this.unitList.length > 0) {
                    data = this.unitList.find(a => parseInt(a.unitId) === this.userInfor.unitId).unitName
                }
                return data || ''
            },
            firstFont() {
                return this.userInfor.userName[0] || '七'
            }
        },
        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])
        },
        methods: {
            goOut() {
                uni.showModal({
                    title: '退出',
                    content: '确认退出吗?',
                    success: res => {
                        if (res.confirm) {
                            this.$http.httpGet('/AppUser/wx/exit', {
                                userId: this.userInfor.userId
                            }).then(res => {
                                uni.clearStorageSync()
                                uni.reLaunch({
                                    url: '/pages/login/login',
                                })
                            }).catch(uni.$u.toast('退出失败'))
                        }
                    }
                })
            }
        }
    }
</script>
<style lang="scss" scoped>
    .mainContent {
        padding: 20px;
    }
 
    .headerAvatar {
        display: flex;
        justify-content: center;
    }
 
    .inforBox {
        margin-top: 57.69rpx;
    }
 
    .bunts {
        margin-top: 57.69rpx;
    }
</style>