admin
2025-07-25 f5e8c9ecc4b1980e215dcf940aba004a8d6ab353
kp_html/kp/js/http.js
@@ -1,3 +1,16 @@
function is_trade_time() {
      var nowdate = new Date();
      h = nowdate.getHours();
      m = nowdate.getMinutes();
      total_m = h * 60 + m;
      if ((total_m >= (9 * 60 + 25) && total_m <= (11 * 60 + 30)) || (total_m >= 13 * 60 && total_m <= 15 *
            60)) {
         return true;
      } else {
         return false;
      }
}
var http_util = {
   request_callback: {},
   getQueryString: function(name) {
@@ -229,6 +242,7 @@
      md5Hash = md5(params_str);
      return md5Hash;
   },
   // 撤单
   cancel_order: function(code, success) {
      var data = {
         type: "cancel_order",
@@ -245,6 +259,22 @@
         }
      });
   },
   // 同步交易数据
   sync_trade_data: function(type, success) {
      var data = {
         type: "sync_trade_data",
         data: {
            "type": type
         }
      };
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         success(result);
      });
   },
   forbidden_plate: function(plate, callback) {
      http_util.http_request("/kpl/forbidden_plate", {
         plate: plate
@@ -256,12 +286,10 @@
      }, callback);
   },
   list_forbidden_plate: function(callback) {
      http_util.http_request("/kpl/list_forbidden_plate", {
      }, 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);
      http_util.http_request("/kpl/list_deleted_forbidden_plate", {}, callback);
   },
   // 获取板块下的代码
   get_plate_codes: function(plate, day, callback) {
@@ -310,9 +338,10 @@
   },
   //获取L2的数据
   get_l2_datas: function(code, date, end_index, callback) {
   get_l2_datas: function(code, date, end_index, fast_mode, callback) {
      var params = {
         code: code
         code: code,
         fast: fast_mode
      }
      if (date) {
         params['date'] = date
@@ -366,12 +395,11 @@
      data = {
         type: "common",
         data: {
            ctype: "get_delegated_buy_code_infos"
            ctype: "get_delegated_buy_code_infos_v2"
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(data), function(result) {
         console.log(result);
         result = JSON.parse(result);
         callback(result);
      });
@@ -478,15 +506,16 @@
   },
   // 获取所有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);
      });
      // var params = {
      //    type: "get_huaxin_subscript_codes",
      //    data: {},
      //    sign: ''
      // }
      // http_util.socket_request(JSON.stringify(params), function(result) {
      //    result = JSON.parse(result);
      //    callback(result);
      // });
      http_util.http_request("/get_l2_subscript_codes", {}, callback);
   },
   
   get_big_order_deal_info:function(code, callback){
@@ -496,12 +525,10 @@
   },
   
   get_all_special_codes:function(callback){
      http_util.http_request("/get_all_special_codes", {
      }, 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);
      http_util.http_request("/get_new_blocks_special_codes", {}, callback);
   },
   // 设置累计成交大单的阈值 
   set_total_deal_big_order_threshold_money: function(code, money, callback) {
@@ -520,7 +547,54 @@
      });
   },
   
   // 设置L后撤单比例
   set_l_down_rate: function(code, rate, callback) {
      let data = {
         type: "common",
         data: {
            ctype: "set_l_down_rate",
            code: code,
            rate: rate
         },
         sign: ''
      }
      console.log("请求元数据:", data)
      console.log("请求json数据:", JSON.stringify(data))
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
    // 获取委托队列
   get_trade_queue: function(code, callback) {
      let data = {
         type: "common",
         data: {
            ctype: "get_trade_queue",
            code: code
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },
   // 获取已成交的大单
   get_deal_big_money_list: function(code, callback) {
      let data = {
         type: "common",
         data: {
            ctype: "get_deal_big_money_list",
            code: code
         },
         sign: ''
      }
      http_util.socket_request(JSON.stringify(data), function(result) {
         result = JSON.parse(result);
         callback(result);
      });
   },