From 74bd629e27bb16b8e07ceecc8960083d2d0748c7 Mon Sep 17 00:00:00 2001
From: Jacob <hlnie@tohours.com>
Date: 星期四, 15 十月 2026 17:58:09 +0800
Subject: [PATCH] Merge branch 'dev' into sit
---
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