From d0cee9514558af1cc85ab1bb87b2f349b4b7c559 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Wed, 12 Nov 2025 13:43:35 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=BB=93=E7=AE=97=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 2 +-
.../choose-table/choose-table.vue | 552 +++++++++---------
.../confirm-order/confirm-order.vue | 124 ++--
pagesCreateOrder/util.js | 1 -
pagesOrder/pay-order/pay-order.vue | 97 ++-
pnpm-lock.yaml | 48 +-
6 files changed, 395 insertions(+), 429 deletions(-)
diff --git a/package.json b/package.json
index fc4ca7c..273aa64 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
"jsencrypt": "^3.3.2",
"lodash": "^4.17.21",
"uview-plus": "^3.3.32",
- "ysk-utils": "^1.0.56"
+ "ysk-utils": "^1.0.58"
},
"devDependencies": {
"copy-webpack-plugin": "^12.0.2",
diff --git a/pagesCreateOrder/choose-table/choose-table.vue b/pagesCreateOrder/choose-table/choose-table.vue
index 3ac5b71..a79db3b 100644
--- a/pagesCreateOrder/choose-table/choose-table.vue
+++ b/pagesCreateOrder/choose-table/choose-table.vue
@@ -1,305 +1,319 @@
-
-
-
-
-
-
-
-
-
-
-
-
- 桌台类型:{{area.sel.name}} 全部
-
-
-
-
-
+
+
+
+
+ 桌台类型:{{ area.sel.name }}
+ 全部
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
- {{item.name}}
-
- {{''}}
-
-
- {{returnStutasText(item.status)}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {{ item.name }}
+
+ {{ "" }}
+
+
+ {{ returnStutasText(item.status) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pagesCreateOrder/confirm-order/confirm-order.vue b/pagesCreateOrder/confirm-order/confirm-order.vue
index 701917d..d40ea68 100644
--- a/pagesCreateOrder/confirm-order/confirm-order.vue
+++ b/pagesCreateOrder/confirm-order/confirm-order.vue
@@ -384,20 +384,20 @@
-
+
桌位费
- ¥{{ $seatFee.totalAmount.toFixed(2) || "0.00" }}
+ ¥{{ orderCostSummary.seatFee }}
-
+
打包费
- ¥{{ $packFee || "0.00" }}
+ ¥{{ orderCostSummary.packFee }}
@@ -412,7 +412,9 @@
实收金额
- ¥{{ orderCostSummary.finalPayAmount }}
+ ¥{{ orderCostSummary.finalPayAmount }}
@@ -479,7 +481,6 @@ import { getSafeBottomHeight } from "@/commons/utils/safe-bottom.js";
import go from "@/commons/utils/go.js";
import { hasPermission } from "@/commons/utils/hasPermission.js";
import { getNowCart } from "@/pagesCreateOrder/util.js";
-import { number } from "uview-plus/libs/function/test";
import { getShopTableDetail } from "@/http/api/table.js";
import { getShopInfo } from "@/http/api/shop.js";
@@ -622,7 +623,6 @@ const $seatFee = reactive({
* 打包费
*/
const $packFee = computed(() => {
- let packAmount = 0;
return goods.list
.reduce((prve, cur) => {
return prve + (cur.packFee || 0) * parseFloat(cur.pack_number).toFixed(2);
@@ -630,15 +630,6 @@ const $packFee = computed(() => {
.toFixed(2);
});
-/**
- * 菜品数量
- */
-const goodsNumber = computed(() => {
- const result = goods.list.reduce((prve, cur) => {
- return prve + cur.number;
- }, 0);
- return result;
-});
/**
* 判断是否是会员
@@ -652,57 +643,13 @@ const isVip = computed(() => {
);
});
-const discount_sale_amount = computed(() => {
- return goods.list
- .filter((v) => v.discount_sale_amount && v.discount_sale_amount > 0)
- .reduce((a, b) => {
- const lowMemberPrice = b.lowMemberPrice ? b.lowMemberPrice : b.lowPrice;
- const tPrice = isVip.value ? lowMemberPrice : b.lowPrice;
- return a + b.number * (tPrice - b.discount_sale_amount);
- }, 0);
-});
-function returnLimitPrice(data) {
- const price = yskUtils.limitUtils.returnPrice({
- goods: data,
- shopInfo: shopInfo,
- limitTimeDiscountRes: pageData.limitTimeDiscount,
- shopUserInfo: null,
- idKey: "id",
- });
- return price;
-}
-const goodsPrice = computed(() => {
- const goodsTotalPrice = goods.list.reduce((prve, cur) => {
- const lowMemberPrice = cur.lowMemberPrice
- ? cur.lowMemberPrice
- : cur.lowPrice;
- let price = isVip.value ? lowMemberPrice : cur.lowPrice;
- if (cur.is_time_discount) {
- price = returnLimitPrice(cur);
- }
- const tPrice = Math.floor(price * cur.number * 100) / 100;
- return prve + (cur.is_gift ? 0 : tPrice);
- }, 0);
- const tpackFee = $packFee.value > 0 ? $packFee.value * 1 : 0;
- return (goodsTotalPrice - discount_sale_amount.value + tpackFee || 0).toFixed(
- 2
- );
-});
-
-/**
- * 实收金额
- */
-const allPrice = computed(() => {
- const n = goodsPrice.value * 1 + $seatFee.totalAmount;
- return n.toFixed(2);
-});
/**
* 计算优惠金额
*/
const youhui = computed(() => {
- return 0
+ return 0;
});
function toFixed(price, item) {
@@ -752,16 +699,17 @@ function onMessage() {
switch (msg.operate_type) {
case "pad_init":
goods.list = [];
- console.log(msg.data);
+
msg.data.map((item) => {
cartItem = getNowCart(item, $goods, pageData.user);
- console.log(cartItem);
if (cartItem.isGrounding || cartItem.is_temporary == 1) {
cartControls(cartItem, "add");
+
} else {
delCart(cartItem.id);
}
});
+
if (pageData.eatTypes.isShow) {
if (pageData.eatTypes.active == "take-out") {
cartItem.pack_number = cartItem.number;
@@ -811,6 +759,9 @@ function onMessage() {
case "product_update":
init();
break;
+ case "pad_batch":
+ init();
+ break;
}
});
}
@@ -838,22 +789,28 @@ function cartControls(cartItem, type) {
pageData.table.tableCode = cartItem.table_code;
}
let cartIndex = 0;
+
goods.list.map((item, index) => {
if (item.id == cartItem.id) {
cartIndex = index;
}
});
+
+
if (type == "del") {
goods.list.splice(cartIndex, 1);
return;
}
if (type == "add") {
- goods.list.push(cartItem);
+ goods.list.push({...cartItem,packNumber:cartItem.pack_number});
}
if (type == "edit") {
goods.list[cartIndex].number = cartItem.number;
+ goods.list[cartIndex].pack_number = cartItem.pack_number;
+ goods.list[cartIndex].packNumber = cartItem.pack_number;
}
+
}
/**
@@ -880,6 +837,7 @@ async function getTbShopInfo() {
id: uni.getStorageSync("shopId"),
});
pageData.shopInfo = res.data;
+ seatFeeConfig.pricePerPerson = res.data.tableFee || 0;
uni.setStorageSync("shopInfo", res.data);
}
@@ -922,7 +880,18 @@ async function changeUseType() {
if (!goods.list.length) {
return;
}
- getCart();
+ websocketUtil.send(
+ JSON.stringify({
+ type: "pad",
+ is_pack: pageData.eatTypes.active == "take-out" ? 1 : 0,
+ account: uni.getStorageSync("shopInfo").id,
+ shop_id: uni.getStorageSync("shopInfo").id,
+ operate_type: "batch",
+ table_code: pageData.table.tableCode,
+ })
+ );
+
+ // getCart();
}
/**
@@ -1160,7 +1129,6 @@ async function createAnOrder() {
let vipPrice = isVip.value ? 1 : 0;
let placeNum = pageData.orderInfo ? pageData.orderInfo.placeNum + 1 : 1;
- let originAmount = goodsPrice.value * 1 + youhui.value * 1;
let par = {
shopId: pageData.shopInfo.id, //店铺Id
userId: pageData.user.userId, //用户Id
@@ -1168,12 +1136,12 @@ async function createAnOrder() {
dineMode: pageData.eatTypes.active, //用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
remark: pageData.form.note, //备注
seatNum: 0, //用餐人数
- packFee: $packFee.value, //打包费
- originAmount: originAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
+ packFee:pageData.eatTypes.active=='dine-in'?seatFeeConfig.personCount : 0, //打包费
+ originAmount: orderCostSummary.value.goodsRealAmount, //订单原金额(不包含打包费+餐位费)
placeNum: placeNum, //当前订单下单次数
waitCall: 0, //是否等叫 0 否 1 等叫
vipPrice: vipPrice, //是否使用会员价
- limitRate:pageData.limitTimeDiscount
+ limitRate: pageData.limitTimeDiscount,
};
if (!pageData.shopInfo.isTableFee && pageData.table && pageData.table.id) {
par.seatNum = userNumbers.defaultCateIndex * 1 + 1;
@@ -1186,7 +1154,7 @@ async function createAnOrder() {
console.log(res, "创建订单");
if (res.code != 200) {
uni.showToast({
- title: res.msg||'创建订单失败!',
+ title: res.msg || "创建订单失败!",
icon: "none",
});
return;
@@ -1223,7 +1191,7 @@ async function createAnOrder() {
"PAGES_ORDER_DETAIL",
{
id: res.data.id,
- dinnerType: pageData.eatTypes.active,
+ dinnerType: pageData.eatTypes.active,
},
"redirect"
);
@@ -1239,9 +1207,6 @@ async function createAnOrder() {
});
}
-
-
-
//选择的优惠券
const selCoupon = ref([]);
//活动列表
@@ -1303,6 +1268,7 @@ const orderExtraConfig = computed(() => {
});
// 订单费用汇总
const orderCostSummary = computed(() => {
+ console.log(goods.list, "购物车数据");
const costSummary = yskUtils.OrderPriceCalculator.calculateOrderCostSummary(
goods.list,
pageData.eatTypes.active,
@@ -1315,7 +1281,15 @@ const orderCostSummary = computed(() => {
console.log(" 订单费用汇总", costSummary);
return costSummary;
});
-
+watch(
+ () => $seatFee.totalNumber,
+ (newVal, oldVal) => {
+ seatFeeConfig.personCount = newVal;
+ },
+ {
+ immediate: true,
+ }
+);