admin
2024-01-11 5a2ef3a696ddccbc1faef1e2e90f5b535ec24a0d
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
var http_util = {
    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.request_callback[key](data);
        delete http_util.request_callback[key];
    },
    http_request: function(path, data, callback) {
        key = "http_callback_" + new Date().getTime() + "_" + Math.round(Math.random() * 100000000);
        http_util.request_callback[key] = callback;
        
        console.log("http请求路径", path,key);
 
        pyjs.http_request(path, JSON.stringify(data), JSON.stringify(["http_util.http_request_result", key]));
    },
    socket_request: function(data, callback) {
        key = "http_callback_" + new Date().getTime() + "_" + Math.round(Math.random() * 100000000);
        http_util.request_callback[key] = callback;
        pyjs.socket_request(data, JSON.stringify(["http_util.http_request_result", key]));
    },
 
 
    get_score_data: function(code, name, callback) {
        params = {
            code: code
        }
        if (name) {
            params.name = name;
        }
        http_util.http_request("/get_score_info", params, callback);
    },
 
    get_kpl_data: function(callback) {
        http_util.http_request("/get_kpl_data", {}, callback);
    },
 
 
    get_market_data: function(type, callback) {
        http_util.http_request("/kpl/get_market_data", {
            type: type
        }, callback);
    },
 
    get_limit_up_list: function(code, callback) {
        http_util.http_request("/kpl/get_limit_up_list", {
            code: code
        }, callback);
    },
 
    get_plate_info: function(code, callback) {
        http_util.http_request("/kpl/get_plate_info", {
            code: code
        }, callback);
    },
 
    add_ignore_code: function(type, code, callback) {
        http_util.http_request("/kpl/add_ignore_code", {
            code: code,
            type: type
        }, callback);
 
    },
 
    do_action_for_code: function(code, plate, type, callback) {
        var data = {
            "data": {
                "codes": [code]
            }
        };
        var type_desc = "";
        switch (type) {
            case 0:
                //加入黑名单
                data.type = 201;
                type_desc = "加入黑名单"
                break;
                //移除黑名单
            case 1:
                data.type = 203;
                type_desc = "移除黑名单"
                break;
            case 2:
                //加自选
                data.type = 601;
                type_desc = "加自选"
                break;
            case 3:
                //移除自选
                data.type = 602;
                type_desc = "移除自选"
 
                break;
            case 4:
                data.type = 401;
                data.data.plates = [plate]
                type_desc = "加想买"
                //加想买
                break;
            case 5:
                data.type = 402;
                type_desc = "移除想买"
                //移除想买
                break;
            case 6:
                data.type = 411;
                data.data.plates = [plate]
                type_desc = "加暂不买"
                //加想买
                break;
            case 7:
                data.type = 412;
                type_desc = "移除暂不买"
                //移除想买
                break;    
        }
 
        console.log("socket请求", data)
 
        pyjs.socket_request(JSON.stringify(data), function(result) {
            result = JSON.parse(result);
            if (result.code == 0) {
                // pyjs.show_info(type_desc +"成功");
                layer.msg(type_desc + "成功")
            }
            callback(result);
        });
    },
 
    get_want_codes: function(plate, callback) {
        pyjs.socket_request(JSON.stringify({
            type: 403,
            plate: plate
        }), function(result) {
            result = JSON.parse(result);
            if (result.code == 0) {
                callback(result);
            }
        });
    },
 
    cancel_order: function(code, success) {
        var data = {
            "type": 80,
            "data": {
                "code": code
            }
        };
        pyjs.socket_request(JSON.stringify(data), function(result) {
            result = JSON.parse(result);
            if (result.code == 0) {
                success()
            }
        });
    },
    forbidden_plate: function(plate, callback) {
        http_util.http_request("/kpl/forbidden_plate", {
            plate: plate
        }, callback);
    },
    // 获取板块下的代码
    get_plate_codes: function(plate, callback) {
        http_util.http_request("/kpl/get_plate_codes", {
            plate: plate
        }, callback);
    },    
    get_h_cancel_data:function(code,callback){
        http_util.http_request("/get_h_cancel_data", {
            code: code
        }, callback);
    },
    // 获取消息列表
    list_msg:function(callback){
        http_util.http_request("/list_kp_client_msg", {
        }, callback);
    },
    //上个交易日相同涨停原因的代码列表
    get_last_trade_day_reasons:function(code,callback){
        http_util.http_request("/get_last_trade_day_reasons", {code:code
        }, callback);
    },
    
    //获取L2的数据
    get_l2_datas:function(code,callback){
        http_util.http_request("/get_l2_datas", {code:code
        }, callback);
    },
    //获取L2的数据
    get_trade_progress:function(code,callback){
        http_util.http_request("/get_trade_progress", {code:code
        }, callback);
    },
    //获取L2的数据
    get_l2_l_cancel_datas:function(code,buy_single_index,callback){
        var params={code:code}
        if(buy_single_index>=0){
            params["buy_single_index"] = buy_single_index;
        }
        http_util.http_request("/get_l_cancel_datas", params, callback);
    },
    get_l2_h_cancel_datas:function(code,buy_single_index,callback){
        var params={code:code}
        if(buy_single_index>=0){
            params["buy_single_index"] = buy_single_index;
        }
        http_util.http_request("/get_h_cancel_datas", params, callback);
    },
    get_kpl_block_info:function(code,callback){
        var params={code:code}
        http_util.http_request("/get_kpl_block_info", params, callback);
    },
    // 获取已挂买单的信息
    get_delegated_buy_code_infos:function(callback){
        data = {type:"common", data: {ctype:"get_delegated_buy_code_infos"},sign:''}
        http_util.socket_request(JSON.stringify(data), function(result) {
            result = JSON.parse(result);
            callback(result);
        });
    },
    get_xgb_limit_up_reasons:function(code,callback){
        var params={code:code}
        http_util.http_request("/get_xgb_limit_up_reasons", params, callback);
    },
    
    
     
};