admin
2025-06-30 cd3eccb32719bb5409ec62f4e201b85992df2d33
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
var http_util_of_ls = {
    request_callback: {},
    getQueryString: function(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(decodeURI(r[2]));
        }
        return null;
    },
    http_request_result: function(key, data) {
        data = atob(data);
        console.log("http请求回调", "key:" + key);
        http_util_of_ls.request_callback[key](data);
        delete http_util_of_ls.request_callback[key];
    },
    http_request: function(path, data, callback) {
        key = "http_callback_" + new Date().getTime() + "_" + Math.round(Math.random() * 100000000);
        http_util_of_ls.request_callback[key] = callback;
 
        console.log("http请求路径", path, key);
 
        pyjs.http_request(path, JSON.stringify(data), JSON.stringify(["http_util_of_ls.http_request_result",
            key]));
    },
    socket_request: function(data, callback) {
        key = "http_callback_" + new Date().getTime() + "_" + Math.round(Math.random() * 100000000);
        http_util_of_ls.request_callback[key] = callback;
        pyjs.ls_socket_request(data, JSON.stringify(["http_util_of_ls.http_request_result", key]));
    },
 
    get_sign: function(data) {
        var params = new Array();
        for (key in data) {
            if (data[key] instanceof Object || data[key] instanceof Array) {
                console.log(typeof data[key])
                params.push(key + "=" + JSON.stringify(data[key]))
            } else {
                params.push(key + "=" + data[key])
            }
        }
        params.sort()
        params.push("%Yeshi2014@#.")
        var params_str = ""
        params.forEach(function(re) {
            params_str += re + "&";
        });
        if (params_str.endsWith("&")) {
            params_str = params_str.substring(0, params_str.length - 1);
        }
 
        console.log(params_str)
 
        md5Hash = md5(params_str);
        return md5Hash;
    },
 
    http_test: function(code, buy_single_index, callback) {
        var params = {
            code: code
        }
        if (buy_single_index >= 0) {
            params["buy_single_index"] = buy_single_index;
        }
        http_util_of_ls.http_request("/get_h_cancel_datas", params, callback);
    },
    // 设置累计成交大单的阈值 
    get_settings: function(callback) {
        var params = {
            type: "common",
            data: {
                ctype: "get_settings"
            },
            sign: ''
        }
        http_util_of_ls.socket_request(JSON.stringify(params), function(result) {
            result = JSON.parse(result);
            callback(result);
        });
    },
    set_settings: function(data_params, callback) {
        let data = {
            ctype: "set_settings"
        };
        for(key in data_params){
            data[key] = data_params[key];
        }
        var params = {
            type: "common",
            data: data,
            sign: ''
        }
        http_util_of_ls.socket_request(JSON.stringify(params), function(result) {
            result = JSON.parse(result);
            callback(result);
        });
    },
    get_plate_white_list: function(callback) {
        let data = {
            ctype: "plate_white_list",
            operate: 3
        };
        var params = {
            type: "common",
            data: data,
            sign: ''
        }
        http_util_of_ls.socket_request(JSON.stringify(params), function(result) {
            result = JSON.parse(result);
            callback(result);
        });
    },
    
    delete_plate_white_list: function(plate,callback) {
        let data = {
            ctype: "plate_white_list",
            operate: 2,
            plate: plate
        };
        var params = {
            type: "common",
            data: data,
            sign: ''
        }
        http_util_of_ls.socket_request(JSON.stringify(params), function(result) {
            result = JSON.parse(result);
            callback(result);
        });
    },
    add_plate_white_list: function(plate,callback) {
        let data = {
            ctype: "plate_white_list",
            operate: 4,
            plate: plate
        };
        var params = {
            type: "common",
            data: data,
            sign: ''
        }
        http_util_of_ls.socket_request(JSON.stringify(params), function(result) {
            result = JSON.parse(result);
            callback(result);
        });
    },
    
    get_place_order_records:function(callback){
        let data = {
            ctype: "get_place_order_records"
        };
        var params = {
            type: "common",
            data: data,
            sign: ''
        }
        http_util_of_ls.socket_request(JSON.stringify(params), function(result) {
            result = JSON.parse(result);
            callback(result);
        });
    }
    
};