wujingjing
2025-03-14 082d9b64ad9bd5e45f0571b7bb042b30007189ac
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
<template>
    <div class="flex flex-col">
        <el-dialog v-model="isShowInformation" title="我的信息" width="500" :before-close="handleCloseInformation">
            <el-form :model="userInformationInfo" ref="autoDialogFormRef" label-width="85">
                <el-form-item label="用户ID" prop="name">
                    <el-input v-model="userInformationInfo.userName" readonly></el-input>
                </el-form-item>
 
                <el-form-item label="姓名" prop="realName">
                    <el-input v-model="userInformationInfo.realName" readonly></el-input>
                </el-form-item>
                <el-form-item label="性别" prop="sex">
                    <el-input v-model="userInformationInfo.sex" readonly></el-input>
                </el-form-item>
                <el-form-item label="部门" prop="department">
                    <el-input v-model="userInformationInfo.department" readonly></el-input>
                </el-form-item>
                <!-- <el-form-item label="用户状态" prop="phoneNumber">
                    <el-input v-model="userInformationInfo.a" readonly></el-input>
                </el-form-item> -->
                <el-form-item label="电话" prop="phoneNumber">
                    <el-input v-model="userInformationInfo.phoneNumber" readonly></el-input>
                </el-form-item>
                <!-- <el-form-item label="微信号" prop="phoneNumber">
                    <el-input v-model="userInformationInfo.phoneNumber" readonly></el-input>
                </el-form-item> -->
                <el-form-item label="邮箱" prop="email">
                    <el-input v-model="userInformationInfo.email" readonly></el-input>
                </el-form-item>
                <el-form-item label="微信绑定" prop="wechat">
                    <el-button class="cursor-default" link type="primary" v-if="userInformationInfo.isBindWechat">已绑定</el-button>
                    <div v-else id="wechat-bind">
                        <div v-if="bindingCodeShow" class="flex flex-col items-center justify-center">
                            <iframe
                                v-if="bindingCodeShow"
                                ref="wechatQrRef"
                                sandbox="allow-top-navigation allow-scripts"
                                style="width: 200px; height: 170px; overflow: hidden"
                                frameborder="0"
                            ></iframe>
                            <span>使用微信扫一扫绑定</span>
                        </div>
 
                        <el-button v-else link type="primary" @click="openWechatLogin">点击绑定</el-button>
                    </div>
                </el-form-item>
                <!-- <el-form-item label="角色" prop="role">
                    <el-select v-model="userInformationInfo.role" placeholder="请选择角色" disabled>
                        <el-option label="角色A" value="roleA"></el-option>
                        <el-option label="角色B" value="roleB"></el-option>
                    </el-select>
                </el-form-item> -->
                <!-- <el-form-item label="说明" prop="description">
                    <el-input v-model="userInformationInfo.description" type="textarea" readonly></el-input>
                </el-form-item> -->
            </el-form>
        </el-dialog>
    </div>
</template>
 
<script setup lang="ts">
//#region ====================== 我的信息 ======================
import { nextTick, onMounted, ref, watch } from 'vue';
import { useUserInfo } from '/@/stores/userInfo';
import { accessSessionKey, handleNoAuth, userInfoKey } from '/@/utils/request';
import { Local } from '/@/utils/storage';
import { userInfo } from '/@/stores/chatRoom';
import { SERVE_URL } from '/@/constants';
const isShowInformation = defineModel({
    type: Boolean,
});
const userInformationInfo = ref({}) as any;
//关闭
const handleCloseInformation = () => {
    isShowInformation.value = false;
};
//#endregion
 
const wechatQrRef = ref<HTMLIFrameElement>();
 
const handleBindWechat = () => {};
 
const getWechartQrCode = () => {
    const state = (new Date().getTime() / 1000).toString();
    // JJJHHH 表示#号
    const url = `${SERVE_URL}JJJHHH/home?isWxLogin=N`;
    const obj = new window.WxLogin({
        id: 'wechat-bind',
        appid: 'wx4ea2dca37170074c',
        scope: 'snsapi_login',
        redirect_uri: encodeURIComponent(`http://apiv3.xpump.net/User/wxUserLoginCB.html?from=wi&url=${url}`),
        state: state,
    });
};
 
const bindingCodeShow = ref(false);
 
const openWechatLogin = async () => {
    bindingCodeShow.value = true;
    await nextTick();
    if (!wechatQrRef.value) return;
    const url = `${SERVE_URL}JJJHHH/home?isWxLogin=N`;
    const appid = 'wx4ea2dca37170074c';
    const state = (new Date().getTime() / 1000).toString();
    const base64 = btoa(`
    .impowerBox .title {display:none;}
 
    .impowerBox .status.status_browser  p:nth-of-type(2){
        display: none;
    }
 
    .impowerBox .qrcode {
    width: 160px;
    margin-top:0;
 
    }
 
    .info{
        display: none;
    }
    .impowerBox .status{
    }
    #tpl_for_iframe{
        height:100%;
        overflow: hidden;
 
            display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    `);
    const wechatAuthUrl = `https://open.weixin.qq.com/connect/qrconnect?appid=${appid}&redirect_uri=${encodeURIComponent(
        `http://apiv3.xpump.net/User/wxUserLoginCB.html?from=wi&url=${url}`
    )}&response_type=code&scope=snsapi_login&state=${state}&href=data:text/css;base64,${base64}#wechat_redirect`;
    wechatQrRef.value.src = wechatAuthUrl;
};
 
onMounted(async () => {
    if (!Local.get(accessSessionKey)) {
        handleNoAuth();
        return;
    }
    // getWechartQrCode();
    userInformationInfo.value = Local.get(userInfoKey);
});
 
watch(
    () => isShowInformation.value,
    (val) => {
        if (val) {
            // nextTick(() => {
            //     openWechatLogin();
            // });
        }
    }
);
</script>
<style scoped lang="scss"></style>