From ec4cc6d4ccba433cf10678b3d767e588a2d00e91 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 16 十二月 2024 16:57:33 +0800 Subject: [PATCH] 去除掘金依赖 --- kp_html/kp/js/page.js | 635 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 575 insertions(+), 60 deletions(-) diff --git a/kp_html/kp/js/page.js b/kp_html/kp/js/page.js index c31f783..87bb074 100644 --- a/kp_html/kp/js/page.js +++ b/kp_html/kp/js/page.js @@ -12,15 +12,16 @@ var app; $(function() { + function _resize() { - var code_info_height = 480 + 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(2)>div").css("height", code_info_height).css("max-height", code_info_height); - $("#body>div:nth-child(3)").css("height", bottom_height) - $("#body>div:nth-child(3)>div:nth-child(2)").css("height", bottom_height - 10) - $("#body>div:nth-child(3)>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) } //閽堝绐楀彛楂樺害鍋氳皟鏁� @@ -63,15 +64,34 @@ //闈炰氦鏄撴椂闂翠笉鍒锋柊 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); + + + setInterval(function() { + if (is_trade_time()) { + app.get_kpl_market_feelings(); + } + }, 3000, 3000); + + setInterval(function() { + if (is_trade_time()) { + app.get_l2_subscript_codes(); + } + }, 3000, 3000); + + + + + @@ -89,6 +109,11 @@ trade_data: { order: 0 }, + cb_list:null,// 鍙浆鍊哄垪琛� + cb_list_top:[], + cb_selected_code:'', + // 浠g爜鐨勫紑鐩樺暒娑ㄥ仠鍘熷洜 + kpl_limit_up_reason: '', default_score_data: { volume: { "score": 0, @@ -231,6 +256,16 @@ ["鏉垮潡2", "0.5%", ''] ] }, + yesterday_block_info: { + reason: "娴嬭瘯", + data: { + yesterday: [ + ["000333", "缇庣殑闆嗗洟"] + ], + current: [] + } + }, + initiative_buy_codes: [{ "name": "缇庣殑闆嗗洟", "code": "000333", @@ -274,14 +309,7 @@ limit_up_codes: [ //(浠g爜,鍚嶇О,娑ㄥ仠鐘舵��(0-鏃犵姸鎬� 1-娑ㄥ仠 2-鐐告澘),榫欏嚑,棣栨澘,鍒嗗��,娑ㄥ仠鏃堕棿,鍘熷洜,鐩稿悓鍘熷洜浠g爜鏁伴噺,鑷敱娴侀��,涔嬪墠鐨勬澘鍧�) ["000333", "缇庣殑闆嗗洟", 1, "榫�1", "棣栨澘", "200", "10:00:00", "涓�瀛e害澧為暱", "1", "12.02浜�", - '12浜�', '', - '' - ], - ["000333", "缇庣殑闆嗗洟", 1, "榫�1", "棣栨澘", "200", "10:00:00", "涓�瀛e害澧為暱", "1", "12.02浜�", - '' - ], - ["000333", "缇庣殑闆嗗洟", 1, "榫�1", "棣栨澘", "200", "10:00:00", "涓�瀛e害澧為暱", "1", "12.02浜�", - '' + '12浜�', '', '' ] ] }, @@ -345,7 +373,8 @@ ["鏉垮潡", "2020-01-01"], ["鏉垮潡", "2020-01-01"] ], - blocks: ["鏉垮潡1", "鏉垮潡2"] + blocks: ["鏉垮潡1", "鏉垮潡2"], + }] }, @@ -355,9 +384,22 @@ first: '', second: '' }, - industry_data_type: 0, - jingxuan_data_type: 0, - + in_money_type: 4, + // 涓夋柟浠g爜鏉垮潡 + code_third_blocks: null, + // 甯傚満鎯呯华 + market_feeling_info: {}, + // 鏉垮潡杞姩 + 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() { @@ -382,34 +424,43 @@ key = $("#limit_up_search_key").val(); app.limit_up_search_key = key; }, - //鑾峰彇琛屼笟鏁版嵁 - get_industry_data: function(type) { - app.industry_data_type = type; - http_util.get_market_data(app.industry_data_type, function(result) { - result = JSON.parse(result); - if (result.code == 0) { - app.industry_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) { - app.jingxuan_data_type = type; - if (type == 0) { - type = 2; - } else { - type = 3; + 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; } - - http_util.get_market_data(type, function(result) { - result = JSON.parse(result); - if (result.code == 0) { - app.jingxuan_datas = result.data; - } - }); }, + + get_score_data: function(code, name, callback) { console.log("鑾峰彇鍒嗘暟鏁版嵁锛�", code, name); - http_util.get_score_data(code, name, function(res) { + var date=$("#date").val(); + http_util.get_score_data(code, name,date, function(res) { res = JSON.parse(res) console.log("鍒嗘暟璇锋眰缁撴灉锛�", res) if (res.code == 0) { @@ -426,10 +477,28 @@ order: res.data.trade_data.trade_state.order } } else { - app.trade_data = { + res.data.trade_data = { order: false }; + app.trade_data = res.data.trade_data } + res.data.kpl_code_info.plate.forEach(function(e) { + var s = null; + if (app.first_info.limit_up_reason_statistic) { + for (var i = 0; i < app.first_info + .limit_up_reason_statistic + .length; i++) { + var limit_up_info = app.first_info.limit_up_reason_statistic[i]; + if (limit_up_info[0] == e[1]) { + s = limit_up_info; + break; + } + } + } + e.push(s); + }); + + app.kpl_code_info = res.data.kpl_code_info; app.initiative_buy_codes = res.data.initiative_buy_codes; app.passive_buy_codes = res.data.passive_buy_codes; @@ -451,24 +520,60 @@ }); }, get_limit_up_list: function(code, is_auto_refresh) { - http_util.get_limit_up_list(code, function(res) { + day = $("#date").val(); + http_util.get_limit_up_list(code,day, function(res) { res = JSON.parse(res) if (res.code == 0) { app.first_info = res.data - if (app.choose_code.first) { - app.get_plate_info(app.choose_code.first, is_auto_refresh); - } else if (app.first_info.limit_up_codes) { - app.choose_code.first = app.first_info.limit_up_codes[0][0]; - app.get_plate_info(app.first_info.limit_up_codes[0][0], - is_auto_refresh); + var temps = new Array(); + var current_limit_up_reason = null; + app.first_info.limit_up_reason_statistic.forEach(function(d) { + if (d[0] == app.kpl_limit_up_reason) { + current_limit_up_reason = d; + } else { + temps.push(d); + } + }); + if (current_limit_up_reason) { + temps.unshift(current_limit_up_reason); } + app.first_info.limit_up_reason_statistic = temps; + // if (app.choose_code.first) { + // app.get_plate_info(app.choose_code.first, is_auto_refresh); + // } else if (app.first_info.limit_up_codes) { + // app.choose_code.first = app.first_info.limit_up_codes[0][0]; + // app.get_plate_info(app.first_info.limit_up_codes[0][0], + // is_auto_refresh); + // } + } + }); + }, + 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) { @@ -490,7 +595,7 @@ // } http_util.cancel_order(app.code, function() { //鎾ゅ崟鎴愬姛锛屽埛鏂颁唬鐮� - app.get_score_data(app.code, null); + app.get_score_data(app.code,null,null); }); }, forbidden_plate: function(plate, type) { @@ -511,11 +616,29 @@ var el = event.currentTarget; if (app.choose_code.first != app.first_info.limit_up_codes[index][0]) { app.choose_code.first = app.first_info.limit_up_codes[index][0]; + app.code = app.first_info.limit_up_codes[index][0]; + app.code_name = app.code + "(" + app.first_info.limit_up_codes[index][1] + + ")"; app.get_score_data(app.first_info.limit_up_codes[index][0], app.first_info .limit_up_codes[index][1]); app.get_plate_info(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( @@ -590,15 +713,78 @@ console.log("璁剧疆鐩爣浠g爜", code); app.origin_code = code; app.code = code; - init_data(); + app.code_name = code; + app.first_info.limit_up_codes.forEach(function(e) { + if (e[0] == code) { + app.code_name = e[0] + "(" + e[1] + + ")"; + } + }); + app.get_code_third_blocks(code); + + //璇锋眰鏉垮潡 + setTimeout(function() { + http_util.get_kpl_block_info(code, function(res) { + res = JSON.parse(res) + console.log("鏉垮潡璇锋眰缁撴灉锛�", res); + if (res.code == 0) { + res.data.plate.forEach(function(e) { + var s = null; + if (app.first_info.limit_up_reason_statistic) { + for (var i = 0; i < app.first_info + .limit_up_reason_statistic + .length; i++) { + if (app.first_info + .limit_up_reason_statistic[ + i][0] == e[1]) { + s = app.first_info.limit_up_reason_statistic[i]; + break; + } + } + } + e.push(s); + }); + + + app.kpl_code_info = res.data; + + // 璁剧疆褰撴棩娑ㄥ仠鍘熷洜 + app.kpl_limit_up_reason = app.kpl_code_info.today[0] + [0]; + // 灏嗗綋鍓嶆定鍋滃師鍥犵疆椤� + var limit_up_reason_statistic = app.first_info + .limit_up_reason_statistic; + var current_limit_up_reason; + if (limit_up_reason_statistic) { + var temps = new Array(); + limit_up_reason_statistic.forEach(function(d) { + if (d[0] == app + .kpl_limit_up_reason) { + current_limit_up_reason = d; + } else { + temps.push(d); + } + }); + if (current_limit_up_reason) { + temps.unshift(current_limit_up_reason); + } + app.first_info.limit_up_reason_statistic = + temps; + } + } + }); + }, 10); + + this.set_selected_cb_top(true); + //init_data(); }, show_want_codes: function(plate) { if (Date.now() - app.last_show_dialog < 500) { return; } app.last_show_dialog = Date.now() - - http_util.get_plate_codes(plate, function(result) { + var day = $("#date").val(); + http_util.get_plate_codes(plate,day, function(result) { result = JSON.parse(result); console.log("娑ㄥ仠鍘熷洜鎴愬垎鑲¤繑鍥烇細", result); var datas = result.data; @@ -610,6 +796,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, function(result) { @@ -619,16 +821,329 @@ app.get_limit_up_list(app.code, true); } }); - } - } + }, + get_kpl_market_feelings: function() { + http_util.get_kpl_market_feelings(function(res) { + console.log(res); + res = JSON.parse(res); + if (res.code == 0) { + app.market_feeling_info = res.data; + labels = []; + values = []; + colors = []; + res.data.map.forEach(function(e) { + labels.push(e[0]); + values.push(e[1]); + colors.push(e[2]); + }); + console.log(colors); + if (!app.market_feeling_chart) { + app.market_feeling_chart = new Chart($( + "#market_feeling_chart"), { + type: 'bar', + data: { + labels: labels, + datasets: [{ + label: '甯傚満鎯呯华', + data: values, + backgroundColor: colors, + }] + }, + itemStyle: { + + }, + options: { + plugins: { + legend: { + display: false // 闅愯棌鍥句緥 + }, + }, + scales: { + y: { + display: true + }, + x: { + grid: { + display: false, + } + + }, + } + + } + }); + } else { + app.market_feeling_chart.data.labels = labels; + app.market_feeling_chart.data.datasets[0].data = values; + app.market_feeling_chart.data.datasets[0].backgroundColor = + colors; + app.market_feeling_chart.update(); + } + + + } + }); + }, + add_or_remove_forbidden: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,'',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; + }); + } + + }, + 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){ + var temp_list=app.cb_list; + for(var i=0;i<temp_list.length;i++){ + if(temp_list[i][0][0] == app.cb_selected_code){ + var data = temp_list[i]; + temp_list.splice(i, 1); + temp_list.unshift(data); + app.cb_list = temp_list; + + break; + } + } + if(update_top){ + // 鍏堝彉榛� + // 缃《 + var temp_list=app.cb_list_top; + for(var i=0;i<temp_list.length;i++){ + if(temp_list[i][1][0] == app.code){ + var data = temp_list[i]; + temp_list.splice(i, 1); + temp_list.unshift(data); + app.cb_list_top = temp_list; + app.cb_selected_code = data[0][0]; + break; + } + } + } + }, + + select_cb:function(data){ + app.cb_selected_code = data[0][0]; + this.set_selected_cb_top(false); + }, + add_to_ths:function(code){ + pyjs.add_code_to_ths(code); + }, + buy_by_ths:function(code){ + http_util.buy_by_ths(code,function(res){ + res= JSON.parse(res); + if(res.code!=0){ + layer.msg("涓嬪崟鍑洪敊锛�"+res.msg); + + }else{ + layer.msg("涓嬪崟瀹屾垚"); + } + }); + }, + statistic_latest_limit_up_block:function(code){ + http_util.statistic_latest_limit_up_block(code,function(res){ + res= JSON.parse(res); + console.log(res); + if(res.code!=0){ + layer.msg(res.msg); + }else{ + app.latest_limit_up_blocks= res.data; + } + }); + + }, + // 鑾峰彇鏂板姒傚康 + 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_score_data(app.code); + 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.statistic_latest_limit_up_block(""); } $(".market .child-title").click(function() { -- Gitblit v1.8.0