From 5a2ef3a696ddccbc1faef1e2e90f5b535ec24a0d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 11 一月 2024 10:06:14 +0800 Subject: [PATCH] 看盘网页修改/接口本地化代理 --- kp_html/kp/js/code_list.js | 407 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 332 insertions(+), 75 deletions(-) diff --git a/kp_html/kp/js/code_list.js b/kp_html/kp/js/code_list.js index 8fdf6b1..bdc6391 100644 --- a/kp_html/kp/js/code_list.js +++ b/kp_html/kp/js/code_list.js @@ -23,20 +23,6 @@ return false; } } - // 瀹氭椂鎷夊彇H鎾ゆ暟鎹� - setInterval(function() { - if (app.code != '000000' && app.trade_data) { - if (is_trade_time()) { - http_util.get_h_cancel_data(app.code, function(res) { - res = JSON.parse(res); - console.log("缁撴灉:", res) - if (res.code == 0) { - app.$set(app.trade_data, 'h_cancel', res.data) - } - }); - } - } - }, 3000) new VConsole(); app = new Vue({ @@ -44,86 +30,357 @@ data: { code: "000000", code_name: "娴嬭瘯浠g爜", + origin_code:null, trade_data: {}, trade_record: { open_limit_up: "", records: [] }, - same_reason_codes: null + same_reason_codes: null, + initiative_buy_codes: null, + passive_buy_codes: null, + data_type: 0, + trade_progress_index: -1, + latest_real_order_index: -1, + hidden_canceled: false, + //闅愯棌鎾ゅ崟 + hidden_cancel:true, + hidden_little_money:false, + hidden_sell:true, + l2_datas: [], + l2_colors_class: ["color-single-start", "color-single-exec", "color-cancel", + "color-real-order" + ], + kpl_code_info: null, + l_up_cancel_indexes: [], + l_down_cancel_indexes: [], + h_cancel_indexes: [], + buy_single_indexes: [], + l2_code_name: '', + operate_index: -1, + // 宸茬粡濮旀墭鐨勪拱浠g爜淇℃伅 + delegated_buy_code_infos:[], + layui_element:null + }, + watch:{ + delegated_buy_code_infos:function(){ + if(app.layui_element){ + setTimeout(()=>{ + app.layui_element.render(); + }) + } + } + }, + mounted:function(){ + layui.use('element', function(){ + var element = layui.element; + app.layui_element=element; + }); + + setInterval(function(){ + app.get_delegated_buy_code_infos(); + },1000*600*5); }, methods: { + change_data_type: function(type) { + if (app.data_type == type) { + return; + } + app.data_type = type; + window.scrollTo(0,0); + }, + refresh_trade_progress: function() { + if (app.code == "000000") { + alert("娌℃湁鑾峰彇鍒颁唬鐮�") + return; + } + http_util.get_trade_progress(app.code, function(res) { + res = JSON.parse(res); + if (res.code == 0) { + console.log("鎴愪氦杩涘害", res.data); + if (!res.data.is_default) { + app.trade_progress_index = res.data.trade_progress; + } + } + }); + }, + refresh_l_cancel_data: function(type_) { + // 鍒锋柊L鎾� + if (app.code == "000000") { + alert("娌℃湁鑾峰彇鍒颁唬鐮�") + return; + } + http_util.get_l2_l_cancel_datas(app.code, app.operate_index, function(res) { + console.log("L鎾ょ粨鏋�",res); + res = JSON.parse(res); + if (res.code == 0) { + if (type_ == 0) { + app.l_up_cancel_indexes = res.data.up; + } else { + app.l_down_cancel_indexes = res.data.down; + } + } + }); + }, + refresh_h_cancel_data: function() { + // 鍒锋柊h鎾� + if (app.code == "000000") { + alert("娌℃湁鑾峰彇鍒颁唬鐮�") + return; + } + http_util.get_l2_h_cancel_datas(app.code, app.operate_index, function(res) { + res = JSON.parse(res); + if (res.code == 0) { + app.h_cancel_indexes = res.data; + } + }); + }, + refresh_l2_data: function() { + if (app.code == "000000") { + alert("娌℃湁鑾峰彇鍒颁唬鐮�") + return; + } + http_util.get_l2_datas(app.code, function(res) { + console.log("鑾峰彇鍒版暟鎹細",res) + res = JSON.parse(res); + if (res.code == 0) { + var real_order_index = -1; + var buy_singles = []; + res.data.data.forEach(function(e) { + if (e[1] != null) { + if (e[1][0] == 3) { + //鐪熷疄涓嬪崟浣嶇疆 + real_order_index = e[2][0]; + } else if (e[1][0] == 0) { + // 淇″彿浣嶇疆 + buy_singles.push(e[2][0]) + } + e[1] = app.l2_colors_class[e[1][0]] + } else { + e[1] = ''; + } + e[2][3] = e[2][3].slice(0, e[2][3].length - 1) + }); + console.log("鏈�杩戠湡瀹炰笅鍗曚綅缃細", real_order_index); + app.latest_real_order_index = real_order_index; + app.l2_datas = res.data.data; + var code_name = res.data.code_name; + var code_ = res.data.code; + app.l2_code_name = code_ + " " + code_name; + // 娓呴櫎鎴愪氦杩涘害锛孡鎾�, H鎾� + app.trade_progress_index = -1; + app.l_up_cancel_indexes = []; + app.l_down_cancel_indexes = []; + app.h_cancel_indexes = []; + app.buy_single_indexes = buy_singles; + }else{ + alert(res.msg); + } + }); + + }, + get_delegated_buy_code_infos:function(){ + // 鑾峰彇鏁版嵁 + http_util.get_delegated_buy_code_infos(function(result){ + if (result.code == 0) { + console.log("宸叉寕涔板崟鏁版嵁锛�",result.data); + result.data.forEach(function(e){ + if(e.total_num>0){ + e.percent = e.finish_num*100/e.total_num; + }else{ + e.percent = 0; + } + }); + app.delegated_buy_code_infos = result.data + } + }); + }, + + + clear_cancel_mark: function() { + //娓呴櫎鎾ゅ崟鏍囪 + app.l_up_cancel_indexes = []; + app.l_down_cancel_indexes = []; + app.h_cancel_indexes = []; + }, get_last_trade_day_reasons: function(code) { http_util.get_last_trade_day_reasons(code, function(res) { - res= JSON.parse(res); - console.log("杩斿洖鍐呭",res); - if(res.code==0){ - app.same_reason_codes = res.data; - }else{ - app.same_reason_codes = null; - } + res = JSON.parse(res); + console.log("杩斿洖鍐呭", res); + if (res.code == 0) { + app.same_reason_codes = res.data; + } else { + app.same_reason_codes = null; + } }); }, + hidden_canceled_check: function(e) { + + app.hidden_canceled = e.currentTarget.checked; + }, + + hidden_cancel_check: function(e) { + + app.hidden_cancel = e.currentTarget.checked; + }, + + hidden_sell_check: function(e) { + app.hidden_sell = e.currentTarget.checked; + }, + + hidden_little_money_check:function(e){ + app.hidden_little_money = e.currentTarget.checked; + }, + + select_row: function(index) { + console.log("鐐瑰嚮浜嬩欢", index); + if (app.buy_single_indexes.includes(index)) { + app.operate_index = index; + } else { + app.operate_index = -1; + } + }, + show_operate: function(event, index) { + console.log("浣嶇疆", event.clientX, event.clientY); + }, set_trade_info: function(code, code_name, trade_data, trade_record, initiative_buy_codes, passive_buy_codes) { - console.log("浜ゆ槗鏁版嵁", code, code_name, trade_data, trade_record) - console.log("涓诲姩涔板叆", initiative_buy_codes) - console.log("琚姩涔板叆", passive_buy_codes) - app.code = code; - app.get_last_trade_day_reasons(code); - app.code_name = code_name; - if (trade_data) { - var trade_data = JSON.parse(trade_data); - app.trade_data = trade_data - } else { - app.trade_data = { - "star": { - "desc": "----", - "count": 0 - }, - "safe_count": { - "base": 0, - "now": 0 - }, - "m_val": { - "base": 0, - "now": 0 - }, - "big_num": { - "base": 0, - "now": 0 - }, - "trade_progress": { - "time": "00:00:00", - "num": 0, - "money": 0 - }, - "trade_state": { - "order": false, - "desc": "鏈氦鏄�" + try { + console.log("浜ゆ槗鏁版嵁", trade_data) + console.log("浜ゆ槗璁板綍鏁版嵁", trade_record) + app.code = code; + // app.get_last_trade_day_reasons(code); + app.code_name = code_name; + if (trade_data) { + console.log("浜ゆ槗鏁版嵁绫诲瀷", typeof trade_data) + try { + // trade_data = trade_data.replace("/\n/g", " ") + // var trade_data = JSON.parse(trade_data); + app.trade_data = trade_data + } catch (e) { + console.log(e) } - }; + console.log("----鏈変氦鏄撴暟鎹�") + } else { + app.trade_data = { + "star": { + "desc": "----", + "count": 0 + }, + "safe_count": { + "base": 0, + "now": 0 + }, + "m_val": { + "base": 0, + "now": 0 + }, + "big_num": { + "base": 0, + "now": 0 + }, + "trade_progress": [{ + "time": "00:00:00", + "num": 0, + "money": 0 + }], + "trade_state": { + "order": false, + "desc": "鏈氦鏄�" + } + }; + } + if (trade_record) { + console.log("----鏈変氦鏄撹褰�") + app.trade_record = trade_record; + } else { + console.log("----鏃犱氦鏄撹褰�") + app.trade_record = null; + } + } catch (ee) { + console.log("澶勭悊鍑洪敊") + console.log(e) } - if (trade_record) { - app.trade_record = JSON.parse(trade_record); - } else { - app.trade_record = null; - } - if (initiative_buy_codes) { - app.initiative_buy_codes = JSON.parse(initiative_buy_codes); - } else { - app.initiative_buy_codes = null; - } + }, + show_more_records: function(items) { + var str_ = "" + items.forEach(function(item) { + str_ += item; + str_ += "\n"; + }); + alert(str_); + }, + test: function() { - if (passive_buy_codes) { - app.passive_buy_codes = JSON.parse(passive_buy_codes); - } else { - app.passive_buy_codes = null; + }, + need_show:function(item){ + if(app.hidden_canceled&&(item[2][6].indexOf('涔版挙')>=0||(item[2][8]!=null&&item[2][8].indexOf("-")>0))){ + return false; } - - + + if(app.hidden_sell&&item[2][6].indexOf('鍗�')>=0){ + return false; + } + + if(app.hidden_cancel&&(item[2][6].indexOf('涔版挙')>=0)){ + return false; + } + if(app.hidden_little_money&&parseFloat(item[2][3])<50&&item[2][0]!=app.latest_real_order_index){ + return false; + } + + return true; + }, + get_score_data: function(code, name, callback) { + console.log("鑾峰彇鍒嗘暟鏁版嵁锛�", code, name); + http_util.get_score_data(code, name, function(res) { + res = JSON.parse(res) + console.log("鍒嗘暟璇锋眰缁撴灉锛�", res) + if (res.code == 0) { + console.log("鑾峰彇鍒嗘暟", res) + app.code = res.data.code + app.code_name = res.data.code_name + if (res.data.score_data) { + app.score_data = res.data.score_data; + } else { + app.score_data = app.default_score_data; + } + if (res.data.trade_data) { + app.trade_data = { + order: res.data.trade_data.trade_state.order + } + } else { + res.data.trade_data= { + order: false + }; + app.trade_data = res.data.trade_data + } + app.kpl_code_info = res.data.kpl_code_info; + //閫氱煡鍓睆鏀瑰彉鍐呭 + app.set_trade_info(app.code, app.code_name, + res.data.trade_data, + res.data.trade_record, + res.data.initiative_buy_codes, + res.data.passive_buy_codes); + + if (callback) { + callback() + } + } + }); + }, + set_target_code: function(code) { + console.log("璁剧疆鐩爣浠g爜", code); + app.origin_code = code; + app.code_name = code; + }, + load_data:function(){ + if(app.origin_code){ + app.get_score_data(app.origin_code,null,null); + } + } - } }) -- Gitblit v1.8.0