From 90c1b2d62bb964b73dfe436db5a8b2a84de77d60 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sat, 27 Jun 2026 18:15:39 +0800 Subject: [PATCH] 1 --- pages/index/index.vue | 114 ++++++++++++++++++++++++++++++++---------- 1 file changed, 87 insertions(+), 27 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 5289932..80d2656 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -370,7 +370,7 @@ 暂时没有可抢订单 可以切换分类或调整筛选条件,新的校园订单会在这里出现 - @@ -382,16 +382,16 @@ - 外卖 + ¥{{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}} - 代取快递 + ¥{{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}} - 代跑腿 + ¥{{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}} - 指派单 + ¥{{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}} - - {{item.allCount ? item.allCount : 0}}件 + + 共{{item.allCount ? item.allCount : 0}}件 @@ -441,17 +441,15 @@ - + - 配送佣金 超大/超重 - ¥{{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}} (包含¥{{item.deliveryFeeMarketplace}}平台佣金) + v-if="item.deliveryFeeMarketplace > 0">(包含¥{{item.deliveryFeeMarketplace}}平台奖励佣金) @@ -535,8 +533,8 @@ 商品详情 请核对商品规格和数量 - - + + @@ -744,7 +742,8 @@ kuaidiCount: 0, paotuiCount: 0, homeReminders: {}, - productData: [], + productData: {}, + productGoodsList: [], zhipaiCount: 0, searchForm: { hallOnly: true, @@ -783,6 +782,7 @@ getshopArea: [], putshopArea: [], totalPages: 1, + deliveryQueryVersion: 0, swipeOrderLowPerf: false, swipeOrderDefaultStyle: { progress: 'transform: translate3d(0, 0, 0) scaleX(0); transition: transform 0.14s ease-out;', @@ -927,12 +927,22 @@ }) } }, + onHide() { + this.closeProductPopup() + }, onReady() { // 记录分类栏相对页面的偏移量,用于上滑检测 setTimeout(() => { this.refreshDaimaiStickyPosition() }, 500); }, + onUnload() { + this.closeProductPopup() + if (this.deliveryTimer) { + clearInterval(this.deliveryTimer); + this.deliveryTimer = null; + } + }, methods: { setTabBarVisible(visible) { this.isTabBarVisible = visible @@ -1107,6 +1117,7 @@ this.searchForm.getAreaId = "" this.searchForm.putAreaId = "" this.searchForm.order = "" + this.resetDeliveryQuery() this.getDelivery() this.$forceUpdate() }, @@ -1121,23 +1132,56 @@ }, 400); }, productDetail(item) { + if (this._isSwipingOrderTap) { + this._isSwipingOrderTap = false + return + } + if (!item || item.deliveryType != 1) return this.productData = item; + this.productGoodsList = Array.isArray(item.goodsList) ? item.goodsList : [] this.$refs.productPopup.open() }, + closeProductPopup() { + if (this.$refs.productPopup && this.$refs.productPopup.close) { + this.$refs.productPopup.close() + } + this.productData = {} + this.productGoodsList = [] + }, getSwipeProgress(item, index) { + if (!item) return 0 if (this.swipeOrder.id === item.id && this.swipeOrder.index === index) { return this.swipeOrder.progress } return 0 }, + resetDeliveryQuery() { + this.deliveryQueryVersion++ + this.searchForm.pageNum = 1 + this.totalPages = 1 + this.deliveryItem = [] + this.resetSwipeOrder() + }, + normalizeDeliveryRecords(records, pageNum) { + if (!Array.isArray(records)) return [] + return records.filter(item => item && typeof item === 'object').map((item, index) => { + return { + ...item, + deliveryKey: item.id !== undefined && item.id !== null ? String(item.id) : (pageNum + '-' + index) + } + }) + }, isSwipeOrderActive(item, index) { + if (!item) return false return this.swipeOrder.id === item.id && this.swipeOrder.index === index && this.swipeOrder.progress > 0 }, //滑动开始 startSwipeOrder(event, item, index) { + if (!item || item.id === undefined || item.id === null) return if (!this.requireLogin(0)) return const touch = event.touches && event.touches[0] if (!touch) return + this._isSwipingOrderTap = false this._swipeOrderProgress = 0 this._swipeOrderLastRenderTime = 0 this.swipeOrder = { @@ -1165,6 +1209,9 @@ const trackWidth = this.swipeOrder.trackWidth || this.swipeOrderBaseWidth || 1 const deltaX = Math.max(0, touch.clientX - this.swipeOrder.startX) const progress = Math.min(100, Math.round(deltaX / (trackWidth * 0.72) * 100)) + if (progress > 3) { + this._isSwipingOrderTap = true + } this._swipeOrderProgress = progress const now = Date.now() const frameGap = this.swipeOrderFrameGap || 16 @@ -1196,6 +1243,10 @@ resetSwipeOrder() { this._swipeOrderProgress = 0 this._swipeOrderLastRenderTime = 0 + clearTimeout(this._swipeOrderTapTimer) + this._swipeOrderTapTimer = setTimeout(() => { + this._isSwipingOrderTap = false + }, 300) this.swipeOrder = { id: '', index: -1, @@ -1496,13 +1547,22 @@ }, getDelivery() { let that = this + const requestVersion = that.deliveryQueryVersion + const requestPageNum = that.searchForm.pageNum + const requestForm = { + ...that.searchForm, + waimaiData: [...(that.searchForm.waimaiData || [])], + kuaidiData: [...(that.searchForm.kuaidiData || [])] + } that.waimaiCount = 0 that.kuaidiCount = 0 that.paotuiCount = 0 that.zhipaiCount = 0 that.adList = [] that.searchForm.userId = uni.getStorageSync('id') || that.searchForm.userId || '' - this.tui.request("/mall/delivery/page", "POST", this.searchForm, false, false).then((res) => { + requestForm.userId = that.searchForm.userId + this.tui.request("/mall/delivery/page", "POST", requestForm, false, false).then((res) => { + if (requestVersion !== that.deliveryQueryVersion) return that.loadStatus = 'nomore'; if (res.code == 200) { that.homeReminders = res.result.homeReminders || {} @@ -1513,10 +1573,11 @@ that.adList.push(that.mallAds[i]) } } - if (that.searchForm.pageNum == 1) { - that.deliveryItem = res.result.records; + const records = that.normalizeDeliveryRecords(res.result.records, requestPageNum) + if (requestPageNum == 1) { + that.deliveryItem = records; } else { - that.deliveryItem = [...that.deliveryItem, ...res.result.records] + that.deliveryItem = [...that.deliveryItem, ...records] } if (res.result.orderCount != null && res.result.orderCount.length > 0) { for (let i = 0; i < res.result.orderCount.length; i++) { @@ -1612,6 +1673,7 @@ this.areaName = item.title this.areaKeyword = '' this.searchForm.regionId = item.id + this.resetDeliveryQuery() this.getDelivery(); this.getShopArea(); let that = this @@ -1731,7 +1793,7 @@ this.checkYongjin = false this.searchForm.order = '' } - this.searchForm.pageNum = 1 + this.resetDeliveryQuery() this.getDelivery(); }, // 获取用户位置 @@ -1753,6 +1815,7 @@ //配送单列表切换 checkTab1(type) { this.checked = type + this.resetDeliveryQuery() if (type == 'waimai') { this.searchForm.deliveryType = 1 this.searchForm.waimaiData = this.waimailistData; @@ -1794,12 +1857,6 @@ phoneNumber: phone }); }, - // 页面卸载时清除定时器 - onUnload() { - if (this.deliveryTimer) { - clearInterval(this.deliveryTimer); - } - }, //筛选条件 checkAdd() { this.isgetArea = !this.isgetArea @@ -1813,6 +1870,9 @@ let that = this; this.isTabBarVisible = true this.lastIndex = this.currentIndex + if (index != 0) { + this.closeProductPopup() + } if(index != 2){ this.currentIndex = index } @@ -3434,7 +3494,7 @@ font-size: 24rpx; } .maotou1 { - width: 130rpx; + width: 90rpx; background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/6f9117df70b048e2b35badb5d3338706.png') no-repeat; height: 74rpx; background-size: 100%; @@ -3964,7 +4024,7 @@ .beizhu { width: 95%; - margin: 0 auto; + margin: 20rpx auto; background: rgba(255, 117, 88, 0.08); border: 1px solid rgba(255, 117, 88, 0.12); border-radius: 20rpx;