From f0c75e29fd44d2116434681c9be42b5d64dffa03 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Tue, 12 May 2026 14:29:45 +0800 Subject: [PATCH] 1 --- pages/index/index.vue | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 3ce76c3..c231955 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -425,14 +425,14 @@ @touchend.stop="endSwipeOrder(item,index)" @touchcancel.stop="resetSwipeOrder"> + :style="swipeOrder.id === item.id && swipeOrder.index === index ? swipeOrder.progressStyle : swipeOrderDefaultStyle.progress"> - 向右滑动抢单 - 继续滑动确认 + 向右滑动抢单 + 继续滑动确认 松手接单 + :style="swipeOrder.id === item.id && swipeOrder.index === index ? swipeOrder.thumbStyle : swipeOrderDefaultStyle.thumb"> @@ -693,12 +693,18 @@ checkYongjin: false, getshopArea: [], putshopArea: [], + swipeOrderDefaultStyle: { + progress: 'width: 0%;', + thumb: 'left: 0%; transform: translateX(-0%);' + }, swipeOrder: { id: '', index: -1, startX: 0, startProgress: 0, progress: 0, + progressStyle: 'width: 0%;', + thumbStyle: 'left: 0%; transform: translateX(-0%);', trackWidth: 0, confirmed: false } @@ -842,6 +848,7 @@ // 计算导航栏高度用于sticky offset:statusBarHeight + 40px内容区 const info = uni.getSystemInfoSync(); this.navBarHeight = info.statusBarHeight; + this.swipeOrderBaseWidth = info.windowWidth * 0.86; }, clearCheck() { this.checkYongjin = false @@ -885,7 +892,9 @@ startX: touch.clientX, startProgress: 0, progress: 0, - trackWidth: 0, + progressStyle: 'width: 0%;', + thumbStyle: 'left: 0%; transform: translateX(-0%);', + trackWidth: this.swipeOrderBaseWidth || 0, confirmed: false } this.$nextTick(() => { @@ -899,16 +908,16 @@ moveSwipeOrder(event) { const touch = event.touches && event.touches[0] if (!touch || this.swipeOrder.id === '') return - const trackWidth = this.swipeOrder.trackWidth || uni.getSystemInfoSync().windowWidth * 0.86 + 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)) - this.swipeOrder.progress = progress + this.setSwipeOrderProgress(progress) }, endSwipeOrder(item, index) { if (this.swipeOrder.id !== item.id || this.swipeOrder.index !== index) return if (this.swipeOrder.progress >= 92 && !this.swipeOrder.confirmed) { this.swipeOrder.confirmed = true - this.swipeOrder.progress = 100 + this.setSwipeOrderProgress(100) this.getOrder(item, index) return } @@ -921,10 +930,19 @@ startX: 0, startProgress: 0, progress: 0, + progressStyle: 'width: 0%;', + thumbStyle: 'left: 0%; transform: translateX(-0%);', trackWidth: 0, confirmed: false } }, + setSwipeOrderProgress(progress) { + if (this.swipeOrder.progress === progress) return + const progressValue = progress + '%' + this.swipeOrder.progress = progress + this.swipeOrder.progressStyle = 'width: ' + progressValue + ';' + this.swipeOrder.thumbStyle = 'left: ' + progressValue + '; transform: translateX(-' + progressValue + ');' + }, noop() {}, getOrder(item, index) { let that = this