admin
2025-06-10 568c763084b926a6f2d632b7ac65b9ec8280752f
kp_html/kp/js/http.js
@@ -17,8 +17,8 @@
   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);
      console.log("http请求路径", path, key);
      pyjs.http_request(path, JSON.stringify(data), JSON.stringify(["http_util.http_request_result", key]));
   },
@@ -29,14 +29,14 @@
   },
   get_score_data: function(code, name,date, callback) {
   get_score_data: function(code, name, date, callback) {
      var params = {
         code: code
      }
      if (name) {
         params.name = name;
      }
      if(date){
      if (date) {
         params.date = date;
      }
      http_util.http_request("/get_score_info", params, callback);
@@ -52,18 +52,39 @@
         type: type
      }, callback);
   },
   get_blocks_in_money_info: function(type, callback) {
      http_util.http_request("/get_blocks_in_money_info", {
         type: type
      }, callback);
   },
   get_place_order_records: function(day, callback) {
      http_util.http_request("/get_place_order_records", {
         day: day
      }, callback);
   },
   get_limit_up_list: function(code, day, callback) {
      var params = {
         code: code
      };
      if(day){
      if (day) {
         params.day = day;
      }
      http_util.http_request("/kpl/get_limit_up_list", params , callback);
      http_util.http_request("/kpl/get_limit_up_list", params, callback);
   },
   get_limit_up_statistic_infos: function(day, callback) {
      var params = {};
      if (day) {
         params.day = day;
      }
      http_util.http_request("/kpl/get_limit_up_statistic_infos", params, callback);
   },
   get_plate_info: function(code, callback) {
      http_util.http_request("/kpl/get_plate_info", {
@@ -129,25 +150,37 @@
            data.type = 412;
            type_desc = "移除暂不买"
            //移除想买
            break;
            break;
         case 8:
            data.type = 441;
            data.data.plates = [plate]
            type_desc = "加绿"
            break;
         case 9:
            data.type = 442;
            type_desc = "移绿"
            break;
      }
      console.log("socket请求", data)
      console.log("参数:",data);
      pyjs.socket_request(JSON.stringify(data), function(result) {
         console.log(result);
      var sign = http_util.get_sign(data);
      data['sign'] = sign;
      console.log("参数:", data);
      http_util.socket_request(JSON.stringify(data), function(result) {
         console.log("撤单结果", result)
         result = JSON.parse(result);
         if (result.code == 0) {
            // pyjs.show_info(type_desc +"成功");
            layer.msg(type_desc + "成功")
            layer.msg(type_desc + "成功");
         }
         callback(result);
      });
   },
   get_want_codes: function(plate, callback) {
      pyjs.socket_request(JSON.stringify({
      http_util.socket_request(JSON.stringify({
         type: 403,
         plate: plate
      }), function(result) {
@@ -157,30 +190,44 @@
         }
      });
   },
   get_sign:function(data){
      var params=new Array();
      for(key in data){
            if(data[key] instanceof Object || data[key] instanceof Array){
   get_green_codes: function(callback) {
      var data = {
         type: 443
      };
      var sign = http_util.get_sign(data);
      data['sign'] = sign;
      http_util.socket_request(JSON.stringify(data), function(result) {
         console.log("结果:", result);
         result = JSON.parse(result);
         if (result.code == 0) {
            callback(result);
         }
      });
   },
   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.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+"&";
      var params_str = ""
      params.forEach(function(re) {
         params_str += re + "&";
      });
      if(params_str.endsWith("&")){
         params_str = params_str.substring(0,params_str.length - 1);
      if (params_str.endsWith("&")) {
         params_str = params_str.substring(0, params_str.length - 1);
      }
      console.log(params_str)
       md5Hash = crypto.createHash("md5").update(params_str).digest("hex");
       return md5Hash;
      md5Hash = md5(params_str);
      return md5Hash;
   },
   cancel_order: function(code, success) {
      var data = {
@@ -189,9 +236,9 @@
            "code": code
         }
      };
      http_util.socket_request(JSON.stringify(data), function(result) {
         console.log("撤单结果",result)
         console.log("撤单结果", result)
         result = JSON.parse(result);
         if (result.code == 0) {
            success()
@@ -203,120 +250,285 @@
         plate: plate
      }, callback);
   },
   delete_forbidden_plate: function(plate, callback) {
      http_util.http_request("/kpl/del_forbidden_plate", {
         plate: plate
      }, callback);
   },
   list_forbidden_plate: function(callback) {
      http_util.http_request("/kpl/list_forbidden_plate", {
      }, callback);
   },
   list_deleted_forbidden_plate :function(callback){
      http_util.http_request("/kpl/list_deleted_forbidden_plate", {
      }, callback);
   },
   // 获取板块下的代码
   get_plate_codes: function(plate, day, callback) {
      var params = {
         plate: plate
      };
      if(day){
      if (day) {
         params.day = day;
      }
      http_util.http_request("/kpl/get_plate_codes", params, callback);
   },
   get_open_limit_up_count_rank(code,callback){
      var params={}
      if(code){
   },
   get_plate_codes_new: function(plate, day, callback) {
      var params = {
         plate: plate
      };
      if (day) {
         params.day = day;
      }
      http_util.http_request("/kpl/get_plate_codes_new", params, callback);
   },
   get_open_limit_up_count_rank(code, callback) {
      var params = {}
      if (code) {
         params.code = code;
      }
      http_util.http_request("/kpl/get_open_limit_up_count_rank", params, callback);
   },
   get_h_cancel_data:function(code,callback){
       http_util.http_request("/get_h_cancel_data", {
          code: code
       }, 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);
   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);
   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, date,callback){
      var params={code:code}
      if(date){
   get_l2_datas: function(code, date, end_index, callback) {
      var params = {
         code: code
      }
      if (date) {
         params['date'] = date
      }
      console.log("L2参数",params);
       http_util.http_request("/get_l2_datas", params, callback);
      if (end_index != null && end_index) {
         params['end_index'] = parseInt(end_index)
      }
      console.log("L2参数", params);
      http_util.http_request("/get_l2_datas", params, callback);
   },
   //获取L2的数据
   get_trade_progress:function(code,callback){
       http_util.http_request("/get_trade_progress", {code:code
       }, callback);
   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,date,callback){
      var params={code:code}
      if(buy_single_index>=0){
   get_l2_l_cancel_datas: function(code, buy_single_index, date, callback) {
      var params = {
         code: code
      }
      if (buy_single_index >= 0) {
         params["buy_single_index"] = buy_single_index;
      }
      if(date){
      if (date) {
         params.date = date;
      }
       http_util.http_request("/get_l_cancel_datas", params, callback);
      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){
   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);
      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_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:''}
   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) {
         console.log(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);
   },
   set_real_place_order_index: function(code, index, callback) {
      data = {
         type: "common",
         data: {
            ctype: "set_real_place_order_index",
            code: code,
            index: index
         },
         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);
   },
   set_real_place_order_index:function(code, index, callback){
      data = {type:"common", data: {ctype:"set_real_place_order_index",code:code,index:index},sign:''}
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   get_l2_cant_buy_reasons:function(code, callback){
      var params={code:code}
      console.log("参数",params)
   get_l2_cant_buy_reasons: function(code, callback) {
      var params = {
         code: code
      }
      console.log("参数", params)
      http_util.http_request("/get_l2_cant_buy_reasons", params, callback);
   },
   get_latest_cancel_orders:function(callback){
      var params={type:"get_latest_cancel_orders",data:{},sign:''}
   get_latest_cancel_orders: function(callback) {
      var params = {
         type: "get_latest_cancel_orders",
         data: {},
         sign: ''
      }
      http_util.socket_request(JSON.stringify(params), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   get_kpl_market_feelings:function(callback){
      var params={}
       http_util.http_request("/get_kpl_market_feelings", params, callback);
   get_kpl_market_feelings: function(callback) {
      var params = {}
      http_util.http_request("/get_kpl_market_feelings", params, callback);
   },
   get_cb_list(callback) {
      var params = {}
      http_util.http_request("/get_cb_list", params, callback);
   },
   get_new_blocks(callback) {
      var params = {}
      http_util.http_request("/get_new_blocks", params, callback);
   },
   buy_by_ths(code, callback) {
      var params = {
         "code": code
      }
      http_util.http_request("/buy_by_ths", params, callback);
   },
   statistic_latest_limit_up_block(code, callback) {
      var params = {
         "code": code
      }
      http_util.http_request("/statistic_latest_limit_up_block", params, callback);
   },
   // 获取距离给定时间最近的开盘啦涨停数据
   get_kpl_latest_limit_up_queue_by_time(time, callback) {
      var params = {
         "time": time,
      }
      http_util.http_request("/kpl/get_latest_limit_up_queue", params, callback);
   },
   get_account_commission_detail(callback) {
      http_util.http_request("/get_account_commission_detail", {}, callback);
   },
   get_code_third_blocks: function(code, callback) {
      var params = {
         type: "common",
         data: {
            ctype: "get_code_third_blocks",
            code: code
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(params), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   
   get_block_codes_with_money: function(block,desc, callback) {
      http_util.http_request("/get_block_codes_with_money", {
         block: block,
         desc:desc
      }, callback);
   },
   // 获取所有L2订阅的列表
   get_l2_subscript_codes: function(callback) {
      var params = {
         type: "get_huaxin_subscript_codes",
         data: {},
         sign: ''
      }
      http_util.socket_request(JSON.stringify(params), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   
   get_big_order_deal_info:function(code, callback){
      http_util.http_request("/get_l2_subscript_codes", {
         code: code
      }, callback);
   },
   
   get_all_special_codes:function(callback){
      http_util.http_request("/get_all_special_codes", {
      }, callback);
   },
   get_new_blocks_special_codes:function(callback){
      http_util.http_request("/get_new_blocks_special_codes", {
      }, callback);
   },
   // 设置累计成交大单的阈值
   set_total_deal_big_order_threshold_money: function(code, money, callback) {
      var params = {
         type: "common",
         data: {
            ctype: "set_total_deal_big_order_threshold_money",
            code: code,
            money:money
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(params), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   
};