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){
|
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;
|
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;
|
}
|
|
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()
|
}
|
});
|
}
|
|
|
|
};
|