admin
2024-12-16 ec012b7d2b915db24cd8b23f723bf18dfe75b7d6
kp_html/kp/js/page.js
@@ -14,14 +14,14 @@
$(function() {
   function _resize() {
      var code_info_height = 440
      var code_info_height = 440;
      console.log("总高", $(window).height())
      var bottom_height = $(window).height() - code_info_height - 140;
      console.log("底部高", bottom_height)
      $("#body>div:nth-child(3)>div").css("height", code_info_height).css("max-height", code_info_height);
      $("#body>div:nth-child(4)").css("height", bottom_height)
      $("#body>div:nth-child(4)>div:nth-child(2)").css("height", bottom_height - 10)
      $("#body>div:nth-child(4)>div:nth-child(3)").css("height", bottom_height - 60)
      $("#body>div:nth-child(4)>div").css("height", code_info_height).css("max-height", code_info_height);
      $("#body>div:nth-child(5)").css("height", bottom_height)
      $("#body>div:nth-child(5)>div:nth-child(3)").css("height", bottom_height - 10)
      $("#body>div:nth-child(5)>div:nth-child(4)").css("height", bottom_height - 60)
      $(".outer-container").css("height", bottom_height - 180)
   }
   //针对窗口高度做调整
@@ -64,13 +64,14 @@
      //非交易时间不刷新
      if (is_trade_time()) {
         app.get_limit_up_list(app.code, true);
         app.get_limit_up_statistic_infos(true);
      }
   }, 3000, 3000);
   setInterval(function() {
      if (is_trade_time()) {
         app.get_industry_data(app.industry_data_type);
         app.get_jingxuan_data(app.jingxuan_data_type);
         app.get_block_in_money_data(app.in_money_type);
      }
   }, 3000, 10000);
@@ -83,9 +84,13 @@
   
   setInterval(function() {
      if (is_trade_time()) {
         app.get_cb_list();
         app.get_l2_subscript_codes();
      }
   }, 3000, 3000);
@@ -368,7 +373,8 @@
                     ["板块", "2020-01-01"],
                     ["板块", "2020-01-01"]
                  ],
                  blocks: ["板块1", "板块2"]
                  blocks: ["板块1", "板块2"],
               }]
            },
