tom
2023-12-06 9e968679ed2e6937aeb7b50a6c450d5d19251f42
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
206
207
208
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>个人中心</title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <script src="../../js/vue/axios/dist/axios.min.js"></script> 
        <link href="./login.css?v=20230117" rel="stylesheet">
    </head>
    <body>
        <div style="height: 100vh;">
            <div id="my_page" style="height: 25%; position: relative; margin-top: 10px; border-bottom: 2px solid #F7F7F7;">
                <div style="position: absolute; height: 100%; left: 0; width: 40%; padding: 5%;box-sizing: border-box;">
                    <img src="../system/img/OK1.png" style="width: 100%; border-radius: 50%; margin: 0 auto; border: 1px solid #aa65aa;"/>
                </div>
                <div style="position: absolute; height: 100%; line-height: 100%; right: 0; width: 70%;">
                    <div style="padding: 50px; box-sizing: border-box; bottom: 15px;">
                        <span id="emp_code"></span>
                        <br />
                        <br />
                        <span id="remark"></span>
                    </div>
                </div>
            </div>
            <div id="login_box3" class="login_box" >
                <div class="row" style="color: #c6e9ff;">
                    <span id="back_jc"></span>
                </div>
            </div>
            
            <div id="h_btn">
                <div id="bind_btn0" class="h_btn0" onclick="showlogin()" style="">去登录</div>
                <div id="bind_btn2" class="h_btn0" onclick="unbind_btn()" style="">登 出</div>
                <br />
                <div id="back3" class="row" style="margin-top: 10px; color: #ff3831;"></div>
            </div>
            
            
            <div id="page" class="page" style="display: none">
                <div class="title">济民可信电子商务平台</div>
                <div id="login_box1" class="login_box">
                    <div class="row">
                        <input id="empCode" class="input" placeholder="商业账号"/>
                    </div>
                    <div class="row" style="margin-top: 10px;">
                        <input id="password" type="password" class="input" placeholder="密码"/>
                    </div>
                    <div class="row" style="margin-top: 10px; color: #c6e9ff;">
                         <span id="close_s"></span>
                    </div>
                    <div id="back1" class="row" style="margin-top: 10px; color: #ff3831;"></div>
                </div>
                
                <div class="bind_div">
                    <div id="bind_btn1" class="bind_btn" onclick="bind_btn()">登 录</div>
                </div>
            </div>
        </div>
        
        
        
    </body>
</html>
 
<script>
    var openId;
    var empCode;
    var baseUrl = "https://ec.jemincare.com/worder/";
    var code = this.getQueryVariable("code");
    var instance = axios.create({
      baseURL: baseUrl,
      timeout: 10000,
      headers: {'Content-Type': 'text/plain'}
    });
    
    //检测是否绑定
    function check_bind() {
        var param = {
            code: code,
        }
        
        instance.post("api/getWxOpenId", param)
            .then(data_ => {
                console.info("success:" + JSON.stringify(data_));
                
                if(data_.data.success) {
                    openId = data_.data.data.openId;
                    if(data_.data.data.emp_code) {
                        document.getElementById("login_box3").style.display = "none";
                        document.getElementById("bind_btn2").style.display = "block";
                        
                        document.getElementById('emp_code').innerText = data_.data.data.emp_code;
                        document.getElementById('remark').innerText = data_.data.data.remark;
                        empCode = data_.data.data.emp_code;
                    }else {
                        document.getElementById('remark').innerText = "未登录";
                        document.getElementById("login_box3").style.display = "none";
                        document.getElementById("bind_btn0").style.display = "block";
                    }
                }else {
                    document.getElementById("back3").innerText = data_.data.message;
                }
            })
            .catch(error => {
                console.info("error:" + error);
                document.getElementById("back_jc").style.display = "none";
                document.getElementById("back3").innerText = error;
            })
    }
    
    function showlogin() {
        document.getElementById("h_btn").style.display = "none";
        document.getElementById("my_page").style.display = "none";
        document.getElementById("page").style.display = "block";
    }
    
    //解绑
    function unbind_btn() {
        var param = {
            openId: openId,
            empCode: empCode,
        }
        instance.post("api/unBindOpenId", param)
            .then(data_ => {
                // document.getElementById("dialog").style.display = "none";
                // document.getElementById("back").style.display = "block";
                if(!data_.data.success) {
                    document.getElementById("back3").innerText = data_.data.message;
                }
                else {
                    weixinClosePage();
                }
            })
            .catch(error => {
                document.getElementById("back3").innerText = error;
            })
    }
    
    //登录绑定
    function bind_btn() {
        var param = {
            code: code,
            openId: openId,
            empCode: document.getElementById("empCode").value,
            passWord: document.getElementById("password").value
        }
        instance.post("api/bindOpenId", param)
            .then(data_ => {
                if(!data_.data.success) {
                    document.getElementById("back1").innerText = data_.data.message;
                }
                else {
                    document.getElementById("back1").innerText = "登录成功";
                    // doCloseWinPage(5);
                    alert("登录成功")
                    weixinClosePage();
                }
            })
            .catch(error => {
                console.info("error:" + error);
                document.getElementById("back1").innerText = error;
            })
 
    }
    
    function getQueryVariable(variable) {
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
    }
 
    function doCloseWinPage(close_s) {
      setTimeout(function(){
        if (close_s == 0) {
          weixinClosePage();
        }
        else if (close_s > 0){
            close_s--;
            document.getElementById("close_s").innerText = close_s;
            doCloseWinPage(close_s);
        }
      },1000);
    }
    
    // 兼容所有浏览器关闭页面方法
    function weixinClosePage() {
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', weixin_ClosePage, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', weixin_ClosePage);
                document.attachEvent('onWeixinJSBridgeReady', weixin_ClosePage);
            }
        } else {
            weixin_ClosePage();
        }
    }
    function weixin_ClosePage() {
        WeixinJSBridge.call('closeWindow');
    }
    // document.addEventListener("DOMContentLoaded", initPage);
    
    check_bind();
</script>