wangfukang 1 month ago
parent
commit
90c1b2d62b
  1. 114
      pages/index/index.vue

114
pages/index/index.vue

@ -370,7 +370,7 @@
<view class="empty-delivery-title">暂时没有可抢订单</view> <view class="empty-delivery-title">暂时没有可抢订单</view>
<view class="empty-delivery-desc">可以切换分类或调整筛选条件新的校园订单会在这里出现</view> <view class="empty-delivery-desc">可以切换分类或调整筛选条件新的校园订单会在这里出现</view>
</view> </view>
<view class="list-1" v-for="(item,index) in deliveryItem" :key="index" <view class="list-1" v-for="(item,index) in deliveryItem" :key="item.deliveryKey"
@tap="productDetail(item)"> @tap="productDetail(item)">
<view class="daoda-time-row"> <view class="daoda-time-row">
<view class="appointment-delivery-tag" v-if="item.appointmentDelivery == 1"> <view class="appointment-delivery-tag" v-if="item.appointmentDelivery == 1">
@ -382,16 +382,16 @@
</view> </view>
<view class="order-page"> <view class="order-page">
<view class="maotou" v-if="item.deliveryType == 1 && !item.workerId"> <view class="maotou" v-if="item.deliveryType == 1 && !item.workerId">
外卖 {{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}}
</view> </view>
<view class="maotou1" v-if="item.deliveryType == 2"> <view class="maotou1" v-if="item.deliveryType == 2">
代取快递 {{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}}
</view> </view>
<view class="maotou2" v-if="item.deliveryType == 3"> <view class="maotou2" v-if="item.deliveryType == 3">
代跑腿 {{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}}
</view> </view>
<view class="maotou3" v-if="item.workerId"> <view class="maotou3" v-if="item.workerId">
指派单 {{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}}
</view> </view>
<view class="shangjia"> <view class="shangjia">
<text <text
@ -400,8 +400,8 @@
style="width: 32rpx;height: 30rpx;font-weight: 700;font-size: 20rpx;color: #fff;text-align: center;background: #00BFFF;border-radius: 10rpx;margin: 20rpx 0 0 10rpx;line-height: 30rpx;"> style="width: 32rpx;height: 30rpx;font-weight: 700;font-size: 20rpx;color: #fff;text-align: center;background: #00BFFF;border-radius: 10rpx;margin: 20rpx 0 0 10rpx;line-height: 30rpx;">
</view> </view>
<view v-else style="font-weight: 700;"> <view v-else style="font-weight: 700;padding-left: 30rpx;">
{{item.allCount ? item.allCount : 0}} {{item.allCount ? item.allCount : 0}}
</view> </view>
</view> </view>
<view class="shangpin"> <view class="shangpin">
@ -441,17 +441,15 @@
</view> </view>
</view> </view>
</view> </view>
<view class="yongjin"> <view class="yongjin" v-if="(item.isBig !=null && item.isBig == 1) || item.deliveryFeeMarketplace > 0">
<view style="width: 50%;color: #777;padding-left: 4%;display: flex;"> <view style="width: 50%;color: #777;padding-left: 4%;display: flex;">
配送佣金
<view class="chaoda" v-if="item.isBig !=null && item.isBig == 1"> <view class="chaoda" v-if="item.isBig !=null && item.isBig == 1">
超大/超重 超大/超重
</view> </view>
</view> </view>
<view style="font-weight: 700;width: 50%;text-align: right;"> <view style="font-weight: 700;width: 50%;text-align: right;">
{{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}}
<text style="color: #777;font-size: 22rpx;" <text style="color: #777;font-size: 22rpx;"
v-if="item.deliveryFeeMarketplace > 0">包含{{item.deliveryFeeMarketplace}}平台佣金</text> v-if="item.deliveryFeeMarketplace > 0">包含{{item.deliveryFeeMarketplace}}平台奖励佣金</text>
</view> </view>
</view> </view>
<view class="beizhu" v-if="item.remark != null && item.remark != ''"> <view class="beizhu" v-if="item.remark != null && item.remark != ''">
@ -535,8 +533,8 @@
<view class="product-popup-title">商品详情</view> <view class="product-popup-title">商品详情</view>
<view class="product-popup-subtitle">请核对商品规格和数量</view> <view class="product-popup-subtitle">请核对商品规格和数量</view>
</view> </view>
<view class="product-popup-list" v-if="productData.goodsList != null && productData.goodsList.length > 0"> <view class="product-popup-list" v-if="productGoodsList.length > 0">
<view class="product-popup-card" v-for="(item1,index1) in productData.goodsList" :key="index1"> <view class="product-popup-card" v-for="(item1,index1) in productGoodsList" :key="index1">
<view class="product-popup-img"> <view class="product-popup-img">
<img :src="item1.productPicture" alt=""> <img :src="item1.productPicture" alt="">
</view> </view>
@ -744,7 +742,8 @@
kuaidiCount: 0, kuaidiCount: 0,
paotuiCount: 0, paotuiCount: 0,
homeReminders: {}, homeReminders: {},
productData: [], productData: {},
productGoodsList: [],
zhipaiCount: 0, zhipaiCount: 0,
searchForm: { searchForm: {
hallOnly: true, hallOnly: true,
@ -783,6 +782,7 @@
getshopArea: [], getshopArea: [],
putshopArea: [], putshopArea: [],
totalPages: 1, totalPages: 1,
deliveryQueryVersion: 0,
swipeOrderLowPerf: false, swipeOrderLowPerf: false,
swipeOrderDefaultStyle: { swipeOrderDefaultStyle: {
progress: 'transform: translate3d(0, 0, 0) scaleX(0); transition: transform 0.14s ease-out;', progress: 'transform: translate3d(0, 0, 0) scaleX(0); transition: transform 0.14s ease-out;',
@ -927,12 +927,22 @@
}) })
} }
}, },
onHide() {
this.closeProductPopup()
},
onReady() { onReady() {
// //
setTimeout(() => { setTimeout(() => {
this.refreshDaimaiStickyPosition() this.refreshDaimaiStickyPosition()
}, 500); }, 500);
}, },
onUnload() {
this.closeProductPopup()
if (this.deliveryTimer) {
clearInterval(this.deliveryTimer);
this.deliveryTimer = null;
}
},
methods: { methods: {
setTabBarVisible(visible) { setTabBarVisible(visible) {
this.isTabBarVisible = visible this.isTabBarVisible = visible
@ -1107,6 +1117,7 @@
this.searchForm.getAreaId = "" this.searchForm.getAreaId = ""
this.searchForm.putAreaId = "" this.searchForm.putAreaId = ""
this.searchForm.order = "" this.searchForm.order = ""
this.resetDeliveryQuery()
this.getDelivery() this.getDelivery()
this.$forceUpdate() this.$forceUpdate()
}, },
@ -1121,23 +1132,56 @@
}, 400); }, 400);
}, },
productDetail(item) { productDetail(item) {
if (this._isSwipingOrderTap) {
this._isSwipingOrderTap = false
return
}
if (!item || item.deliveryType != 1) return
this.productData = item; this.productData = item;
this.productGoodsList = Array.isArray(item.goodsList) ? item.goodsList : []
this.$refs.productPopup.open() this.$refs.productPopup.open()
}, },
closeProductPopup() {
if (this.$refs.productPopup && this.$refs.productPopup.close) {
this.$refs.productPopup.close()
}
this.productData = {}
this.productGoodsList = []
},
getSwipeProgress(item, index) { getSwipeProgress(item, index) {
if (!item) return 0
if (this.swipeOrder.id === item.id && this.swipeOrder.index === index) { if (this.swipeOrder.id === item.id && this.swipeOrder.index === index) {
return this.swipeOrder.progress return this.swipeOrder.progress
} }
return 0 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) { isSwipeOrderActive(item, index) {
if (!item) return false
return this.swipeOrder.id === item.id && this.swipeOrder.index === index && this.swipeOrder.progress > 0 return this.swipeOrder.id === item.id && this.swipeOrder.index === index && this.swipeOrder.progress > 0
}, },
// //
startSwipeOrder(event, item, index) { startSwipeOrder(event, item, index) {
if (!item || item.id === undefined || item.id === null) return
if (!this.requireLogin(0)) return if (!this.requireLogin(0)) return
const touch = event.touches && event.touches[0] const touch = event.touches && event.touches[0]
if (!touch) return if (!touch) return
this._isSwipingOrderTap = false
this._swipeOrderProgress = 0 this._swipeOrderProgress = 0
this._swipeOrderLastRenderTime = 0 this._swipeOrderLastRenderTime = 0
this.swipeOrder = { this.swipeOrder = {
@ -1165,6 +1209,9 @@
const trackWidth = this.swipeOrder.trackWidth || this.swipeOrderBaseWidth || 1 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))
if (progress > 3) {
this._isSwipingOrderTap = true
}
this._swipeOrderProgress = progress this._swipeOrderProgress = progress
const now = Date.now() const now = Date.now()
const frameGap = this.swipeOrderFrameGap || 16 const frameGap = this.swipeOrderFrameGap || 16
@ -1196,6 +1243,10 @@
resetSwipeOrder() { resetSwipeOrder() {
this._swipeOrderProgress = 0 this._swipeOrderProgress = 0
this._swipeOrderLastRenderTime = 0 this._swipeOrderLastRenderTime = 0
clearTimeout(this._swipeOrderTapTimer)
this._swipeOrderTapTimer = setTimeout(() => {
this._isSwipingOrderTap = false
}, 300)
this.swipeOrder = { this.swipeOrder = {
id: '', id: '',
index: -1, index: -1,
@ -1496,13 +1547,22 @@
}, },
getDelivery() { getDelivery() {
let that = this 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.waimaiCount = 0
that.kuaidiCount = 0 that.kuaidiCount = 0
that.paotuiCount = 0 that.paotuiCount = 0
that.zhipaiCount = 0 that.zhipaiCount = 0
that.adList = [] that.adList = []
that.searchForm.userId = uni.getStorageSync('id') || that.searchForm.userId || '' 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'; that.loadStatus = 'nomore';
if (res.code == 200) { if (res.code == 200) {
that.homeReminders = res.result.homeReminders || {} that.homeReminders = res.result.homeReminders || {}
@ -1513,10 +1573,11 @@
that.adList.push(that.mallAds[i]) that.adList.push(that.mallAds[i])
} }
} }
if (that.searchForm.pageNum == 1) { const records = that.normalizeDeliveryRecords(res.result.records, requestPageNum)
that.deliveryItem = res.result.records; if (requestPageNum == 1) {
that.deliveryItem = records;
} else { } else {
that.deliveryItem = [...that.deliveryItem, ...res.result.records] that.deliveryItem = [...that.deliveryItem, ...records]
} }
if (res.result.orderCount != null && res.result.orderCount.length > 0) { if (res.result.orderCount != null && res.result.orderCount.length > 0) {
for (let i = 0; i < res.result.orderCount.length; i++) { for (let i = 0; i < res.result.orderCount.length; i++) {
@ -1612,6 +1673,7 @@
this.areaName = item.title this.areaName = item.title
this.areaKeyword = '' this.areaKeyword = ''
this.searchForm.regionId = item.id this.searchForm.regionId = item.id
this.resetDeliveryQuery()
this.getDelivery(); this.getDelivery();
this.getShopArea(); this.getShopArea();
let that = this let that = this
@ -1731,7 +1793,7 @@
this.checkYongjin = false this.checkYongjin = false
this.searchForm.order = '' this.searchForm.order = ''
} }
this.searchForm.pageNum = 1 this.resetDeliveryQuery()
this.getDelivery(); this.getDelivery();
}, },
// //
@ -1753,6 +1815,7 @@
// //
checkTab1(type) { checkTab1(type) {
this.checked = type this.checked = type
this.resetDeliveryQuery()
if (type == 'waimai') { if (type == 'waimai') {
this.searchForm.deliveryType = 1 this.searchForm.deliveryType = 1
this.searchForm.waimaiData = this.waimailistData; this.searchForm.waimaiData = this.waimailistData;
@ -1794,12 +1857,6 @@
phoneNumber: phone phoneNumber: phone
}); });
}, },
//
onUnload() {
if (this.deliveryTimer) {
clearInterval(this.deliveryTimer);
}
},
// //
checkAdd() { checkAdd() {
this.isgetArea = !this.isgetArea this.isgetArea = !this.isgetArea
@ -1813,6 +1870,9 @@
let that = this; let that = this;
this.isTabBarVisible = true this.isTabBarVisible = true
this.lastIndex = this.currentIndex this.lastIndex = this.currentIndex
if (index != 0) {
this.closeProductPopup()
}
if(index != 2){ if(index != 2){
this.currentIndex = index this.currentIndex = index
} }
@ -3434,7 +3494,7 @@
font-size: 24rpx; font-size: 24rpx;
} }
.maotou1 { .maotou1 {
width: 130rpx; width: 90rpx;
background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/6f9117df70b048e2b35badb5d3338706.png') no-repeat; background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/6f9117df70b048e2b35badb5d3338706.png') no-repeat;
height: 74rpx; height: 74rpx;
background-size: 100%; background-size: 100%;
@ -3964,7 +4024,7 @@
.beizhu { .beizhu {
width: 95%; width: 95%;
margin: 0 auto; margin: 20rpx auto;
background: rgba(255, 117, 88, 0.08); background: rgba(255, 117, 88, 0.08);
border: 1px solid rgba(255, 117, 88, 0.12); border: 1px solid rgba(255, 117, 88, 0.12);
border-radius: 20rpx; border-radius: 20rpx;

Loading…
Cancel
Save