From e352acbdd0e3e927f0434fc4785e04fce55e267a Mon Sep 17 00:00:00 2001 From: wwz <1144797966@qq.com> Date: Mon, 31 Mar 2025 14:08:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/order/index.js | 18 + framework/0-conf.js | 4 +- pages/order/detail.vue | 28 +- pages/product/components/confirmorder.vue | 1 - pages/product/components/shoppingCartes.vue | 442 +++++++++++++++++++- pages/product/index.vue | 91 ++-- stores/order.js | 3 +- 7 files changed, 521 insertions(+), 66 deletions(-) diff --git a/common/api/order/index.js b/common/api/order/index.js index b27a806..52b5aac 100644 --- a/common/api/order/index.js +++ b/common/api/order/index.js @@ -44,4 +44,22 @@ export const APIgetOrderById = (data) => { method: 'get', data: data }) +} + +//删除所有待支付订单 +export const APIcancelOrder = (data) => { + return request({ + url: url + '/user/order/cancelOrder', + method: 'post', + data: data + }) +} + +//删除某一个待支付订单 +export const APIrmPlaceOrder = (data) => { + return request({ + url: url + '/user/order/rmPlaceOrder', + method: 'post', + data: data + }) } \ No newline at end of file diff --git a/framework/0-conf.js b/framework/0-conf.js index 15c661e..4b632aa 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -1,12 +1,12 @@ // const debug = process.env.NODE_ENV == 'development' ? true : false; -const debug = false +const debug = true // #ifdef H5 const proxyApi = "/api" // #endif // #ifdef MP-WEIXIN || APP || MP-ALIPAY const proxyApi = 'http://192.168.1.31' // 调试地址 -const proxyApiwws = 'wss://sockets.sxczgkj.com/wss' // 调试地址 +const proxyApiwws = 'ws://192.168.1.31:2348' // 调试地址 // // 本地 // const proxyApi = 'http://192.168.1.31' // 固定的测试 diff --git a/pages/order/detail.vue b/pages/order/detail.vue index e7fe9a7..984af64 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -33,7 +33,7 @@ - + @@ -60,13 +60,13 @@ {{paymentmethod.paymentBtnText}} - + - + @@ -224,9 +224,9 @@ 0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo .coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0); listinfo.totalCost = Math.round(sums * 100) / 100; - //总价格 - // console.log(listinfo.combinedArray, listinfo.packFeess, listinfo.totalPrices, listinfo - // .Seatcharge, listinfo.Productroll, listinfo.coupondiscountAmount, sums) // 霸王餐 + // 总价格 + console.log(listinfo.combinedArray, listinfo.packFeess, listinfo.totalPrices, listinfo + .Seatcharge, listinfo.Productroll, listinfo.coupondiscountAmount, sums) // 霸王餐 console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value) if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) { listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value @@ -354,7 +354,11 @@ // 删除订单 const APIputuserorderclick = async () => { await APIputuserorder(listinfo.id) - uni.navigateBack() + uni.showToast({ + title: '删除成功', + icon: 'none' + }) + uni.pro.switchTab('order/index') } const istoricalorders = async () => { @@ -426,6 +430,12 @@ } } }) + // } else if (orderVIP.value.amount == 0) { + // uni.showToast({ + // title: '您的余额不足', + // icon: 'none' + // }) + // } else { } else { ispws.value = true } @@ -543,6 +553,7 @@ orderVIP.value = uni.cache.get('orderVIP') ordershopUserInfo.value = orderVIP.value.shopInfo paymentMethodref.value.orderVIPfun(uni.cache.get('orderVIP')) + orderorderInfo() } } catch (error) { //TODO handle the exception @@ -1029,6 +1040,7 @@ } .fixedview_tows { + margin-top: 10rpx; background: #c3c3c3; border-radius: 36rpx; font-weight: 400; diff --git a/pages/product/components/confirmorder.vue b/pages/product/components/confirmorder.vue index 1b032f1..6c8c80c 100644 --- a/pages/product/components/confirmorder.vue +++ b/pages/product/components/confirmorder.vue @@ -183,7 +183,6 @@ // 计算购物车商品费用 const totalPrices = computed(() => { - let combinedArray = []; for (const key in props.orderinfo.detailMap) { if (props.orderinfo.detailMap.hasOwnProperty(key)) { diff --git a/pages/product/components/shoppingCartes.vue b/pages/product/components/shoppingCartes.vue index 00f378a..d1c6bd4 100644 --- a/pages/product/components/shoppingCartes.vue +++ b/pages/product/components/shoppingCartes.vue @@ -12,6 +12,9 @@ + + 购物车 + @@ -69,11 +72,57 @@ - + + + + + + + 历史订单 + + + 清空历史订单 + + + + + + 第{{key}}次下单 + + + 清空 + + + + + + + + + + + + {{item.productName}} + {{item.productSkuName}} + + + + + ¥{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.price):item.price}} + + x{{item.num}} + + + + + + + + @@ -95,7 +144,7 @@ } from '@/stores/user.js'; // 定义自定义事件 - const emits = defineEmits(['customevent', 'close']); + const emits = defineEmits(['customevent', 'close', 'clickcancelOrder']); const props = defineProps({ cartList: { @@ -108,6 +157,13 @@ showCart: { type: Boolean }, + orderinfo: { + type: Object, + default: { + detailMap: {} + } + }, + }); const shopInfo = uni.cache.get('shopInfo') @@ -171,6 +227,13 @@ }; }) + const clickcancelOrder = (i, key) => { + emits('clickcancelOrder', { + i, + key + }) + } + const calculateValue = (cartNumber, i, step = 1) => { if (i == '+') { const result = parseFloat(cartNumber) + parseFloat(step); @@ -247,6 +310,13 @@ padding: 28rpx 0 0 28rpx; } + .ShoppingCart { + margin: 10rpx 0 20rpx 0; + font-size: 30rpx; + text-align: center; + color: #969494; + } + .shop-item { display: flex; flex-direction: column; @@ -428,5 +498,365 @@ } } + .card { + // background-color: #fff; + border-radius: 20upx; + margin-bottom: 28upx; + position: relative; + + .cardcalorders { + position: relative; + margin: 40rpx 0 20rpx; + font-size: 35rpx; + text-align: left; + font-weight: bold; + color: #000000; + + .absolute { + position: absolute; + right: 28rpx; + top: 2rpx; + font-size: 24rpx; + } + } + + .card_item { + display: flex; + flex-direction: column; + position: relative; + padding-right: 20rpx; + + .head { + display: flex; + justify-content: space-between; + + // padding: 32rpx 0; + .head_left { + width: 100%; + display: flex; + justify-content: space-between; + padding: 20rpx 0; + + .placeNum { + font-weight: bold; + font-size: 32rpx; + color: #333333; + } + + .placeTime { + font-weight: 400; + font-size: 32rpx; + color: #999; + + .t { + margin-left: 4rpx; + font-size: 24rpx; + } + } + } + + } + + .shop-info { + border-bottom: 2rpx dashed #e5e5e5; + + + .item { + margin: 30rpx 0; + display: flex; + + .info { + flex: 1; + display: flex; + flex-direction: column; + padding-left: 16upx; + + .productName { + font-weight: bold; + font-size: 28rpx; + color: #333333; + margin-top: 20rpx; + } + + .productSkuName { + font-weight: 400; + font-size: 24rpx; + color: #999999; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 3; + overflow: hidden; + text-overflow: ellipsis; + } + + .n { + font-size: 24upx; + color: #999; + } + } + + .price { + display: flex; + flex-direction: column; + align-items: flex-end; + padding: 0 28rpx; + + .priceAmount { + font-weight: 500; + font-size: 28rpx; + color: #333333; + margin-top: 26rpx; + } + + .num { + font-weight: 400; + font-size: 24rpx; + color: #999999; + margin-top: 22rpx; + } + } + } + } + + .status { + align-self: flex-end; + width: 92rpx; + height: 40rpx; + line-height: 40rpx; + text-align: center; + background: #999999; + border-radius: 10rpx 10rpx 10rpx 10rpx; + font-weight: 400; + font-size: 22rpx; + color: #FFFFFF; + margin-top: 32rpx; + } + + .totalAmount { + width: 100%; + display: flex; + justify-content: flex-end; + align-items: flex-end; + padding: 32rpx 0; + border-bottom: 2rpx dashed #e5e5e5; + + .label { + font-weight: bold; + font-size: 28rpx; + color: #333333; + } + + .price { + font-weight: bold; + font-size: 36rpx; + color: #333333; + } + } + + .semicircle_icon { + width: 100%; + position: absolute; + top: -22.5rpx; + left: 0; + display: flex; + justify-content: space-between; + + .semicircle_left_icon { + width: 45rpx; + height: 45rpx; + margin-left: -22.5rpx; + background-color: #f9f9f9; + border-radius: 50%; + // box-shadow: inset -20rpx 0rpx 22rpx -20rpx rgba(87, 86, 86, 0.35); + + } + + .semicircle_right_icon { + width: 45rpx; + height: 45rpx; + margin-right: -22.5rpx; + background-color: #f9f9f9; + border-radius: 50%; + // box-shadow: inset 13rpx 0rpx 16rpx -9rpx rgba(87, 86, 86, 0.35); + + } + } + } + + .cell-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 32rpx 34rpx 0 34rpx; + + .label { + font-weight: bold; + font-size: 32rpx; + color: #333333; + padding-bottom: 32rpx; + } + + .val { + display: flex; + align-items: flex-end; + padding-bottom: 32rpx; + border-bottom: 2rpx dashed #e5e5e5; + + view:nth-child(1) { + font-weight: 400; + font-size: 24rpx; + color: #999999; + margin-right: 42rpx; + } + + view:nth-child(2) { + display: flex; + align-items: flex-end; + font-weight: bold; + font-size: 36rpx; + color: #333333; + } + } + + .val.column { + display: flex; + flex-direction: column; + + .productCoupon { + display: flex; + align-items: flex-end; + margin: 0 0 10rpx 0; + + .name { + font-weight: 400; + font-size: 26rpx; + color: #999; + margin: 0; + } + + .num { + font-weight: 400; + font-size: 26rpx; + color: #999; + margin: 0 30rpx; + line-height: 20rpx; + } + + .amount { + font-weight: bold; + font-size: 26rpx; + color: #333; + } + } + } + } + + .favorable { + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 30rpx; + box-sizing: border-box; + padding-bottom: 26rpx; + padding-top: 26rpx; + border-bottom: 2rpx solid #E5E5E5; + + .favorable_left { + display: flex; + align-items: center; + + .icon { + width: 40rpx; + height: 40rpx; + margin-right: 16rpx; + } + + .name { + font-size: 28rpx; + font-weight: 400rpx; + color: #333; + } + } + + .favorable_right { + display: flex; + align-items: center; + + .favorable_right_text { + font-size: 24rpx; + color: #999; + font-weight: 400rpx; + } + + } + + .favorable_right { + .column { + display: flex; + flex-direction: column; + align-items: flex-end; + + .favorable_right_text { + margin-bottom: 10rpx; + + text:nth-child(1) { + font-size: 26rpx; + color: #999; + } + + text:nth-child(2) { + font-size: 26rpx; + color: #999; + margin: 0 30rpx; + } + + text:nth-child(3) { + font-size: 26rpx; + color: #333; + + } + } + } + } + + .favorable_right.column { + align-items: flex-start; + } + } + + .favorable.column { + align-items: flex-start; + } + + .cell-item.column { + align-items: flex-start; + } + + .total-wrap { + width: 100%; + display: flex; + justify-content: flex-end; + align-items: flex-end; + padding: 0 34rpx; + font-weight: bold; + font-size: 28rpx; + color: #333333; + margin-top: 64rpx; + + .price { + font-weight: bold; + font-size: 36rpx; + } + } + + .order_footer { + display: flex; + flex-direction: column; + padding: 34rpx; + position: relative; + } + + } + } \ No newline at end of file diff --git a/pages/product/index.vue b/pages/product/index.vue index 2c5e51a..8a0fc83 100644 --- a/pages/product/index.vue +++ b/pages/product/index.vue @@ -244,7 +244,8 @@ + :showCart="showCart" @customevent='websocketsendMessage' @close="showCart = !showCart" + :orderinfo="orderinfo" @clickcancelOrder='clickcancelOrder'> @@ -254,7 +255,7 @@ + mode="aspectFill" @click="Historicalorders(true)"> {{cartLists_count<99?cartLists_count:'99+'}} @@ -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: '' diff --git a/stores/order.js b/stores/order.js index 1b935e5..59a2beb 100644 --- a/stores/order.js +++ b/stores/order.js @@ -65,9 +65,10 @@ export const useCartStore = defineStore('cart', () => { }, 0); cart = cart.toFixed(2) + console.log(parseFloat(cart)) // 向上取整并保留两位小数 // let result = roundUpToTwoDecimals(cart, 'upward') - return cart; + return parseFloat(cart); }); // 计算商品卷所选择的总价格