|
|
@ -6,35 +6,38 @@ |
|
|
|
<!-- 搜索框 --> |
|
|
|
<view style="background-color: #fff; padding: 12rpx 20rpx 0rpx; "> |
|
|
|
<uv-search placeholder="搜索商品名" v-model="keyword" :showAction="false" actionText="" height="80rpx" animation |
|
|
|
bgColor="#F5F5F5" inputAlign="center" color="#000" placeholderColor="#979797" |
|
|
|
searchIconSize="50rpx"></uv-search> |
|
|
|
bgColor="#F5F5F5" inputAlign="center" color="#000" placeholderColor="#979797" |
|
|
|
searchIconSize="50rpx"></uv-search> |
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 订单筛选 --> |
|
|
|
<view class="tabs"> |
|
|
|
<uv-tabs :list="tabs" :activeStyle="{ color: '#019245'}" lineColor="#019245" :scrollable="false" |
|
|
|
:inactiveStyle="{color: 'black'}" lineHeight="6rpx" lineWidth="55rpx" :current="current" |
|
|
|
@click="clickTabs" /> |
|
|
|
:inactiveStyle="{color: 'black'}" lineHeight="6rpx" lineWidth="55rpx" :current="current" |
|
|
|
@click="clickTabs" /> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 团餐列表 --> |
|
|
|
<view class="group-meal-list" v-if="identity"> |
|
|
|
<view class="meal-item" v-for="(meal, index) in leaderOrderList" :key="meal.id"> |
|
|
|
<view class="meal-item" v-for="(meal, index) in mealList" :key="meal.id"> |
|
|
|
<view class="meal-name">{{ meal.title }}</view> |
|
|
|
<view class="meal-price">本单佣金合计: <text class="price-value">¥{{ levelInfo.amount || '0.00' }}</text></view> |
|
|
|
<view class="meal-price">本单佣金合计: <text class="price-value">¥{{ levelInfo.amount || '0.00' }}</text> |
|
|
|
</view> |
|
|
|
<view class="meal-action"> |
|
|
|
<button class="order-btn" @tap="viewOrder(meal)">查看订单</button> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view style="margin-top: 200rpx; min-width: 700rpx;"> |
|
|
|
<uv-empty mode="order" v-if="mealList.length == 0" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 订单列表 --> |
|
|
|
<view class="order-list" v-else> |
|
|
|
<OrderItem v-for="(order, index) in memberOrderList" :key="order.id" :order="order" @cancel="handleCancelOrder" |
|
|
|
@pick="handlePickOrder" |
|
|
|
@pay="handlePayOrder" @click="goToOrderDetail(order)" /> |
|
|
|
<OrderItem v-for="(order, index) in orderList" :key="order.id" :order="order" @cancel="handleCancelOrder" |
|
|
|
@pick="handlePickOrder" @pay="handlePayOrder" @click="goToOrderDetail(order)" /> |
|
|
|
<view style="margin-top: 200rpx; min-width: 700rpx;"> |
|
|
|
<uv-empty mode="order" v-if="memberOrderList.length == 0"></uv-empty> |
|
|
|
<uv-empty mode="order" v-if="orderList.length == 0" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
@ -119,7 +122,7 @@ |
|
|
|
import tabber from '@/components/base/tabbar.vue' |
|
|
|
import customerServicePopup from '@/components/config/customerServicePopup.vue' |
|
|
|
import OrderItem from '@/components/order/OrderItem.vue' |
|
|
|
// import { mockOrders, mockGroupMeals} from '@/static/js/mockOrders.js' |
|
|
|
|
|
|
|
export default { |
|
|
|
mixins: [mixinsList, mixinsOrder], |
|
|
|
components: { |
|
|
@ -127,11 +130,21 @@ |
|
|
|
customerServicePopup, |
|
|
|
OrderItem |
|
|
|
}, |
|
|
|
computed: {}, |
|
|
|
computed: { |
|
|
|
orderList() { |
|
|
|
return this.memberOrderList.filter(order => order.status == this.current) |
|
|
|
}, |
|
|
|
mealList() { |
|
|
|
return this.leaderOrderList.filter(order => order.status == this.current) |
|
|
|
}, |
|
|
|
tabs() { |
|
|
|
return this.identity ? this.tabMeal : this.tabOrder |
|
|
|
} |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
keyword: '', |
|
|
|
tabs: [{ |
|
|
|
tabOrder: [{ |
|
|
|
name: '待支付' |
|
|
|
}, |
|
|
|
{ |
|
|
@ -147,58 +160,50 @@ |
|
|
|
name: '已完成' |
|
|
|
} |
|
|
|
], |
|
|
|
statusMap: { |
|
|
|
0: 'pending', // 待支付 |
|
|
|
1: 'processing', // 待出餐 |
|
|
|
2: 'shipping', // 送餐中 |
|
|
|
3: 'delivered', // 待取餐 |
|
|
|
4: 'completed' // 已完成 |
|
|
|
tabMeal: [{ |
|
|
|
name: '待出餐' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: '已出餐' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: '待取餐' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: '已完成' |
|
|
|
} |
|
|
|
], |
|
|
|
current: 0, |
|
|
|
// mixinsListApi: 'queryLeaderOrderList', |
|
|
|
orderList: [], |
|
|
|
memberOrderList: [], |
|
|
|
leaderOrderList: [], |
|
|
|
groupMeals: [], |
|
|
|
identity: uni.getStorageSync('identity') |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(args) { |
|
|
|
// console.log(6666); |
|
|
|
|
|
|
|
// console.log('222',this.$store.state.levelInfo); |
|
|
|
|
|
|
|
// if (args.status) { |
|
|
|
// // 因为传过来的是状态 所以需要 遍历Map找到下标 |
|
|
|
// for (const key in this.statusMap) { |
|
|
|
// if (this.statusMap[key] === args.status) { |
|
|
|
// this.current = Number(key) |
|
|
|
// break |
|
|
|
// } |
|
|
|
// } |
|
|
|
// this.clickTabs({ |
|
|
|
// index: this.current |
|
|
|
// }) |
|
|
|
// } |
|
|
|
|
|
|
|
// 加载模拟订单数据 |
|
|
|
// this.loadMockOrders() |
|
|
|
// this.filterOrdersByStatus(this.current) |
|
|
|
this.getData() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getData() { |
|
|
|
this.$api('queryMemberOrderList', {}, res => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.memberOrderList = res.result.records |
|
|
|
} |
|
|
|
}) |
|
|
|
this.$api('queryLeaderOrderList', {}, res => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.leaderOrderList = res.result.records |
|
|
|
|
|
|
|
} |
|
|
|
uni.showLoading({ |
|
|
|
title: '加载中' |
|
|
|
}) |
|
|
|
if (!this.identity) { |
|
|
|
this.$api('queryMemberOrderList', {}, res => { |
|
|
|
uni.hideLoading() |
|
|
|
if (res.code == 200) { |
|
|
|
this.memberOrderList = res.result.records |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
else { |
|
|
|
this.$api('queryLeaderOrderList', {}, res => { |
|
|
|
uni.hideLoading() |
|
|
|
if (res.code == 200) { |
|
|
|
this.leaderOrderList = res.result.records |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
//点击tab栏 |
|
|
|
clickTabs({ |
|
|
@ -209,12 +214,8 @@ |
|
|
|
} else { |
|
|
|
this.queryParams.state = index - 1 |
|
|
|
} |
|
|
|
// 关闭请求 |
|
|
|
// this.getData() |
|
|
|
// console.log('点击了tab栏', index); |
|
|
|
|
|
|
|
// 模拟根据状态筛选订单 |
|
|
|
this.filterOrdersByStatus(index) |
|
|
|
|
|
|
|
this.current = index |
|
|
|
}, |
|
|
|
// 跳转到新订单详情页 |
|
|
|
goToOrderDetail(order) { |
|
|
@ -235,106 +236,106 @@ |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 根据状态筛选订单 |
|
|
|
filterOrdersByStatus(index) { |
|
|
|
this.loadMockOrders() // 先重置数据 |
|
|
|
// filterOrdersByStatus(index) { |
|
|
|
// this.loadMockOrders() // 先重置数据 |
|
|
|
|
|
|
|
// if (index === 0) return // 全部订单不需要筛选 |
|
|
|
const targetStatus = this.statusMap[index] |
|
|
|
if (targetStatus) { |
|
|
|
this.orderList = this.orderList.filter(order => order.status === targetStatus) |
|
|
|
this.groupMeals = this.groupMeals.filter(meal => meal.status === targetStatus) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 处理取消订单 |
|
|
|
handleCancelOrder(orderId) { |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '确定要取消订单吗?', |
|
|
|
confirmColor: '#019245', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 模拟取消订单API调用 |
|
|
|
|
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: '订单已取消', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
// // if (index === 0) return // 全部订单不需要筛选 |
|
|
|
// const targetStatus = this.statusMap[index] |
|
|
|
// if (targetStatus) { |
|
|
|
// this.orderList = this.orderList.filter(order => order.status === targetStatus) |
|
|
|
// this.groupMeals = this.groupMeals.filter(meal => meal.status === targetStatus) |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// // 处理取消订单 |
|
|
|
// handleCancelOrder(orderId) { |
|
|
|
// uni.showModal({ |
|
|
|
// title: '提示', |
|
|
|
// content: '确定要取消订单吗?', |
|
|
|
// confirmColor: '#019245', |
|
|
|
// success: (res) => { |
|
|
|
// if (res.confirm) { |
|
|
|
// // 模拟取消订单API调用 |
|
|
|
|
|
|
|
|
|
|
|
// uni.showToast({ |
|
|
|
// title: '订单已取消', |
|
|
|
// icon: 'success' |
|
|
|
// }) |
|
|
|
|
|
|
|
// 更新订单状态 |
|
|
|
const orderIndex = this.orderList.findIndex(item => item.id === orderId) |
|
|
|
if (orderIndex !== -1) { |
|
|
|
this.orderList[orderIndex].status = 'canceled' |
|
|
|
// // 更新订单状态 |
|
|
|
// const orderIndex = this.orderList.findIndex(item => item.id === orderId) |
|
|
|
// if (orderIndex !== -1) { |
|
|
|
// this.orderList[orderIndex].status = 'canceled' |
|
|
|
|
|
|
|
// 如果当前标签页不是全部或已取消,则移除该订单 |
|
|
|
if (this.current !== 0 && this.current !== 5) { |
|
|
|
this.orderList.splice(orderIndex, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// // 如果当前标签页不是全部或已取消,则移除该订单 |
|
|
|
// if (this.current !== 0 && this.current !== 5) { |
|
|
|
// this.orderList.splice(orderIndex, 1) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// }, |
|
|
|
// 处理支付订单 |
|
|
|
handlePayOrder(orderId) { |
|
|
|
uni.showToast({ |
|
|
|
title: '正在跳转支付...', |
|
|
|
icon: 'loading' |
|
|
|
}) |
|
|
|
// handlePayOrder(orderId) { |
|
|
|
// uni.showToast({ |
|
|
|
// title: '正在跳转支付...', |
|
|
|
// icon: 'loading' |
|
|
|
// }) |
|
|
|
|
|
|
|
// 模拟支付操作,实际项目中应调用支付API |
|
|
|
setTimeout(() => { |
|
|
|
uni.hideToast() |
|
|
|
// // 模拟支付操作,实际项目中应调用支付API |
|
|
|
// setTimeout(() => { |
|
|
|
// uni.hideToast() |
|
|
|
|
|
|
|
this.$api('payOrder', { |
|
|
|
orderId: orderId, |
|
|
|
payType: 0 |
|
|
|
}, res => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: '支付成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
// this.$api('payOrder', { |
|
|
|
// orderId: orderId, |
|
|
|
// payType: 0 |
|
|
|
// }, res => { |
|
|
|
// if (res.code == 200) { |
|
|
|
// uni.showToast({ |
|
|
|
// title: '支付成功', |
|
|
|
// icon: 'success' |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
|
|
|
|
// 更新订单状态 |
|
|
|
const orderIndex = this.orderList.findIndex(item => item.id === orderId) |
|
|
|
if (orderIndex !== -1) { |
|
|
|
this.orderList[orderIndex].status = 'processing' |
|
|
|
// // 更新订单状态 |
|
|
|
// const orderIndex = this.orderList.findIndex(item => item.id === orderId) |
|
|
|
// if (orderIndex !== -1) { |
|
|
|
// this.orderList[orderIndex].status = 'processing' |
|
|
|
|
|
|
|
// 如果当前标签页不是全部或待发货,则移除该订单 |
|
|
|
if (this.current !== 0 && this.current !== 2) { |
|
|
|
this.orderList.splice(orderIndex, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
}, 1500) |
|
|
|
}, |
|
|
|
// // 如果当前标签页不是全部或待发货,则移除该订单 |
|
|
|
// if (this.current !== 0 && this.current !== 2) { |
|
|
|
// this.orderList.splice(orderIndex, 1) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }, 1500) |
|
|
|
// }, |
|
|
|
// 处理取餐完成 |
|
|
|
handlePickOrder(order) { |
|
|
|
uni.showModal( { |
|
|
|
title: '提示', |
|
|
|
content: '确定取餐完成?', |
|
|
|
confirmColor: '#019245', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// order.status_dictText = '已完成', |
|
|
|
this.$api('updateMemberOrderStatus', { id: order.id, status: 3 }, res => { |
|
|
|
if (res.code === 200) { |
|
|
|
this.clickTabs({ |
|
|
|
index: 3 |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
uni.showToast({ |
|
|
|
title: '取餐完成', |
|
|
|
icon: 'success', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
// handlePickOrder(order) { |
|
|
|
// uni.showModal( { |
|
|
|
// title: '提示', |
|
|
|
// content: '确定取餐完成?', |
|
|
|
// confirmColor: '#019245', |
|
|
|
// success: (res) => { |
|
|
|
// if (res.confirm) { |
|
|
|
// // order.status_dictText = '已完成', |
|
|
|
// this.$api('updateMemberOrderStatus', { id: order.id, status: 3 }, res => { |
|
|
|
// if (res.code === 200) { |
|
|
|
// this.clickTabs({ |
|
|
|
// index: 3 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// uni.showToast({ |
|
|
|
// title: '取餐完成', |
|
|
|
// icon: 'success', |
|
|
|
// duration: 2000 |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|