From 27924672a24cf634909073f63fbd9276a4bf9ad7 Mon Sep 17 00:00:00 2001 From: lifizer <913626195@qq.com> Date: Thu, 21 May 2026 15:32:14 +0800 Subject: [PATCH] =?UTF-8?q?Refactor(=E9=A6=96=E9=A1=B5):=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=8A=A0=E8=BD=BD=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index.vue | 52 +++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/pages/home/index.vue b/pages/home/index.vue index 4500212..719fd1b 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -517,6 +517,7 @@ export default { } }, onLoad() { + console.clear() console.time() // uni.hideTabBar() const _this = this @@ -553,7 +554,11 @@ export default { this.pageToHideHandle() }, onPageScroll(e) { - this.scrollTop = e.scrollTop + if (this.pageScrollTimer) return + this.pageScrollTimer = setTimeout(() => { + this.pageScrollTimer = null + this.scrollTop = e.scrollTop + }, 50) }, onShareTimeline() { uni.updateShareMenu({ @@ -636,20 +641,24 @@ export default { }, onscroll(e) { this.scrollViewWidth = e.detail.scrollWidth - const imgs = [] - this.getElementData(`#${this.scrollView}`, res=>{ - this.setFunctionGuideData({ - imgs: this.imgs, - btnGroupPosition: '20rpx', - tipsPosition: '', - position: { - top: res.top + 'px', - left: res.left + 'px', - width: `${res.height}px`, - height: `${res.height}px` - } + if (this.scrollTimer) return + this.scrollTimer = setTimeout(() => { + this.scrollTimer = null + this.getElementData(`#${this.scrollView}`, res => { + if (!res) return + this.setFunctionGuideData({ + imgs: this.imgs, + btnGroupPosition: '20rpx', + tipsPosition: '', + position: { + top: res.top + 'px', + left: res.left + 'px', + width: `${res.height}px`, + height: `${res.height}px` + } + }) }) - }) + }, 100) }, toEle(id, imgs) { this.getElementData(`#${id}`, res=>{ @@ -739,6 +748,9 @@ export default { getHomeData({ cityName: this.cityName }).then(res => { const { success, data } = res if (success && data) { + console.timeEnd() + console.log('^^^^^^^^^^^^^^^^接口响应之后开始') + console.time() _this.$set(_this, 'banner', data.banner || []) _this.$set(_this, 'menus', data.menus || []) _this.$set(_this, 'landmarkGoodsImage', data.landmarkGoodsImage || {}) @@ -758,28 +770,32 @@ export default { _this.lotteryCanDraw = data.lotteryCanDraw || false _this.initPosterPopupState(data) if (data.bastList) { + const newBastLeftList = [] + const newBastRightList = [] for (let i = 0; i < data.bastList.length; i++) { if (i % 2 === 0) { // 店铺排名 if (i === 4 && data.hotelList.length > 0) { - _this.bastLeftList.push({ + newBastLeftList.push({ type: 'hotel', list: data.hotelList }) } - _this.bastLeftList.push(data.bastList[i]) + newBastLeftList.push(data.bastList[i]) } if (i % 2 === 1) { // 尖货专题 if (i === 3 && data.contentBest.length > 0) { - _this.bastRightList.push({ + newBastRightList.push({ type: 'swiper', list: data.contentBest }) } - _this.bastRightList.push(data.bastList[i]) + newBastRightList.push(data.bastList[i]) } } + _this.$set(_this, 'bastLeftList', newBastLeftList) + _this.$set(_this, 'bastRightList', newBastRightList) } this.$nextTick(() => { console.timeEnd()