From b92dbb786833487fa343f3edea1b1b9885e86dc1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 29 二月 2024 17:32:40 +0800
Subject: [PATCH] 网页修改/自动加同花顺修改

---
 kp_html/kp/js/code_list.js |  246 ++++++++++++++++++++++++++++--------------------
 1 files changed, 144 insertions(+), 102 deletions(-)

diff --git a/kp_html/kp/js/code_list.js b/kp_html/kp/js/code_list.js
index a99e0a4..ff4a74a 100644
--- a/kp_html/kp/js/code_list.js
+++ b/kp_html/kp/js/code_list.js
@@ -28,9 +28,11 @@
 	app = new Vue({
 		el: "#app",
 		data: {
+			element: null,
 			code: "000000",
 			code_name: "娴嬭瘯浠g爜",
-			origin_code:null,
+			account_available_money: 0,
+			origin_code: null,
 			trade_data: {},
 			trade_record: {
 				open_limit_up: "",
@@ -44,9 +46,9 @@
 			latest_real_order_index: -1,
 			hidden_canceled: true,
 			//闅愯棌鎾ゅ崟
-			hidden_cancel:true,
-			hidden_little_money:true,
-			hidden_sell:true,
+			hidden_cancel: true,
+			hidden_little_money: true,
+			hidden_sell: true,
 			l2_datas: [],
 			l2_colors_class: ["color-single-start", "color-single-exec", "color-cancel",
 				"color-real-order"
@@ -59,38 +61,46 @@
 			l2_code_name: '',
 			operate_index: -1,
 			// 宸茬粡濮旀墭鐨勪拱浠g爜淇℃伅
-			delegated_buy_code_infos:[],
-			layui_element:null,
-			l2_cant_buy_reasons:[],
+			delegated_buy_code_infos: [],
+			layui_element: null,
+			l2_cant_buy_reasons: [],
+			latest_cancel_orders: []
 		},
-		watch:{
-			delegated_buy_code_infos:function(){
-				if(app.layui_element){
-					setTimeout(()=>{
+		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(){
-				if(is_trade_time()){
+		mounted: function() {
+			layui.use('element', function() {
+				var element = layui.element;
+				app.layui_element = element;
+			});
+
+			setInterval(function() {
+				if (is_trade_time()) {
 					app.get_delegated_buy_code_infos();
+					app.get_latest_cancel_orders();
 				}
-			},1000*3);
+			}, 1000 * 3);
+
+			layui.use(function() {
+				app.element = layui.element;
+			});
+
 		},
 		methods: {
 			change_data_type: function(type) {
-				if (app.data_type == type) {
-					return;
-				}
-				app.data_type = type;
-				window.scrollTo(0,0);
+				// if (app.data_type == type) {
+				// 	return;
+				// }
+				// app.data_type = type;
+				// window.scrollTo(0,0);
+				app.element.tabChange('test-handle', type);
 			},
 			refresh_trade_progress: function() {
 				if (app.code == "000000") {
@@ -114,7 +124,7 @@
 					return;
 				}
 				http_util.get_l2_l_cancel_datas(app.code, app.operate_index, function(res) {
-					console.log("L鎾ょ粨鏋�",res);
+					console.log("L鎾ょ粨鏋�", res);
 					res = JSON.parse(res);
 					if (res.code == 0) {
 						if (type_ == 0) {
@@ -143,14 +153,14 @@
 					alert("娌℃湁鑾峰彇鍒颁唬鐮�")
 					return;
 				}
-				
+
 				var index = layer.load(1, {
-				  shade: [0.1,'#fff'] //0.1閫忔槑搴︾殑鐧借壊鑳屾櫙
+					shade: [0.1, '#fff'] //0.1閫忔槑搴︾殑鐧借壊鑳屾櫙
 				});
-		
+
 				http_util.get_l2_datas(app.code, function(res) {
 					layer.close(index);
-					console.log("鑾峰彇鍒癓2鏁版嵁锛�",res)
+					console.log("鑾峰彇鍒癓2鏁版嵁锛�", res)
 					res = JSON.parse(res);
 					if (res.code == 0) {
 						var real_order_index = -1;
@@ -173,7 +183,7 @@
 						console.log("鏈�杩戠湡瀹炰笅鍗曚綅缃細", real_order_index);
 						app.latest_real_order_index = real_order_index;
 						app.l2_datas = res.data.data;
-						console.log("L2鏁版嵁:",app.l2_datas);
+						console.log("L2鏁版嵁:", app.l2_datas);
 						var code_name = res.data.code_name;
 						var code_ = res.data.code;
 						app.l2_code_name = code_ + " " + code_name;
@@ -183,33 +193,54 @@
 						app.l_down_cancel_indexes = [];
 						app.h_cancel_indexes = [];
 						app.buy_single_indexes = buy_singles;
-					}else{
+					} else {
 						alert(res.msg);
 					}
 				});
 
 			},
-			get_delegated_buy_code_infos:function(){
+			get_delegated_buy_code_infos: function() {
 				// 鑾峰彇鏁版嵁
-				http_util.get_delegated_buy_code_infos(function(result){
+				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{
+						console.log("宸叉寕涔板崟鏁版嵁锛�", result.data);
+						result.data.delegates.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
-					}else{
-						console.log("宸叉寕涔板崟閿欒锛�",result.msg);
-						app.delegated_buy_code_infos=[];
+						app.delegated_buy_code_infos = result.data.delegates;
+						app.account_available_money = result.data.account_available_money;
+						app.reset_l2_height();
+
+					} else {
+						console.log("宸叉寕涔板崟閿欒锛�", result.msg);
+						app.delegated_buy_code_infos = [];
 					}
 				});
 			},
-			
-			
+
+			get_latest_cancel_orders: function() {
+				http_util.get_latest_cancel_orders(function(res) {
+					res = JSON.parse(res);
+					console.log("鏈�杩戠殑鎾ゅ崟", res);
+					if (res.code == 0) {
+						app.latest_cancel_orders = res.data;
+						app.reset_l2_height();
+					}
+				});
+
+			},
+
+			reset_l2_height: function() {
+				var height = document.documentElement.clientHeight;
+				console.log("灞忓箷锛�", height);
+				$(".l2-content").eq(0).css("height", (height - 370 - 66 * app
+						.delegated_buy_code_infos.length - 24 * app.latest_cancel_orders.length
+						) + "px");
+			},
 			clear_cancel_mark: function() {
 				//娓呴櫎鎾ゅ崟鏍囪
 				app.l_up_cancel_indexes = [];
@@ -232,17 +263,17 @@
 
 				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){
+
+			hidden_little_money_check: function(e) {
 				app.hidden_little_money = e.currentTarget.checked;
 			},
 
@@ -315,7 +346,7 @@
 					console.log("澶勭悊鍑洪敊")
 					console.log(e)
 				}
-				 app.get_l2_cant_buy_reasons(code); 
+				app.get_l2_cant_buy_reasons(code);
 			},
 			show_more_records: function(items) {
 				var str_ = ""
@@ -327,56 +358,62 @@
 			},
 			set_real_place_order_index: function() {
 				// 璁剧疆鐪熷疄涓嬪崟浣�
-				if(app.code){
+				if (app.code) {
 					layer.prompt({
-					  formType: 0,
-					  value: '',
-					  title: '璁剧疆鐪熷疄涓嬪崟浣�-'+app.code,
-					  area: ['800px', '350px'] //鑷畾涔夋枃鏈煙瀹介珮
-					}, function(value, index, elem){
-						try{
-							if(isNaN(value)){
+						formType: 0,
+						value: '',
+						title: '璁剧疆鐪熷疄涓嬪崟浣�-' + app.code,
+						area: ['800px', '350px'] //鑷畾涔夋枃鏈煙瀹介珮
+					}, function(value, index, elem) {
+						try {
+							if (isNaN(value)) {
 								layer.msg("璇疯緭鍏ユ暟瀛�");
 								return;
-							}else{
-								http_util.set_real_place_order_index(app.code,parseInt(value),function(res){
+							} else {
+								http_util.set_real_place_order_index(app.code, parseInt(
+									value), function(res) {
 									// 鑾峰彇鍒扮粨鏋�
 									console.log(res);
-									if(res.code!=0){
-										layer.msg(res.msg,{icon: 5});
-									}else{
-										layer.msg("璁剧疆鎴愬姛",{icon: 1});
+									if (res.code != 0) {
+										layer.msg(res.msg, {
+											icon: 5
+										});
+									} else {
+										layer.msg("璁剧疆鎴愬姛", {
+											icon: 1
+										});
 									}
 								})
 							}
-						}catch(e){
-						}
+						} catch (e) {}
 						layer.close(index);
 					});
-					
+
 					//set_real_place_order_index
-					
-				}else{
-					layer.msg("璇峰厛鍔犺浇鏁版嵁"); 
+
+				} else {
+					layer.msg("璇峰厛鍔犺浇鏁版嵁");
 				}
-				
+
 			},
-			need_show:function(item){
-				if(app.hidden_canceled&&(item[2][6].indexOf('涔版挙')>=0||(item[2][8]!=null&&item[2][8].indexOf("-")>0))){
+			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){
+
+				if (app.hidden_sell && item[2][6].indexOf('鍗�') >= 0) {
 					return false;
 				}
-				
-				if(app.hidden_cancel&&(item[2][6].indexOf('涔版挙')>=0)){
+
+				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){
+				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) {
@@ -398,7 +435,7 @@
 								order: res.data.trade_data.trade_state.order
 							}
 						} else {
-							res.data.trade_data= {
+							res.data.trade_data = {
 								order: false
 							};
 							app.trade_data = res.data.trade_data
@@ -406,11 +443,11 @@
 						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.trade_data,
+							res.data.trade_record,
 							res.data.initiative_buy_codes,
 							res.data.passive_buy_codes);
-			
+
 						if (callback) {
 							callback()
 						}
@@ -422,40 +459,45 @@
 				app.origin_code = code;
 				app.code_name = code;
 			},
-			load_data:function(refresh_l2){
-				if(app.origin_code){
-					app.get_score_data(app.origin_code,null,function(e){
-						if(refresh_l2){
+			load_data: function(refresh_l2) {
+				if (app.origin_code) {
+					app.get_score_data(app.origin_code, null, function(e) {
+						if (refresh_l2) {
 							app.refresh_l2_data();
 						}
 					});
-				    app.get_l2_cant_buy_reasons(app.origin_code); 
+					app.get_l2_cant_buy_reasons(app.origin_code);
 				}
 			},
-			cancel_order:function(code){
-				http_util.cancel_order(code,function(res){
+			cancel_order: function(code) {
+				http_util.cancel_order(code, function(res) {
 					layer.msg("鎾ゅ崟鎴愬姛");
 				});
 			},
-			
-			view_details:function(code){
+
+			view_details: function(code, need_l2) {
 				pyjs.add_code_to_ths(code);
 				// 璁剧疆鐩爣浠g爜
 				app.set_target_code(code);
-				// 鐐瑰嚮閫夋嫨L2閫夐」
-				app.change_data_type(1);
 				// 灏嗙洰鏍囩エ浼犻�掑埌棣栭〉
 				pyjs.set_target_code(code);
-				app.load_data(true);
+				if (need_l2) {
+					// 鐐瑰嚮閫夋嫨L2閫夐」
+					app.change_data_type(1);
+					app.load_data(true);
+				} else {
+					app.change_data_type(0);
+					app.load_data(false);
+				}
 			},
-			
-			get_l2_cant_buy_reasons:function(code){
-				http_util.get_l2_cant_buy_reasons(code,function(res){
+
+			get_l2_cant_buy_reasons: function(code) {
+				http_util.get_l2_cant_buy_reasons(code, function(res) {
 					res = JSON.parse(res);
-					if(res.code==0){
+					if (res.code == 0) {
 						app.l2_cant_buy_reasons = res.data;
-					}else{
-						app.l2_cant_buy_reasons =[]
+					} else {
+						app.l2_cant_buy_reasons = []
 					}
 				});
 			}

--
Gitblit v1.8.0