订单删除

This commit is contained in:
wwz
2025-03-31 14:08:34 +08:00
parent 10a47abe13
commit e352acbdd0
7 changed files with 521 additions and 66 deletions

View File

@@ -244,7 +244,8 @@
<shopindex ref="showShopInfoRef"></shopindex>
<!-- 购物车 -->
<shoppingCartes :cartLists_count="cartLists_count" v-if="matchedProducts.length>0" :cartList="matchedProducts"
:showCart="showCart" @customevent='websocketsendMessage' @close="showCart = !showCart">
:showCart="showCart" @customevent='websocketsendMessage' @close="showCart = !showCart"
:orderinfo="orderinfo" @clickcancelOrder='clickcancelOrder'>
</shoppingCartes>
<!-- 显示购物车栏 -->
@@ -254,7 +255,7 @@
<view class="iconBox">
<image class="icon"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/shopIcon.png"
mode="aspectFill" @click="showCart = !showCart">
mode="aspectFill" @click="Historicalorders(true)">
</image>
<text class="u-badge"> {{cartLists_count<99?cartLists_count:'99+'}} </text>
</view>
@@ -427,7 +428,9 @@
} from "@/common/api/product/product.js";
import {
APIhistoryOrder
APIhistoryOrder,
APIcancelOrder,
APIrmPlaceOrder
} from "@/common/api/order/index.js";
// websocket
@@ -1096,7 +1099,6 @@
if (Message.type == "ping_interval" || Message.msg_id == "ping_interval") {
return false
}
// 检查消息是否已经处理过
if (processedMessageIds.has(Message.msg_id)) {
return;
@@ -1105,11 +1107,10 @@
// 初始化
if (Message.operate_type == "init") {
console.log(Message)
cartList.value = Message.data
setTimeout(() => {
uni.hideLoading();
isLoading.value = false;
}, 500)
uni.hideLoading();
isLoading.value = false;
}
// 清空购物车
@@ -1251,24 +1252,50 @@
});
//删除某一个待支付订单
const clickcancelOrder = async (i, key) => {
if (i == 'all') {
await APIcancelOrder({
shopId: uni.cache.get('shopId'),
orderId: orderinfo.id,
})
} else {
await APIrmPlaceOrder({
shopId: uni.cache.get('shopId'),
orderId: orderinfo.id,
placeNum: key
})
}
Historicalorders()
}
// 储存是否存在多次下单
const orderinfo = ref({})
const confirmorderref = ref(null)
// 结账
const orderdetail = async () => {
try {
let res = await APIhistoryOrder({
tableCode: uni.cache.get('tableCode'),
})
orderinfo.value = {
id: res.id,
detailMap: res.detailMap,
placeNum: res.placeNum
}
await Historicalorders()
} catch (error) {}
confirmordershow.value = true
}
// 历史订单
const Historicalorders = async (W) => {
let res = await APIhistoryOrder({
tableCode: uni.cache.get('tableCode'),
})
orderinfo.value = {
id: res.id,
detailMap: res.detailMap,
placeNum: res.placeNum
}
if (W) {
showCart.value = !showCart.value
}
}
// 定义 ifcartNumber 计算属性方法 展示数量
const ifcartNumber = computed(() => {
return (item) => {
@@ -1320,38 +1347,6 @@
}));
})
// // 获取当前时间
// const getCurrentDateTime = () => {
// const now = new Date();
// const dayOfWeek = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][now.getDay()];
// const hours = now.getHours().toString().padStart(2, '0');
// const minutes = now.getMinutes().toString().padStart(2, '0');
// const currentTime = `${hours}:${minutes}`;
// return {
// dayOfWeek,
// currentTime
// };
// };
// // 计算是否在营业时间内
// const isBusinessTime = computed(() => {
// const {
// dayOfWeek,
// currentTime
// } = getCurrentDateTime();
// console.log(shopInfo)
// const [startDay, endDay] = [shopInfo.businessStartDay, shopInfo.businessEndDay];
// const [startTime, endTime] = shopInfo.businessTime.split('-');
// const dayIndex = ['周一', '周二', '周三', '周四', '周五', '周六', '周天'].indexOf(dayOfWeek);
// const startDayIndex = ['周一', '周二', '周三', '周四', '周五', '周六', '周天'].indexOf(startDay);
// const endDayIndex = ['周一', '周二', '周三', '周四', '周五', '周六', '周天'].indexOf(endDay);
// console.log(shopInfo.businessTime, 1111)
// const isInDayRange = dayIndex >= startDayIndex && dayIndex <= endDayIndex;
// const isInTimeRange = currentTime >= startTime && currentTime <= endTime;
// console.log(isInDayRange, isInTimeRange, 1111)
// return isInDayRange && isInTimeRange;
// });
const endTimeref = reactive({
startTime: '',
endTime: ''