From 321c0b34cf4bb21305d3c345d19d233e67ee141f Mon Sep 17 00:00:00 2001
From: Jacob <hlnie@tohours.com>
Date: 星期三, 14 十月 2026 13:09:30 +0800
Subject: [PATCH] feat: 全局引入页面日志 mixin 打印页面地址与入参

---
 pages/goods_cate/goods_cate.vue |  111 +++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 70 insertions(+), 41 deletions(-)

diff --git a/pages/goods_cate/goods_cate.vue b/pages/goods_cate/goods_cate.vue
index 8821bde..4b3e378 100644
--- a/pages/goods_cate/goods_cate.vue
+++ b/pages/goods_cate/goods_cate.vue
@@ -144,7 +144,11 @@
 				totalGetNum: 0,
 				// 棣栧睆浼樺寲锛氬綋鍓嶅垎绫荤殑寰呭畬鎴愯姹傛暟
 				catePending: [],
+				// 鏍囪鍚勫垎绫绘槸鍚﹀凡娲惧彂杩囪姹傦紝閬垮厤鍒囨崲鍒嗙被鏃堕噸澶嶈姹�
+				cateStarted: [],
 				firstScreenReady: true,
+				// 鍚庡彴鍔犺浇鏍囪锛氶灞忔覆鏌撳苟鍏抽棴loading鍚庯紝鎵嶅紑濮嬪悗鍙板姞杞藉叾浣欏垎绫�
+				bgLoaded: false,
 				// 娓叉煋浼樺寲锛氶潪棣栧睆鍒嗙被鏁版嵁缂撳啿闃熷垪锛屾壒閲忔覆鏌撳噺灏憇etData娆℃暟
 				deferredLists: [],
 				deferTimer: null,
@@ -162,6 +166,8 @@
 			let that = this;
 			that.menuTop = uni.getMenuButtonBoundingClientRect().top;
 			that.menuHeight = uni.getMenuButtonBoundingClientRect().height;
+			// 灏芥棭璁$畻椤甸潰甯冨眬楂樺害锛岄伩鍏嶉灞忔暟鎹氨缁悗鍥� height 涓� 0 鑰岀櫧灞�
+			that.infoScroll();
 			if (that.$store.getters.careBeanRate) {
 				that.$nextTick(() => {
 					that.$set(that, 'careBeanRate', that.$store.getters.careBeanRate)
@@ -176,6 +182,10 @@
 			});
 		},
 		mounted() {},