@@ -378,14 +384,22 @@
               first: '',
               second: ''
            },
            industry_data_type: -1,
            jingxuan_data_type: 0,
            // 选股宝涨停原因
            xgb_limit_up_reasons: null,
            in_money_type: 4,
            // 三方代码板块
            code_third_blocks: null,
            // 市场情绪
            market_feeling_info: {},
            // 板块轮动
            latest_limit_up_blocks:[]
            latest_limit_up_blocks:[],
            new_blocks:"",// 新增的概念
            latest_limit_up_datas:[],
            green_list:[], // 绿名单
            limit_up_reason_statistic_new:[],
            place_order_record_list:[], // 下单记录
            block_codes_in:[],
            block_codes_out:[],
            l2_subscript_codes:[],
            want_list:[]
         },
         watch: {
            want_codes: function() {
@@ -410,39 +424,39 @@
               key = $("#limit_up_search_key").val();
               app.limit_up_search_key = key;
            },
            //获取行业数据
            get_industry_data: function(type) {
               if (type < 0) {
                  return;
               }
               app.industry_data_type = type;
               app.jingxuan_data_type = -1;
               http_util.get_market_data(app.industry_data_type, function(result) {
                  result = JSON.parse(result);
                  if (result.code == 0) {
                     app.jingxuan_datas = result.data;
                  }
               });
            select_in_money_type:function(type){
               app.in_money_type = type;
               app.get_block_in_money_data(type);
            },
            get_jingxuan_data: function(type) {
               if (type < 0) {
                  return;
               }
               app.jingxuan_data_type = type;
               app.industry_data_type = -1;
               if (type == 0) {
                  type = 2;
               } else {
                  type = 3;
               }
               http_util.get_market_data(type, function(result) {
                  result = JSON.parse(result);
                  if (result.code == 0) {
                     app.jingxuan_datas = result.data;
            get_block_in_money_data: function(type) {
               switch(type){
                  case 0:
                  case 1:
                  case 2:
                  case 3:{
                     http_util.get_market_data(type, function(result) {
                        result = JSON.parse(result);
                        if (result.code == 0) {
                           app.jingxuan_datas = result.data;
                        }
                     });
                  }
               });
                  break;
                  case 4:
                  case 5:
                  {
                     http_util.get_blocks_in_money_info(type%2, function(result) {
                        result = JSON.parse(result);
                        if (result.code == 0) {
                           app.jingxuan_datas = result.data;
                        }
                     });
                  }
                  break;
               }
            },
            get_score_data: function(code, name, callback) {
               console.log("获取分数数据:", code, name);
               var date=$("#date").val();
@@ -534,10 +548,32 @@
                  }
               });
            },
            get_limit_up_statistic_infos: function(is_auto_refresh) {
               day = $("#date").val();
               http_util.get_limit_up_statistic_infos(day, function(res) {
                  res = JSON.parse(res)
                  console.log("get_limit_up_statistic_infos", res);
                  if (res.code == 0) {
                     var temps = new Array();
                     var current_limit_up_reason =null;
                     res.data.limit_up_reason_statistic.forEach(function(d) {
                        if (app.code_third_blocks&&app.code_third_blocks.match_blocks&&app.code_third_blocks.match_blocks[0].includes(d[0])) {
                           current_limit_up_reason = d;
                        } else {
                           temps.push(d);
                        }
                     });
                     if (current_limit_up_reason) {
                        temps.unshift(current_limit_up_reason);
                     }
                     app.limit_up_reason_statistic_new = temps;
                  }
               });
            },
            get_plate_info: function(code, is_auto_refresh) {
               http_util.get_plate_info(code, function(res) {
                  res = JSON.parse(res)
                  console.log(res)
                  console.log("get_plate_info", res)
                  if (res.code == 0) {
                     app.choose_code_info = res.data
                     if (!is_auto_refresh) {
@@ -587,8 +623,23 @@
                     .limit_up_codes[index][1]);
                  app.get_plate_info(app.first_info.limit_up_codes[index][0]);
                  app.get_last_trade_day_reasons(app.first_info.limit_up_codes[index][0]);
                  app.get_code_third_blocks(app.code);
               }
            },
            get_code_third_blocks:function(code){
               http_util.get_code_third_blocks(app.code, function(res) {
                  console.log("三方板块请求结果:",JSON.stringify(res.data));
                  if (res.code == 0) {
                     app.code_third_blocks = res.data;
                     console.log(res.data)
                  } else {
                     app.code_third_blocks = null;
                  }
               });
            },
            //删除1级代码
            del_code_level_1: function(index) {
               http_util.add_ignore_code(1, app.first_info.limit_up_codes[index][0], function(
@@ -668,19 +719,11 @@
               app.code_name = code;
               app.first_info.limit_up_codes.forEach(function(e) {
                  if (e[0] == code) {
                     app.code_name = e[1] + " " + e[0];
                     app.code_name = e[0] + "(" + e[1] +
                        ")";
                  }
               });
               http_util.get_xgb_limit_up_reasons(code, function(res) {
                  console.log("选股宝请求结果:", res);
                  res = JSON.parse(res)
                  if (res.code == 0) {
                     app.xgb_limit_up_reasons = res.data;
                     console.log(app.xgb_limit_up_reasons.reasons)
                  } else {
                     app.xgb_limit_up_reasons = null;
                  }
               });
               app.get_code_third_blocks(code);
               //请求板块
               setTimeout(function() {
@@ -757,6 +800,22 @@
               });
            },
            show_want_codes_new: function(plate) {
               if (Date.now() - app.last_show_dialog < 500) {
                  return;
               }
               app.last_show_dialog = Date.now()
                var day = $("#date").val();
               http_util.get_plate_codes_new(plate,day, function(result) {
                  result = JSON.parse(result);
                  console.log("涨停原因成分股返回:", result);
                  var datas = result.data;
                  app.want_codes_title = plate;
                  app.want_codes = datas;
                  console.log("涨停原因成分股:", datas)
               });
            },
            delete_from_want_codes: function(index) {
               http_util.do_action_for_code(app.want_codes[index][0], "", 5,
@@ -842,7 +901,7 @@
                  }
               });
            },
             add_or_remove_forbidden:function(event,code){
             add_or_remove_forbidden:function(event, code, index){
               
               var el = event.currentTarget;
               var checked = $(el).is(':checked');
@@ -850,53 +909,48 @@
               if(checked){
                  http_util.do_action_for_code(code,'',0,function(res){
                     
                     app.want_codes[index][9] = 1;
                  });
               }else{
                  http_util.do_action_for_code(code,'',1,function(res){
                     app.want_codes[index][9] = 0;
                  });
               }
               
            },
            get_cb_list:function(){
               http_util.get_cb_list(function(res){
                  res = JSON.parse(res);
                  if(res.code==0){
                     if(app.cb_list!=null){
                        var buy_codes = [];
                        for(var i=0;i<res.data.length;i++){
                           var contains = false;
                           for(var j=0;j<app.cb_list.length;j++){
                              if(app.cb_list[j][0][0] ==res.data[i][0][0] ){
                                 contains = true;
                                 break;
                              }
                           }
                           if(!contains){
                              buy_codes.push(res.data[i][0][0])
                           }
                        }
                        if(buy_codes.length>0){
                           buy_codes.forEach(function(e){
                              http_util.buy_by_ths(e,function(res){
                                 res= JSON.parse(res);
                                 if(res.code!=0){
                                    console.log("同花顺下单出错:",res.msg);
                                 }else{
                                    layer.msg("下单完成");
                                 }
                              });
                           });
                        }
                     }
                     app.cb_list = res.data;
                     var arr= new Array();
                     arr = arr.concat(res.data);
                     app.cb_list_top = arr;
                     app.set_selected_cb_top(true);
                  }
               })
            add_or_remove_green_buy:function(event,code, index){
               var el = event.currentTarget;
               var checked = $(el).is(':checked');
               console.log(code, checked);
               if(checked){
                  http_util.do_action_for_code(code,'',8,function(res){
                        app.want_codes[index][4] = 1;
                  });
               }else{
                  http_util.do_action_for_code(code,'',9,function(res){
                     app.want_codes[index][4] = 0;
                  });
               }
            },
            add_or_remove_want_buy:function(event,code, index){
               var el = event.currentTarget;
               var checked = $(el).is(':checked');
               console.log(code, checked);
               if(checked){
                  http_util.do_action_for_code(code,'',4,function(res){
                        app.want_codes[index][12] = 1;
                  });
               }else{
                  http_util.do_action_for_code(code,'',5,function(res){
                     app.want_codes[index][12] = 0;
                  });
               }
            },
            
            set_selected_cb_top:function(update_top){
@@ -957,17 +1011,155 @@
                  }
               });
               
            }
            },
            // 获取新增概念
            get_new_blocks:function(){
              http_util.get_new_blocks(function(res){
                 res= JSON.parse(res);
                 console.log(res);
                 if(res.code==0){
                    var blocks = res.data;
                    var block_str="";
                    for(var i=0;i<blocks.length;i++){
                       block_str +=blocks[i];
                       if(i<blocks.length-1){
                          block_str+="、";
                       }
                    }
                    app.new_blocks = block_str;
                 }else{
                  layer.msg(res.msg);
                 }
              })
            },
            add_to_ths:function(code){
               pyjs.add_code_to_ths(code);
            },
            show_latest_limit_up_queue:function(time_str){
                  http_util.get_kpl_latest_limit_up_queue_by_time(time_str,function(res){
                  res = JSON.parse(res);
                  if(res.code==0){
                     datas = [];
                     res.data.sort((a,b)=>a[2] - b[2]);
                     res.data.forEach(function(e){
                        let date = new Date(e[2]*1000);
                        let hours = String(date.getHours()).padStart(2, '0');
                        let minutes = String(date.getMinutes()).padStart(2, '0');
                        let seconds = String(date.getSeconds()).padStart(2, '0');
                        temp_time_str = `${hours}:${minutes}:${seconds}`;
                        datas.push([e[0],e[1],temp_time_str,e[4],e[5],e[6]]);
                     });
                     app.latest_limit_up_datas = datas;
                     layer.open({
                        title: '当时涨停:' + time_str,
                        type: 1,
                        content: $("#latest_limit_up_dialog"),
                     });
                  }
               });
            },
            show_green_codes:function(){
               http_util.get_green_codes(function(res){
                  app.green_list = res.data;
                  layer.open({
                     title: '绿名单',
                     type: 1,
                     content: $("#green_list_dialog"),
                  });
               });
            },
            delete_from_green_codes:function(code_info){
               code = code_info.split(":")[1]
               http_util.do_action_for_code(code, '', 9);
               http_util.get_green_codes(function(res){
                  app.green_list = res.data;
               });
            },
            show_want_codes_list:function(){
               http_util.get_want_codes('',function(res){
                  app.want_list = res.data;
                  layer.open({
                     title: '想买单',
                     type: 1,
                     content: $("#want_list_dialog"),
                  });
               });
            },
            delete_from_want_codes:function(code_info){
               code = code_info.split(":")[1]
               http_util.do_action_for_code(code, '', 5);
               http_util.get_want_codes('',function(res){
                  app.want_list = res.data;
               });
            },
            get_place_order_records:function(){
               day = $("#date").val();
               http_util.get_place_order_records(day,function(res){
                  res = JSON.parse(res);
                  if(res.code == 0){
                     app.place_order_record_list = res.data;
                  }
               });
            },
            get_block_codes_with_money:function(block, desc){
               http_util.get_block_codes_with_money(block, 1, function(res){
                  res = JSON.parse(res);
                  if(res.code == 0){
                     app.block_codes_in = res.data;
                     http_util.get_block_codes_with_money(block, 0, function(res){
                        res = JSON.parse(res);
                        if(res.code == 0){
                           app.block_codes_out = res.data;
                        }
                        layer.open({
                           title: '成分股',
                           type: 1,
                           content: $("#block_codes_dialog"),
                        });
                     });
                  }
               });
            },
            get_l2_subscript_codes:function(){
               http_util.get_l2_subscript_codes(function(res){
                  if(res.code == 0){
                     app.l2_subscript_codes = res.data.list;
                  }
               });
            },
            add_to_forbidden:function(code){
                  http_util.do_action_for_code(code,'',0,function(res){
                     layer.msg("拉黑成功");
                     app.get_l2_subscript_codes();
                  });
            },
          }
      });
   }
   function init_data() {
      app.get_industry_data(app.industry_data_type);
      app.get_jingxuan_data(app.jingxuan_data_type);
      app.get_block_in_money_data(app.in_money_type);
      app.get_limit_up_list(app.code, false);
      app.get_limit_up_statistic_infos(true);
      app.get_kpl_market_feelings();
      app.get_cb_list();
      app.statistic_latest_limit_up_block("");
   }