wangfukang 4 weeks ago
parent
commit
f0c75e29fd
  1. 34
      pages/index/index.vue

34
pages/index/index.vue

@ -425,14 +425,14 @@
@touchend.stop="endSwipeOrder(item,index)" @touchend.stop="endSwipeOrder(item,index)"
@touchcancel.stop="resetSwipeOrder"> @touchcancel.stop="resetSwipeOrder">
<view class="qiangdan-progress" <view class="qiangdan-progress"
:style="{'width': getSwipeProgress(item,index) + '%'}"></view> :style="swipeOrder.id === item.id && swipeOrder.index === index ? swipeOrder.progressStyle : swipeOrderDefaultStyle.progress"></view>
<view class="qiangdan-text"> <view class="qiangdan-text">
<text v-if="!isSwipeOrderActive(item,index)">向右滑动抢单</text> <text v-if="swipeOrder.id !== item.id || swipeOrder.index !== index || swipeOrder.progress <= 0">向右滑动抢单</text>
<text v-else-if="getSwipeProgress(item,index) < 92">继续滑动确认</text> <text v-else-if="swipeOrder.progress < 92">继续滑动确认</text>
<text v-else>松手接单</text> <text v-else>松手接单</text>
</view> </view>
<view class="qiangdan-thumb" <view class="qiangdan-thumb"
:style="{'left': getSwipeProgress(item,index) + '%','transform':'translateX(-' + getSwipeProgress(item,index) + '%)'}"> :style="swipeOrder.id === item.id && swipeOrder.index === index ? swipeOrder.thumbStyle : swipeOrderDefaultStyle.thumb">
<text></text> <text></text>
</view> </view>
</view> </view>
@ -693,12 +693,18 @@
checkYongjin: false, checkYongjin: false,
getshopArea: [], getshopArea: [],
putshopArea: [], putshopArea: [],
swipeOrderDefaultStyle: {
progress: 'width: 0%;',
thumb: 'left: 0%; transform: translateX(-0%);'
},
swipeOrder: { swipeOrder: {
id: '', id: '',
index: -1, index: -1,
startX: 0, startX: 0,
startProgress: 0, startProgress: 0,
progress: 0, progress: 0,
progressStyle: 'width: 0%;',
thumbStyle: 'left: 0%; transform: translateX(-0%);',
trackWidth: 0, trackWidth: 0,
confirmed: false confirmed: false
} }
@ -842,6 +848,7 @@
// sticky offsetstatusBarHeight + 40px // sticky offsetstatusBarHeight + 40px
const info = uni.getSystemInfoSync(); const info = uni.getSystemInfoSync();
this.navBarHeight = info.statusBarHeight; this.navBarHeight = info.statusBarHeight;
this.swipeOrderBaseWidth = info.windowWidth * 0.86;
}, },
clearCheck() { clearCheck() {
this.checkYongjin = false this.checkYongjin = false
@ -885,7 +892,9 @@
startX: touch.clientX, startX: touch.clientX,
startProgress: 0, startProgress: 0,
progress: 0, progress: 0,
trackWidth: 0, progressStyle: 'width: 0%;',
thumbStyle: 'left: 0%; transform: translateX(-0%);',
trackWidth: this.swipeOrderBaseWidth || 0,
confirmed: false confirmed: false
} }
this.$nextTick(() => { this.$nextTick(() => {
@ -899,16 +908,16 @@
moveSwipeOrder(event) { moveSwipeOrder(event) {
const touch = event.touches && event.touches[0] const touch = event.touches && event.touches[0]
if (!touch || this.swipeOrder.id === '') return 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 deltaX = Math.max(0, touch.clientX - this.swipeOrder.startX)
const progress = Math.min(100, Math.round(deltaX / (trackWidth * 0.72) * 100)) const progress = Math.min(100, Math.round(deltaX / (trackWidth * 0.72) * 100))
this.swipeOrder.progress = progress this.setSwipeOrderProgress(progress)
}, },
endSwipeOrder(item, index) { endSwipeOrder(item, index) {
if (this.swipeOrder.id !== item.id || this.swipeOrder.index !== index) return if (this.swipeOrder.id !== item.id || this.swipeOrder.index !== index) return
if (this.swipeOrder.progress >= 92 && !this.swipeOrder.confirmed) { if (this.swipeOrder.progress >= 92 && !this.swipeOrder.confirmed) {
this.swipeOrder.confirmed = true this.swipeOrder.confirmed = true
this.swipeOrder.progress = 100 this.setSwipeOrderProgress(100)
this.getOrder(item, index) this.getOrder(item, index)
return return
} }
@ -921,10 +930,19 @@
startX: 0, startX: 0,
startProgress: 0, startProgress: 0,
progress: 0, progress: 0,
progressStyle: 'width: 0%;',
thumbStyle: 'left: 0%; transform: translateX(-0%);',
trackWidth: 0, trackWidth: 0,
confirmed: false 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() {}, noop() {},
getOrder(item, index) { getOrder(item, index) {
let that = this let that = this

Loading…
Cancel
Save