+		onReady() {
+			// 椤甸潰娓叉煋瀹屾垚鍚庡鏍镐竴娆″竷灞�灏哄锛堝惈婊氬姩鍖哄煙 scrollHeight锛�
+			this.infoScroll();
+		},
 		onHide() {
 			let that = this;
 			if (that.$store.getters.isSystemHide) {
@@ -339,6 +349,10 @@
 				that.isClicking = true;
 				that.navActive = index;
 				that.subActive = 0;
+				// loading鏈熼棿鍒囧埌灏氭湭鍙戣捣璇锋眰鐨勫垎绫绘椂锛岀珛鍗宠ˉ鍙戣姹傦紝閬垮厤loading鍗′綇
+				if (!that.cateStarted[index]) {
+					that.loadCateByIndex(index);
+				}
 				// loading鏈熼棿鍒囨崲鍒嗙被锛岃嫢鐩爣鍒嗙被宸插姞杞藉畬鎴愬垯绔嬪嵆鍏抽棴loading
 				that.checkFirstScreen(index);
 				that.$nextTick(() => {
@@ -352,6 +366,10 @@
 				let that = this;
 				that.isClicking = true;
 				that.subActive = index;
+				// 褰撳墠鍒嗙被灏氭湭鍙戣捣璇锋眰鏃惰ˉ鍙戯紝閬垮厤loading鍗′綇
+				if (!that.cateStarted[that.navActive]) {
+					that.loadCateByIndex(that.navActive);
+				}
 				that.checkFirstScreen(that.navActive);
 				that.$nextTick(() => {
 					that.scrollIntoView = 'list' + that.navActive + '_' + that.subActive;
@@ -391,21 +409,28 @@
 				let that = this;
 				that.firstScreenReady = false;
 				that.allRequestsDone = false;
+				that.bgLoaded = false;
 				that.deferredLists = [];
 				if (that.deferTimer) {
 					clearTimeout(that.deferTimer);
 					that.deferTimer = null;
 				}
+				// 鏆備笉鑰冭檻浼犲叆cid鐨勬儏鍐碉細涓�寰嬩粠绗竴涓垎绫诲紑濮嬪姞杞介灞�
+				that.navActive = 0;
+				that.subActive = 0;
 				uni.showLoading();
 				getCategoryList().then(res => {
-					that.categoryList = res.data;
+					that.categoryList = res.data || [];
 					// 閲嶇疆璁℃暟锛岄伩鍏嶉噸澶嶈繘鍏ラ〉闈㈡椂绱Н
 					that.totalGetNum = 0;
 					that.finishNum = 0;
 					that.catePending = [];
+					that.cateStarted = [];
 					that.categoryList.forEach((item, index) => {
-
 						if (item.child && item.child.length > 0) {
+							item.child.sort((a, b) => {
+								return a.sort - b.sort;
+							});
 							that.totalGetNum += item.child.length;
 							that.catePending[index] = item.child.length;
 						} else {
@@ -413,45 +438,46 @@
 							that.catePending[index] = 1;
 						}
 					})
-
-					// 鍏堟爣璁板綋鍓嶉�変腑鍒嗙被锛屽啀鍙戣捣璇锋眰
-					that.categoryList.forEach((item, index) => {
-						if (that.optionId && that.optionId == item.id) {
-							that.navActive = index;
-							that.subActive = 0;
-						}
-						if (item.child && item.child.length > 0) {
-							item.child.sort((a, b) => {
-								return a.sort - b.sort;
-							});
-							item.child.forEach((item2, index2) => {
-								if (that.optionId && that.optionId == item2.id) {
-									that.navActive = index;
-									that.subActive = index2;
-								}
-							})
-						}
+					// 鍒嗙被涓虹┖鏃剁洿鎺ュ叧闂璴oading锛岄伩鍏嶄竴鐩村仠鐣欏湪loading鎬�
+					if (!that.categoryList.length) {
+						that.firstScreenReady = true;
+						that.isLoading = false;
+						uni.hideLoading();
+						return;
+					}
+					// 棣栧睆浼樺寲锛氬厛鍙姹傜涓�涓垎绫伙紝淇濊瘉棣栧睆鏁版嵁鏈�蹇繑鍥炲苟鐩存帴娓叉煋
+					that.loadCateByIndex(that.navActive);
+					// 鍏朵綑鍒嗙被寰呴灞忔覆鏌撱�乴oading鍏抽棴鍚庯紝鐢� loadRestCategory 鍚庡彴閿欏嘲鍔犺浇
+				})
+			},
+			// 鎸夌储寮曞姞杞芥煇涓垎绫讳笅鐨勫晢鍝佹暟鎹紙鍚屼竴鍒嗙被鍙淳鍙戜竴娆★級
+			loadCateByIndex(index) {
+				let that = this;
+				let item = that.categoryList[index];
+				if (!item) return;
+				if (that.cateStarted[index]) return;
+				that.cateStarted[index] = true;
+				if (item.child && item.child.length > 0) {
+					item.child.forEach((item2, index2) => {
+						that.getAllProductList('isSub', index, index2);
 					})
-
-					const loadCate = (index) => {
-						let item = that.categoryList[index];
-						if (item.child && item.child.length > 0) {
-							item.child.forEach((item2, index2) => {
-								that.getAllProductList('isSub', index, index2);
-							})
-						} else {
-							that.getAllProductList(false, index);
-						}
-					};
-					// 褰撳墠鍒嗙被浼樺厛璇锋眰锛屼繚璇侀灞忔暟鎹渶鍏堣繑鍥�
-					loadCate(that.navActive);
-					that.categoryList.forEach((item, index) => {
-						if (index != that.navActive) {
-							loadCate(index);
-						}
-					})
-
-
+				} else {
+					that.getAllProductList(false, index);
+				}
+			},
+			// 棣栧睆娓叉煋骞跺叧闂璴oading鍚庯紝鍚庡彴閿欏嘲鍔犺浇鍏朵綑鍒嗙被锛岄伩鍏嶄笌棣栧睆鎶㈣姹�/鎶㈡覆鏌�
+			loadRestCategory() {
+				let that = this;
+				if (that.bgLoaded) return;
+				that.bgLoaded = true;
+				let delay = 0;
+				that.categoryList.forEach((item, index) => {
+					if (index == that.navActive) return;
+					// 姣忎釜鍒嗙被閿欏紑瑙﹀彂锛岄�愭鍦ㄥ悗鍙伴摵寮�锛岄伩鍏嶄竴娆℃�ч摵婊¤姹傞槦鍒�
+					delay += 50;
+					setTimeout(() => {
+						that.loadCateByIndex(index);
+					}, delay);
 				})
 			},
 			// 褰撳墠鍒嗙被鏁版嵁鍏ㄩ儴灏辩华鍚庣珛鍗冲叧闂叏灞弆oading锛屼笉蹇呯瓑寰呮墍鏈夊垎绫�
@@ -465,6 +491,8 @@
 					that.$nextTick(() => {
 						setTimeout(() => {
 							uni.hideLoading();
+							// 棣栧睆宸叉覆鏌撲笖loading宸插叧闂紝姝ゆ椂鎵嶅紑濮嬪悗鍙板姞杞藉叾浣欏垎绫�
+							that.loadRestCategory();
 						}, 50)
 					})
 				}
@@ -534,7 +562,8 @@
 			updateDimensions() {
 				const query = uni.createSelectorQuery().in(this);
 				query.select('.goodlistScroll').boundingClientRect(data => {
-					this.scrollHeight = data.height;
+					// 棣栧睆娓叉煋鍓嶈鑺傜偣鍙兘杩樹笉瀛樺湪锛岄伩鍏嶆姤閿�
+					if (data) this.scrollHeight = data.height;
 				}).exec();
 			},
 			handleScroll(e) {

--
Gitblit v1.4.0