Mr.Shi
2023-09-11 24eb9d89423613c7322da715f2a445b4466ffcf4
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<template>
    <div class="box">
        <div class="box_info">
            <!-- store.state.userInfo.avatar ? store.state.userInfo.avatar :  -->
            <img :src="avatar" alt="" />
            <div class="box_info_box">
                <span>{{store.state.userInfo.companyUser ? store.state.userInfo.companyUser.name : ''}}</span>
                <div class="box_info_box_x" @click="switchOrganization">
                    <span>{{store.state.userInfo.curComDepartment ? store.state.userInfo.curComDepartment.name : ''}}</span>
                    <img src="@/assets/icon/mine_ic_change@2x.png" alt="" />
                </div>
            </div>
        </div>
        <div class="box_function">
            <div class="box_function_item" v-for="(item, index) in MENU" :key="index" @click="JUMP(item.url)">
                <div class="box_function_item_left">
                    <img :src="item.icon" alt="" />
                    <span>{{item.name}}</span>
                </div>
                <div class="box_function_item_right">
                    <van-icon name="arrow" size="20" color="#CCCCCC" />
                </div>
            </div>
        </div>
        <div class="box_out" v-if="store.state.env && (store.state.env == 'WX' || store.state.env == 'XCX')" @click="loginOut"><span>退出登录</span></div>
    </div>
    <van-popup v-model:show="show" position="bottom" round :style="{ height: '50%' }">
        <van-picker
            title="请选择组织"
            :columns="columns"
            @confirm="onConfirm"
            @cancel="onCancel"
        />
    </van-popup>
</template>
 
<script setup lang="ts">
    import { ref } from 'vue'
    import { useRouter } from 'vue-router'
    import { useStore } from "vuex"
    import { Dialog, Toast } from 'vant'
    const VanDialog = Dialog.Component;
    import { changeCom, getDepartmentListByConditon } from '@/apis/PersonalAPI'
    import { wxLoginOut } from '@/apis'
 
    const router = useRouter()
 
    const store = useStore()
 
    let show = ref<boolean>(false)   // 控制切换组织弹框
 
    let columns = ref([]);     // 组织数据
 
    let avatar: any = require('@/assets/icon/2@2x.png')     // 默认头像
 
    const MENU = ref([
        { name: '个人信息', url: '/personal/personalInformation', icon: require('@/assets/icon/mine_ic_gerenxinxi@2x.png') },
        // { name: '系统通知', url: '', icon: require('@/assets/icon/mine_ic_xitonggonggao@2x.png') },
        { name: '更新手机号', url: '/personal/updatePhone', icon: require('@/assets/icon/mine_ic_shoujihao@2x.png') },
        { name: '更新邮箱号', url: '/personal/updateMailbox', icon: require('@/assets/icon/mine_ic_youxianghao@2x.png') },
        { name: '扫码绑定账号', url: '', icon: require('@/assets/icon/mine_ic_bangding@2x.png') },
        { name: '修改密码', url: '/personal/changePassword', icon: require('@/assets/icon/mine_ic_xiugaimima@2x.png') },
    ])
 
    // 确认切换组织
    const onConfirm = (value: any): void => {
        changeCom(value.id).then(res => {
            show.value = false
            Toast.success({ message: '更新组织成功' })
            store.dispatch('getUserInfos')
        })
    };
 
    // 退出登录
    const loginOut = () => {
        wxLoginOut({
            companyUserId: store.state.userInfo.companyUser.id
        }).then(res => {
            if (res.code === 200) {
                // window.parent.postMessage('阿康', '*')
                // let href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6ea339a336f26380&redirect_url=https://www.mes.red/h5/redirect.html&response_type=code&scope=snsapi_base&state=#wechat_redirect'
                let href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6ea339a336f26380&redirect_url=https://dmtest.ahapp.net/doumeeplant_h5/redirect.html&response_type=code&scope=snsapi_base&state=#wechat_redirect'
                window.open(href)
            }
        })
    }
 
    // 关闭组织弹框
    const onCancel = (): void => {
        show.value = false
    }
 
    // 跳转页面
    const JUMP = (url: string): void => {
        url ? router.push({ path: url }) : ''
    }
 
    // 切换组织
    const switchOrganization = (): void => {
        getDepartmentListByConditon({
            type: 0
        }).then(res => {
            if (res.code === 200) {
                columns.value = []
                res.data.forEach((item: any) => {
                    let obj: any = {
                        text: item.name, id: item.id
                    }
                    columns.value.push(obj as never)
                })
                show.value = true
            }
        })
 
    }
</script>
 
<style lang="scss" scoped>
.box {
    padding: 30px;
    .box_info {
        padding: 0 30px;
        height: 168px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        background: url("@/assets/icon/mine_bg@2x.png");
        background-repeat: no-repeat;
        background-size: cover;
        img {
            width: 88px;
            height: 88px;
        }
        .box_info_box {
            height: 88px;
            display: flex;
            margin-left: 30px;
            flex-direction: column;
            justify-content: space-between;
            .box_info_box_x {
                display: flex;
                align-items: center;
                span {
                    font-size: 26px;
                    font-weight: 400;
                    color: rgba(255, 255, 255, 0.8);
                }
                img {
                    width: 26px;
                    height: 26px;
                    margin-left: 10px;
                }
            }
            span {
                font-size: 34px;
                font-weight: 500;
                color: #FFFFFF;
            }
        }
    }
    .box_function {
        margin-top: 30px;
        .box_function_item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 98px;
            border-bottom: 1PX solid #E5E5E5;
            /*&:last-child {*/
            /*    border: none;*/
            /*}*/
            .box_function_item_left {
                display: flex;
                align-items: center;
                img {
                    width: 36px;
                    height: 36px;
                    margin-right: 24px;
                }
                span {
                    font-size: 30px;
                    font-weight: 400;
                    color: #222222;
                }
            }
        }
    }
    .box_out {
        position: fixed;
        bottom: 200px;
        left: 50%;
        transform: translate(-50%, 0);
        width: 350px;
        height: 88px;
        background: #F7F7F7;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 30px;
        font-weight: 400;
        color: #333333;
    }
}
</style>