qin
2024-04-01 d1a50163e4d445bc8451cf68cf0791caf7c410e0
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
 
function ajaxRequest(opt) {
    let m_token = localStorage.Token;
    //console.log(m_token,opt,4)
    let defaults = {
        type: 'get',
        headers: {},
        data: {},
        dataType: 'json',
        async: true,
        cache: true,
        beforeSend: null,
        success: null,
        error: null,
        complate: null,
        contentType: 'application/x-www-form-urlencoded',
        processData: true,
    }
    let o = $.extend({}, defaults, opt)
 
    $.ajax({
        type: o.type,
        contentType: o.contentType,
        processData: o.processData,
        dataType: o.dataType,
        url: o.url,
        async: o.async,
        cache: o.cache,
        data: o.data,
        beforeSend: function (request) {
            if (m_token) {
                request.setRequestHeader("Authorization", m_token);
            }
        },
        success: function (result) {
            o.success && o.success(result)
        },
        error: function (textStatus, errorThrown) {
            o.error && o.error(textStatus, errorThrown)
        }
    });
}
 
// 注销账户 并清除cookie和localStorage
function logout() {
 
    localStorage.isAuto = false;
    localStorage.removeItem('EmployeeID');
    localStorage.removeItem('DefaultStationID');
    localStorage.removeItem('Token');
    localStorage.removeItem('tokentime');
    localStorage.removeItem('CreateUserID');
    $.cookie(GlobalParas.CookieName.EmployeeID, "", { path: '/' });
    $.cookie(GlobalParas.CookieName.UserID, "", { path: '/' });
    $.cookie(GlobalParas.CookieName.CorpID, "", { path: '/' });
    $.cookie(GlobalParas.CookieName.RealName, "", { path: '/' });
    $.cookie(GlobalParas.CookieName.Token, "", { path: '/' });
    $.cookie(GlobalParas.CookieName.CreateUserID, "", { path: '/' });
    $.cookie('tokentime', "", { path: '/' });
 
    window.location.replace("/Login/index");
}
 
function logintest() {
 
    let postData = { SoftType: "BS", SoftTag: "SHI", LoginName: 'smiadmin', LoginPwd: 'admin', CorpID: 5 };
 
 
    $.ajax({
        type: 'post',
        //dataType: 'json',
        contentType: 'application/json',
        cache: false,
        url: 'http://101.133.133.173:9019/User/UserLogin/FromCorpStandard@V1.0',
        data: JSON.stringify(postData),
        success: function (result) {
 
            console.log(result, 114);
            if (result.Code != 0) {
                $("#password").html("");
                $("#password").focus();
                $("#js-server-helpinfo").html(result.Message);
                return;
            }
            var resp = result.Data;
 
            if (resp.Status == -1) {
                layer.alert("账户不存在!");
                return;
            }
            if (resp.Status == -2) {
                layer.alert("密码错误!");
                return;
            }
            if (resp.Status == -3 || resp.Status == -4 || resp.Status == -5) {
                layer.alert("您的账号已无法登录!");
                return;
            }
            if (resp.Status == -99) {
                layer.alert("登录失败!");
                return;
            }
            //
            var userInfo = resp.User;
            let token = ''
            if (resp.Token) {
                token = ' Bearer ' + resp.Token
                localStorage.tokentime = new Date().getTime();
            }
 
            localStorage.Token = token;
 
        },
        error: function (xhr, type, exception) {
            $("#js-server-helpinfo").html("发生系统错误,请与系统管理员联系!");
        }
    });
}