diff --git a/common/api/request.js b/common/api/request.js index d057677..1627c6b 100644 --- a/common/api/request.js +++ b/common/api/request.js @@ -45,22 +45,23 @@ export default (params) => { if (res.code == 200) { uni.hideLoading(); uni.hideToast(); - resolve(res.data ?res.data: true); + resolve(res.data ? res.data : true); } else { switch (res.code) { case '501': uni.cache.remove('shopId') - uni.showToast({ - title: '', - icon: "none", - success: () => { - setTimeout(() => { - uni.reLaunch({ - url: "/pages/index/index", - }) - }, 1000); - } - }) + // uni.showToast({ + // title: '', + // icon: "none", + // success: () => { + + // } + // }) + setTimeout(() => { + uni.reLaunch({ + url: "/pages/index/index", + }) + }, 1000); break; case 404: uni.showToast({ diff --git a/common/api/subscribeto.js b/common/api/subscribeto.js index 6441ae2..c6a9e2d 100644 --- a/common/api/subscribeto.js +++ b/common/api/subscribeto.js @@ -40,12 +40,19 @@ export const APIqueuedetail = (data) => { }) } - // 消息订阅 export const APIcallTablesubMsg = (data) => { return request({ url: urlAccount + '/user/callTable/subMsg', - method: 'get', + method: 'post', data: data }) +} + +// 取消排队 +export const APIqueuecancel = (data) => { + return request({ + url: urlAccount + '/user/callTable/cancel?queueId=' + data.queueId + '&shopId=' + data.shopId, + method: 'DELETE' + }) } \ No newline at end of file diff --git a/framework/0-conf.js b/framework/0-conf.js index 4b632aa..2c4a371 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -1,5 +1,5 @@ // const debug = process.env.NODE_ENV == 'development' ? true : false; -const debug = true +const debug = false // #ifdef H5 const proxyApi = "/api" // #endif @@ -7,10 +7,9 @@ const proxyApi = "/api" // #ifdef MP-WEIXIN || APP || MP-ALIPAY const proxyApi = 'http://192.168.1.31' // 调试地址 const proxyApiwws = 'ws://192.168.1.31:2348' // 调试地址 - -// // 本地 -// const proxyApi = 'http://192.168.1.31' // 固定的测试 -// const proxyApiwws = 'ws://192.168.1.43:2348' //宏哥本地 +// 测试 +// const proxyApi = "https://fv901fw8033.vicp.fun" +// const proxyApiwws = 'wss://sockets.sxczgkj.com/wss' // #endif // #ifdef H5 diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 984af64..577028f 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -60,13 +60,13 @@ {{paymentmethod.paymentBtnText}} - + - + @@ -553,7 +553,9 @@ orderVIP.value = uni.cache.get('orderVIP') ordershopUserInfo.value = orderVIP.value.shopInfo paymentMethodref.value.orderVIPfun(uni.cache.get('orderVIP')) - orderorderInfo() + if (orderId.value) { + orderorderInfo() + } } } catch (error) { //TODO handle the exception diff --git a/pages/product/components/confirmorder.vue b/pages/product/components/confirmorder.vue index 6c8c80c..16ce7b0 100644 --- a/pages/product/components/confirmorder.vue +++ b/pages/product/components/confirmorder.vue @@ -37,7 +37,7 @@ {{item.productName}} {{item.productSkuName}} + v-if="item.skuName">{{item.skuName}} @@ -69,7 +69,7 @@ {{item.cartListinfo.sku_id == i.id ? i.name :""}} - + @@ -135,7 +135,8 @@ const props = defineProps({ cartList: { - type: Array + type: Array, + default: [] }, cartLists_count: { type: Number, @@ -263,71 +264,36 @@ // 提交订单 const orderdetail = async () => { - let res = await storeMemberpay.actionscreateOrder({ - dineMode: 'dine-in', //堂食 dine-in 外带 take-out 外卖 take-away - seatNum: uni.cache.get('dinersNum') ? uni.cache.get('dinersNum') : '', //用餐人数 - // packFee: packFee.value, //打包费 - packFee: 0, //打包费 - originAmount: totalPrices.value, //订单原金额(包含打包费) 不含折扣价格 不含餐位费 - remark: remark.value, //备注 - placeNum: props.orderinfo.placeNum + 1, //当前订单下单次数 - waitCall: '', //是否等叫 0 否 1 等叫 - orderId: props.orderinfo.id, - userId: uni.cache.get('userInfo').id || '' // - }) - // 清空购物车 - emits('customevent', { - type: 'shopping', - table_code: uni.cache.get('tableCode'), - shop_id: uni.cache.get('shopId'), - operate_type: 'cleanup', - }) - // uni.pro.redirectTo('order/detail', { - // orderId: res.id, - // shopId: uni.cache.get('shopId') - // }) - uni.reLaunch({ - url: '/pages/order/detail?orderId=' + res.id + '&shopId=' + uni.cache.get('shopId') - }) - // uni.pro.navigateTo('order/detail', { - // orderId: res.id, - // shopId: uni.cache.get('shopId') - // }) - // uni.showLoading({ - // title: '正在生成订单', - // mask: true - // }) - // if (res) { - // let checkOrderPay = { - // orderId: res.id, - // vipPrice: shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1 ? 1 : 0, //是否使用会员价0否1是 - // allPack: is_type.value == 0 ? 0 : 1, //是否整单打包 - // seatNum: uni.cache.get('dinersNum') ? uni.cache.get('dinersNum') : '', //用餐人数 - // orderAmount: totalCost.value, //订单原金额(包含打包费+餐位费) 不含折扣价格 - // discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1 - // discountAmount: 0, //手动优惠金额 写死0 - // productCouponDiscountAmount: '', //商品优惠券抵扣金额 - // fullCouponDiscountAmount: '', //满减优惠券抵扣金额 - // couponList: '', //用户使用的卡券 - // orderAmount: totalCost.value, // 最中订单金额 - // roundAmount: 0, //抹零金额 减免多少钱 - // pointsDiscountAmount: 0, //积分抵扣金额(tb_points_basic_setting表) - // pointsNum: 0, //(扣除各类折扣 enable_deduction后使用) - // remark: '', //用户备注 - // } - // let successdata = await storeMemberpay.actionsltPayOrder({ - // checkOrderPay, - // payType: paymentmethod.payType, - // buyerRemark: '', - // returnUrl: '' - // }) - // if (successdata) { - // console.log(res.id, '支付成功res.id') - // uni.redirectTo({ - // url: '/order/detail?orderId=' + res.id - // }); - // } - // } + if (props.cartList.length > 0) { + let res = await storeMemberpay.actionscreateOrder({ + dineMode: 'dine-in', //堂食 dine-in 外带 take-out 外卖 take-away + seatNum: uni.cache.get('dinersNum') ? uni.cache.get('dinersNum') : '', //用餐人数 + // packFee: packFee.value, //打包费 + packFee: 0, //打包费 + originAmount: totalPrices.value, //订单原金额(包含打包费) 不含折扣价格 不含餐位费 + remark: remark.value, //备注 + placeNum: props.orderinfo.placeNum + 1, //当前订单下单次数 + waitCall: '', //是否等叫 0 否 1 等叫 + orderId: props.orderinfo.id, + userId: uni.cache.get('userInfo').id || '' // + }) + // 清空购物车 + emits('customevent', { + type: 'shopping', + table_code: uni.cache.get('tableCode'), + shop_id: uni.cache.get('shopId'), + operate_type: 'cleanup', + }) + uni.reLaunch({ + url: '/pages/order/detail?orderId=' + res.id + '&shopId=' + uni.cache.get('shopId') + }) + } else { + uni.reLaunch({ + url: '/pages/order/detail?orderId=' + props.orderinfo.id + '&shopId=' + uni.cache.get( + 'shopId') + }) + } + } const dataprocessing = computed(() => { diff --git a/pages/product/components/shoppingCartes.vue b/pages/product/components/shoppingCartes.vue index d1c6bd4..18aabdf 100644 --- a/pages/product/components/shoppingCartes.vue +++ b/pages/product/components/shoppingCartes.vue @@ -3,70 +3,80 @@ - + - - 购物车 - - - - - + + + + 购物车 - - {{item.cartListinfo.is_temporary == 1?'临时菜' :item.name }} + + + 清空购物车 + + + + + + + - - - {{item.cartListinfo.sku_id == i.id? i.name:"" }} - - - - - - - {{i.proName }} + + {{item.cartListinfo.is_temporary == 1?'临时菜' :item.name }} + + + + {{item.cartListinfo.sku_id == i.id? i.name:"" }} - - - - - - - - - {{item.cartListinfo.sku_id == i.id?(shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(i.memberPrice || i.salePrice):i.salePrice):''}} + + + + + {{i.proName }} - - - {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice || item.salePrice):item.salePrice}} - - - - - - - - - - {{ ifcartNumber(item) }} - - - - + + + + + + + + + {{item.cartListinfo.sku_id == i.id?(shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(i.memberPrice || i.salePrice):i.salePrice):''}} + + + + {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice || item.salePrice):item.salePrice}} + + + + + + + + + + + {{ ifcartNumber(item) }} + + + + + @@ -76,11 +86,11 @@ - + - 历史订单 - - + 待支付订单 + + 清空历史订单 @@ -90,7 +100,7 @@ 第{{key}}次下单 - 清空 + 清空 @@ -107,7 +117,7 @@ {{item.productName}} {{item.productSkuName}} + v-if="item.skuName">{{item.skuName}} @@ -232,6 +242,12 @@ i, key }) + emits('customevent', { + type: 'shopping', + table_code: uni.cache.get('tableCode'), + shop_id: uni.cache.get('shopId'), + operate_type: 'clearOrder', + }) } const calculateValue = (cartNumber, i, step = 1) => { @@ -302,195 +318,202 @@ } .scroll-view { - max-height: 50vh; + max-height: 60vh; margin-bottom: 190rpx; - } - .list-wrap { - padding: 28rpx 0 0 28rpx; - } + .list-wrap { + padding: 0 28rpx; - .ShoppingCart { - margin: 10rpx 0 20rpx 0; - font-size: 30rpx; - text-align: center; - color: #969494; - } + .ShoppingCart { + font-size: 30rpx; + text-align: left; + padding: 20rpx 0; + font-weight: 700; + border-bottom: 1rpx solid #cecece; + color: #000; - .shop-item { - display: flex; - flex-direction: column; - padding-bottom: 28rpx; - - .shop-item-content { - display: flex; - justify-content: center; - align-items: center; - } - - .shop-item-remark { - display: flex; - align-items: center; - padding-right: 180rpx; - margin-top: 10rpx; - - .label { - font-size: 28rpx; - color: #666; - margin-right: 20rpx; } - } - - .langcover { - position: relative; - } - - .langcover::after { - content: '加载中..'; - position: absolute; - top: 0; - left: 0; - height: 100%; - width: 100%; - background-color: #e8e8e8; - color: #6b6b6b; - border-radius: 10rpx; - text-align: center; - line-height: 180rpx; - z-index: 1; - } - - .info { - flex: 1; - padding-left: 20upx; - padding-right: 28rpx; - - .name { - font-size: 28upx; - font-weight: bold; - color: #333; - margin-bottom: 5rpx; + .shop-item:last-child { + border-bottom: 1rpx solid #cecece; + padding-bottom: 20rpx; } - .select-sku-wrap { - font-weight: 400; - font-size: 24rpx; - color: #999999; - } - - .price-wrap { - margin-top: 16rpx; + .shop-item { + margin-top: 15rpx; display: flex; - align-items: center; - justify-content: space-between; + flex-direction: column; - .price { + .shop-item-content { display: flex; - align-items: flex-end; - - .i, - .num { - font-weight: bold; - font-size: 32rpx; - color: #333333; - } - - .i { - position: relative; - bottom: 4upx; - } - - .price { - font-family: Source Han Sans CN, Source Han Sans CN; - font-weight: bold; - font-size: 36rpx; - color: #333333; - } - - .originalprice { - margin-left: 10rpx; - font-family: Source Han Sans CN, Source Han Sans CN; - font-weight: 400; - font-size: 20rpx; - text-decoration: line-through; - } - - .unit { - font-family: Source Han Sans CN, Source Han Sans CN; - font-weight: 400; - font-size: 36rpx; - color: #333333; - } - - .lineThrough { - font-weight: normal; - text-decoration: line-through; - color: #999 !important; - font-size: 24rpx !important; - } - } - - .sku-wrap { - padding: 6upx 16upx; - background-color: #ffd100; - border-radius: 12upx; - display: flex; - align-items: center; justify-content: center; - position: relative; + align-items: center; + } - .t { - font-size: 24upx; - font-weight: bold; - } + .shop-item-remark { + display: flex; + align-items: center; + padding-right: 180rpx; + margin-top: 10rpx; - .dot { - display: flex; - align-items: center; - justify-content: center; - font-size: 20upx; - position: absolute; - padding: 2upx 12upx; - border-radius: 8upx; - background-color: #eb5232; - color: #fff; - position: absolute; - top: -14upx; - right: -8upx; + .label { + font-size: 28rpx; + color: #666; + margin-right: 20rpx; } } - .operation-wrap { - display: flex; - align-items: center; + .langcover { + position: relative; + } - .num { - font-size: 32upx; - padding: 0 16upx; + .langcover::after { + content: '加载中..'; + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + background-color: #e8e8e8; + color: #6b6b6b; + border-radius: 10rpx; + text-align: center; + line-height: 180rpx; + z-index: 1; + } + + .info { + flex: 1; + padding-left: 20rpx; + + .name { + font-size: 28upx; + font-weight: bold; + color: #333; + margin-bottom: 5rpx; } - .btn { - position: relative; + .select-sku-wrap { + font-weight: 400; + font-size: 24rpx; + color: #999999; + } + + .price-wrap { + margin-top: 16rpx; display: flex; align-items: center; - justify-content: center; - position: relative; + justify-content: space-between; - .btnClick { - width: 100rpx; - height: 100rpx; - position: absolute; - // bottom: 0; + .price { + display: flex; + align-items: flex-end; + + .i, + .num { + font-weight: bold; + font-size: 32rpx; + color: #333333; + } + + .i { + position: relative; + bottom: 4upx; + } + + .price { + font-family: Source Han Sans CN, Source Han Sans CN; + font-weight: bold; + font-size: 36rpx; + color: #333333; + } + + .originalprice { + margin-left: 10rpx; + font-family: Source Han Sans CN, Source Han Sans CN; + font-weight: 400; + font-size: 20rpx; + text-decoration: line-through; + } + + .unit { + font-family: Source Han Sans CN, Source Han Sans CN; + font-weight: 400; + font-size: 36rpx; + color: #333333; + } + + .lineThrough { + font-weight: normal; + text-decoration: line-through; + color: #999 !important; + font-size: 24rpx !important; + } } - .btnClick.l { - right: 0; + .sku-wrap { + padding: 6upx 16upx; + background-color: #ffd100; + border-radius: 12upx; + display: flex; + align-items: center; + justify-content: center; + position: relative; + + .t { + font-size: 24upx; + font-weight: bold; + } + + .dot { + display: flex; + align-items: center; + justify-content: center; + font-size: 20upx; + position: absolute; + padding: 2upx 12upx; + border-radius: 8upx; + background-color: #eb5232; + color: #fff; + position: absolute; + top: -14upx; + right: -8upx; + } + } - .btnClick.r { - left: 0; + .operation-wrap { + display: flex; + align-items: center; + + .num { + font-size: 32upx; + padding: 0 16upx; + } + + .btn { + position: relative; + display: flex; + align-items: center; + justify-content: center; + position: relative; + + .btnClick { + width: 100rpx; + height: 100rpx; + position: absolute; + // bottom: 0; + } + + .btnClick.l { + right: 0; + } + + .btnClick.r { + left: 0; + } + } } } } @@ -499,22 +522,19 @@ } .card { - // background-color: #fff; - border-radius: 20upx; - margin-bottom: 28upx; position: relative; .cardcalorders { position: relative; - margin: 40rpx 0 20rpx; + padding: 20rpx 0; font-size: 35rpx; - text-align: left; font-weight: bold; - color: #000000; + border-bottom: 1rpx solid #cecece; + color: #000; .absolute { position: absolute; - right: 28rpx; + right: 0; top: 2rpx; font-size: 24rpx; } @@ -524,23 +544,22 @@ 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; + border-bottom: 1rpx solid #cecece; .placeNum { - font-weight: bold; - font-size: 32rpx; - color: #333333; + font-weight: 700; + font-size: 27rpx; + color: #3e3d3d; } .placeTime { @@ -599,7 +618,6 @@ display: flex; flex-direction: column; align-items: flex-end; - padding: 0 28rpx; .priceAmount { font-weight: 500; diff --git a/pages/product/index.vue b/pages/product/index.vue index 8a0fc83..589c9e1 100644 --- a/pages/product/index.vue +++ b/pages/product/index.vue @@ -133,7 +133,7 @@ + :style="{height:`${store.screenHeight - store.height}px`}" style="padding-bottom: 200rpx;"> {{item.name}} @@ -243,9 +243,9 @@ - + @@ -353,7 +353,6 @@ - { + if (i == '-' && shopCartNumber.value >= 0) { + shopCartNumber.value = 0 + return false; + } let res = await shoppingcart() if (i == '-') { if (!res && shopCartNumber.value == specifications.item.suitNum) { uni.showToast({ - title: `起点${specifications.item.suitNum}`, + title: `起点${specifications.item.suitNum}个`, icon: 'none' }) return false; @@ -859,7 +860,6 @@ // 直接返回布尔值 return result; } else if (specifications.item.type == 'sku') { - // console.log(product,data, 'product,data') // 多规格 return product.cartListinfo.sku_id == data.id && product.cartListinfo.product_id == data .productId @@ -897,41 +897,50 @@ // 提交选择并执行下一步操作的方法 const submitSelection = async () => { + // 数量不能少于0 if (shopCartNumber.value <= 0) { return; } - let res = await shoppingcart() - console.log(res) + if ((specifications.item.type == 'package' && allConditionsSatisfied.value) || (specifications.item.type == + 'sku' && canSubmit.value)) { + let res = await shoppingcart() - // 是否是套餐 有就传 - if (specifications.item.type != "package") { + // 是否是套餐 有就传 + if (specifications.item.type != "package") { + selectedGroupSnap.value = [] + } + + websocketsendMessage({ + id: res ? res.cartListId : '', + type: 'shopping', + table_code: uni.cache.get('tableCode'), + shop_id: uni.cache.get('shopId'), + operate_type: res ? 'edit' : 'add', + product_id: specifications.product_id, + sku_id: specifications.sku_id, + number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : + shopCartNumber + .value, + pro_group_info: selectedGroupSnap.value, + goods_type: specifications.item.type == "package" ? 'package' : '', + is_print: 1, + product_type: specifications.item.type + }) + // 清空套餐选中 selectedGroupSnap.value = [] + showShopsku.value = false + } else { + return; } - websocketsendMessage({ - id: res ? res.cartListId : '', - type: 'shopping', - table_code: uni.cache.get('tableCode'), - shop_id: uni.cache.get('shopId'), - operate_type: res ? 'edit' : 'add', - product_id: specifications.product_id, - sku_id: specifications.sku_id, - number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : shopCartNumber - .value, - pro_group_info: selectedGroupSnap.value, - goods_type: specifications.item.type == "package" ? 'package' : '', - is_print: 1, - product_type: specifications.item.type - }) - // 清空套餐选中 - selectedGroupSnap.value = [] - showShopsku.value = false + } //获取多规格数据 const clickspecifications = async (item, index, indexs, type) => { - if (item.isSoldStock == 1 || item.isSaleTime == 0) { + // 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券 + if (item.isSoldStock == 1 || item.isSaleTime == 0 || item.type == 'single' || item.type == 'weight' || (item.type == 'package' && item.groupType == '0')) { return false; } // 数量清零 @@ -1033,7 +1042,6 @@ initNetworkListener } = useWebSocket(options); - //购物车显示 const showCart = ref(false) @@ -1116,6 +1124,9 @@ // 清空购物车 if (Message.operate_type == 'cleanup') { cartList.value = [] + setTimeout(() => { + Historicalorders() + }, 400) showCart.value = false } @@ -1138,6 +1149,11 @@ }); } + // 历史订单 + if (Message.operate_type == 'clearOrder') { + Historicalorders() + } + // 购物车数据更新从新请求 if (Message.type == 'product' && Message.data_type == 'product_update' && Message .operate_type == 'product_update') { @@ -1207,26 +1223,95 @@ }) - // 计算购物车商品总数量 - const cartLists_count = computed(() => { - if (matchedProducts.value.length > 0) { - return matchedProducts.value.reduce((sum, item) => { - // 将 cartNumberToAdd 转换为数字 - // const num = typeof item.cartNumberToAdd === 'string' ? parseFloat(item.cartNumberToAdd) : item.cartNumberToAdd; - const num = typeof item.cartNumber === 'string' ? parseFloat(item.cartNumber) : item - .cartNumber; - return sum + num; - }, 0); + //删除某一个待支付订单 + const clickcancelOrder = async (data) => { + if (data.i == 'all') { + await APIcancelOrder({ + shopId: uni.cache.get('shopId'), + orderId: orderinfo.value.id, + }) } else { - return 0; + await APIrmPlaceOrder({ + shopId: uni.cache.get('shopId'), + orderId: orderinfo.value.id, + placeNum: data.key + }) } - }); + Historicalorders() + } - // 计算购物车商品总价格 + // 储存是否存在多次下单 + const orderinfo = ref({}) + const confirmorderref = ref(null) + + // 结账 + const orderdetail = async () => { + try { + await Historicalorders() + } catch (error) {} + confirmordershow.value = true + showCart.value = false + } + + // 历史订单 + 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 + } + } + + // 提取合并 orderinfo.detailMap 数组的逻辑 + function combineOrderInfoDetailMap(orderinfo) { + if (!orderinfo) return []; + let combinedArray = []; + for (const key in orderinfo.detailMap) { + if (orderinfo.detailMap.hasOwnProperty(key)) { + let subArray = orderinfo.detailMap[key]; + combinedArray = [...combinedArray, ...subArray]; + } + } + return combinedArray; + } + + // 计算购物车商品费用 const totalPrices = computed(() => { + // 待支付订单 + let cartone = 0 + if (orderinfo.value) { + let combinedArray = []; + for (const key in orderinfo.value.detailMap) { + if (orderinfo.value.detailMap.hasOwnProperty(key)) { + let subArray = orderinfo.value.detailMap[key]; + combinedArray = [...combinedArray, ...subArray] + } + } + // 购物车总数价格 + cartone = combinedArray.reduce((total, item) => { + // 是否启用会员价 0否1是 + if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) { + // memberPrice会员价 + return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item.num - item + .returnNum)); + } else { + // salePrice销售价 + return total + (parseFloat(item.price || 0) * parseFloat(item.num - item.returnNum)); + } + }, 0); + } + console.log(cartone, 'orderinfo.value') + // 购物车总数价格 + let cart = 0 if (matchedProducts.value.length > 0) { // 购物车总数价格 - let cart = matchedProducts.value.reduce((total, item) => { + cart = matchedProducts.value.reduce((total, item) => { if (item.type == 'sku') { item.skuList.forEach((i, t) => { if (item.cartListinfo.sku_id == i.id) { @@ -1245,56 +1330,29 @@ return total + parseFloat(item.salePrice || 0) * parseFloat(item.cartNumber); } }, 0); - return parseFloat(cart.toFixed(2)); - } else { - return 0 } - + cart = parseFloat(cartone) + parseFloat(cart) + console.log(cart, 'orderinfo.value') + // 向上取整并保留两位小数 + return parseFloat(cart.toFixed(2)); }); - //删除某一个待支付订单 - 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 cartLists_count = computed(() => { + const combinedOrderInfo = combineOrderInfoDetailMap(orderinfo.value); + const orderInfoCount = combinedOrderInfo.reduce((sum, item) => { + return sum + parseFloat(item.num); + }, 0); - // 储存是否存在多次下单 - const orderinfo = ref({}) - const confirmorderref = ref(null) + const matchedProductsCount = matchedProducts.value.reduce((sum, item) => { + const num = typeof item.cartNumber === 'string' ? parseFloat(item.cartNumber) : item + .cartNumber; + return sum + num; + }, 0); - // 结账 - const orderdetail = async () => { - try { - 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 - } - } + const totalCount = orderInfoCount + matchedProductsCount; + return parseFloat(totalCount.toFixed(2)); + }); // 定义 ifcartNumber 计算属性方法 展示数量 const ifcartNumber = computed(() => { @@ -1407,7 +1465,8 @@ // userStore.actionsAPIuser() // 数据可以更新 isDataLoaded.value = true; - + // 历史订单 + Historicalorders() } else { uni.showToast({ title: '暂无列表数据,请重新扫码', diff --git a/pages/subscribeto/index.vue b/pages/subscribeto/index.vue index dff778e..3210be6 100644 --- a/pages/subscribeto/index.vue +++ b/pages/subscribeto/index.vue @@ -1,44 +1,6 @@