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]));
|
},
|
|
|
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);
|
},
|
|
};
|