liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
<!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" />
        <link href="css/mui.min.css"   rel="stylesheet" />
    </head>
 
    <body>
        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> 
        <script src="js/mui.min.js"  ></script>
        <script type="text/javascript" src="js/common.js"  ></script>
        <script type="text/javascript">
            var code = getUrlParam("code");
        mui.ajax({
            type: "get",
            url: serverUrl + 'login/getwxuserinfo.json',
            data: {
                CODE: code
            },
            async: false,
            success: function(data) {
                console.log(" data  " + data.UserId  );
                if(data.errcode == undefined) {
                    sessionCache.setSessionCashe("weixin_user", data, sessionCache.json_value);
                } else {
                    WeixinJSBridge.call('closeWindow');
                }
            }
        });
            var openObj = sessionCache.getSessionCashe("weixin_user", sessionCache.json_value);
            var openId;
            if(openObj.UserId != undefined) {
                openId = openObj.UserId;
            } else if(openObj.OpenId != undefined) {
                openId = openObj.OpenId;
            }
 
            mui.init()
            mui.ajax(serverUrl + '/login/loginOutForWeChat.json',{
                data:{
                    openId: openId
                },
                dataType:'json',//服务器返回json格式数据
                type:'get',//HTTP请求类型
                async: false,
                success:function(data){
                    window.localStorage.clear();
                     
                    if(!openId){
                        openId = data.UserId;
                    }
                    sessionCache.setSessionCashe("weixin_user",openObj, sessionCache.json_value);
                     
                    location.href="http://tm.fschool365.cn/safety/login.html";
                },
                error:function(xhr,type,errorThrown){
                    alert(errorThrown);
                }
            });
        </script>
    </body>
 
</html>