问题修复

This commit is contained in:
2025-12-01 10:50:08 +08:00
parent 0c5ba4b092
commit d2ba7af340
14 changed files with 346 additions and 201 deletions

View File

@@ -143,6 +143,7 @@ export async function hasPermission(params) {
if(loginType=='0'){ if(loginType=='0'){
return true return true
} }
return true;
params = returnFormatParams(params) params = returnFormatParams(params)
if (!params) { if (!params) {
return infoBox.showToast('未找到相关权限请检查代码或在权限配置文件commons/utils/hasPermission.js文件进行修改或增加') return infoBox.showToast('未找到相关权限请检查代码或在权限配置文件commons/utils/hasPermission.js文件进行修改或增加')

View File

@@ -25,7 +25,7 @@ const model = {
// error类型的提示 // error类型的提示
showErrorToast: (title, duration) => { showErrorToast: (title, duration) => {
return model.showToast(title, duration, {icon: 'error'}) return model.showToast(title, duration, {icon: 'none'})
}, },
showLoading: (title = '请稍后' ) => { showLoading: (title = '请稍后' ) => {

View File

@@ -92,7 +92,6 @@ function commonsProcess(showLoading, httpReqCallback) {
return Promise.reject(bodyData); // 跳转到catch函数 return Promise.reject(bodyData); // 跳转到catch函数
} }
// http响应码不正确 // http响应码不正确
if (statusCode != 200 && statusCode != 204 && statusCode != 201) { if (statusCode != 200 && statusCode != 204 && statusCode != 201) {
isShowErrorToast = true; isShowErrorToast = true;
@@ -101,19 +100,25 @@ function commonsProcess(showLoading, httpReqCallback) {
infoBox.showToast(data.message || "服务器异常"); infoBox.showToast(data.message || "服务器异常");
return Promise.reject(bodyData); // 跳转到catch函数 return Promise.reject(bodyData); // 跳转到catch函数
} }
// 构造请求成功的响应数据 // 构造请求成功的响应数据
if (bodyData.code == 501) { if (bodyData.code == 501) {
return Promise.reject(bodyData); // 跳转到catch函数 return Promise.reject(bodyData); // 跳转到catch函数
} }
if(data.code!==200){
return Promise.reject(bodyData); // 跳转到catch函数
}
if (data.code == 200 && data.data === null) { if (data.code == 200 && data.data === null) {
return Promise.resolve(true); return Promise.resolve(true);
} }
return Promise.resolve(bodyData.data); return Promise.resolve(bodyData.data);
}) })
.catch((res) => { .catch((res) => {
console.log('res', res);
if (res.code == 401 || res.code == 501) { if (res.code == 401 || res.code == 501) {
storageManage.token(null, true); storageManage.token(null, true);
infoBox.showErrorToast(res.message || "请登录").then(() => { infoBox.showErrorToast(res.message || res.msg || "请登录").then(() => {
uni.redirectTo({ uni.redirectTo({
url: "/pages/login/index", url: "/pages/login/index",
}); });
@@ -122,16 +127,12 @@ function commonsProcess(showLoading, httpReqCallback) {
} }
if (res.status == 500) { if (res.status == 500) {
infoBox.showErrorToast(res.message || "服务器异常").then(() => {}); infoBox.showErrorToast(res.message ||res.msg || "服务器异常").then(() => {});
} }
infoBox.showErrorToast(res.message||res.msg || "服务器异常").then(() => {});
reqFinishFunc(); // 请求完毕的动作 reqFinishFunc(); // 请求完毕的动作
// 如果没有提示错误, 那么此处提示 异常。
if (!isShowErrorToast) {
infoBox.showErrorToast(`请求网络异常`);
}
return Promise.reject(res); return Promise.reject(res);
}) })
.finally(() => { .finally(() => {

View File

@@ -94,7 +94,7 @@
<view class="u-p-l-30 u-p-r-30 color-333" style=""> <view class="u-p-l-30 u-p-r-30 color-333" style="">
{{ item.number }} {{ item.number }}
</view> </view>
<template v-if="item.type != 'package'"> <template v-if="item.type != 'package' || (item.type == 'package'&&item.groupType==0)">
<view class="u-flex" @tap="updateNumber(true, index, item)"> <view class="u-flex" @tap="updateNumber(true, index, item)">
<image <image
src="/pagesCreateOrder/static/images/icon-add-black.svg" src="/pagesCreateOrder/static/images/icon-add-black.svg"
@@ -199,6 +199,9 @@
</view> </view>
</view> </view>
</view> </view>
<view style="height: 100px;"></view>
</scroll-view> </scroll-view>
<view <view
@@ -286,12 +289,14 @@
<ServingStyleModal <ServingStyleModal
v-model="servingStyleModalShow" v-model="servingStyleModalShow"
v-model:servingSel="subStatus"
@confirm="servingStyleConfirm" @confirm="servingStyleConfirm"
></ServingStyleModal> ></ServingStyleModal>
<!-- 下单确认 --> <!-- 下单确认 -->
<Modal <Modal
v-model="orderConfirmModalShow" v-model="orderConfirmModalShow"
title="下单确认" title="下单确认"
confirmText="确定" confirmText="确定"
@confirm="workerConfirm" @confirm="workerConfirm"
@@ -531,7 +536,6 @@ function setModalShow(key = "show", show = true, type = "", title = "") {
} }
modal.key = key; modal.key = key;
modal[key] = show; modal[key] = show;
console.log(modal, 123);
} }
function nullFun() {} function nullFun() {}
@@ -585,6 +589,7 @@ async function workerConfirm() {
return infoBox.showToast("请输入当前登录员工账号"); return infoBox.showToast("请输入当前登录员工账号");
} }
let newOldRes = null; let newOldRes = null;
console.log('props.orderInfo',props.orderInfo);
if (props.data.length >= 1) { if (props.data.length >= 1) {
newOldRes = await createOrder({ newOldRes = await createOrder({
shopId: uni.getStorageSync("shopId"), //店铺Id shopId: uni.getStorageSync("shopId"), //店铺Id
@@ -600,6 +605,7 @@ async function workerConfirm() {
vipPrice: false, //是否使用会员价 vipPrice: false, //是否使用会员价
limitRate: null, limitRate: null,
subStatus: subStatus.value, subStatus: subStatus.value,
orderId: props.orderInfo.id?props.orderInfo.id:"",
}); });
if (!newOldRes) { if (!newOldRes) {
return infoBox.showToast("创建订单失败"); return infoBox.showToast("创建订单失败");
@@ -607,6 +613,7 @@ async function workerConfirm() {
} }
form.workerAccount = ""; form.workerAccount = "";
subStatus.value = servingStyles[0].value
go.to("PAGES_TABLE_ORDER", { go.to("PAGES_TABLE_ORDER", {
orderId: newOldRes ? newOldRes.id : props.orderInfo.id, orderId: newOldRes ? newOldRes.id : props.orderInfo.id,
}); });
@@ -729,11 +736,12 @@ function touchend(e) {
} }
function clear() { function clear() {
edmits("clear", modal.key);
setModalShow("clear", false);
if (modal.type == "cart") { if (modal.type == "cart") {
hideGoods(); hideGoods();
} }
setModalShow("clear", false);
edmits("clear", modal.type);
// setModalShow('clear', false) // setModalShow('clear', false)
// edmits('clear') // edmits('clear')

View File

@@ -138,7 +138,20 @@
<template v-else> <template v-else>
<view class="u-flex w-full u-row-right"> <view class="u-flex w-full u-row-right">
<view class="u-flex icon-btn"> <view class="u-flex icon-btn">
<template v-if="data.chooseNumber"> <template v-if="carsProductIdNumberMap[data.id]">
<view class="u-flex" @tap.stop="emitEvent('reduce')">
<image
src="/pagesCreateOrder/static/images/icon-reduce.svg"
class="icon"
mode=""
>
</image>
</view>
<view class="u-font-32">
{{ carsProductIdNumberMap[data.id] }}
</view>
</template>
<!-- <template v-if="data.chooseNumber">
<view class="u-flex" @tap.stop="emitEvent('reduce')"> <view class="u-flex" @tap.stop="emitEvent('reduce')">
<image <image
src="/pagesCreateOrder/static/images/icon-reduce.svg" src="/pagesCreateOrder/static/images/icon-reduce.svg"
@@ -150,7 +163,7 @@
<view class="u-font-32"> <view class="u-font-32">
{{ data.chooseNumber }} {{ data.chooseNumber }}
</view> </view>
</template> </template> -->
<view <view
class="u-flex" class="u-flex"
@tap.stop=" @tap.stop="
@@ -173,7 +186,7 @@
</template> </template>
</view> </view>
<view class="bg-fff u-p-20 w-full"> <view class="bg-fff u-p-20 w-full">
<view class="u-flex u-row-between "> <view class="u-flex u-row-between">
<view class="u-font-40">{{ data.name }}</view> <view class="u-font-40">{{ data.name }}</view>
<view class="u-flex" v-if="is_time_discount"> <view class="u-flex" v-if="is_time_discount">
<view class="font-bold u-m-t-16 u-font-40"> <view class="font-bold u-m-t-16 u-font-40">
@@ -182,7 +195,9 @@
<view class="u-m-t-16 old-price"> ¥{{ data.lowPrice }} </view> <view class="u-m-t-16 old-price"> ¥{{ data.lowPrice }} </view>
</view> </view>
<view class="font-bold u-m-t-16 u-font-40" v-else> ¥{{ data.lowPrice }} </view> <view class="font-bold u-m-t-16 u-font-40" v-else>
¥{{ data.lowPrice }}
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -197,6 +212,7 @@ const yskUtils = inject("yskUtils");
const shopInfo = inject("shopInfo"); const shopInfo = inject("shopInfo");
dayjs.extend(isBetween); dayjs.extend(isBetween);
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { defaultTo } from "lodash";
const props = defineProps({ const props = defineProps({
limitTimeDiscount: { limitTimeDiscount: {
type: Object, type: Object,
@@ -246,6 +262,12 @@ const props = defineProps({
type: Number, type: Number,
default: 20, default: 20,
}, },
carsProductIdNumberMap: {
type: Object,
default: () => {
return {};
},
},
}); });
watch( watch(
@@ -298,7 +320,7 @@ const limitPrice = computed(() => {
return 0; return 0;
} }
const price = yskUtils.limitUtils.returnPrice({ const price = yskUtils.limitUtils.returnPrice({
goods: props.data, goods: props.data,
shopInfo: shopInfo, shopInfo: shopInfo,
limitTimeDiscountRes: props.limitTimeDiscount, limitTimeDiscountRes: props.limitTimeDiscount,
shopUserInfo: null, shopUserInfo: null,
@@ -383,7 +405,7 @@ function emitEvent(emitName) {
} }
.btn { .btn {
background: #FE4F1E; background: #fe4f1e;
border-radius: 16rpx; border-radius: 16rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
@@ -434,7 +456,7 @@ function emitEvent(emitName) {
z-index: 2; z-index: 2;
} }
.limit-discount { .limit-discount {
background-color: #FEB41E; background-color: #feb41e;
padding: 16rpx 44rpx; padding: 16rpx 44rpx;
white-space: nowrap; white-space: nowrap;
text-align: center; text-align: center;
@@ -453,4 +475,4 @@ function emitEvent(emitName) {
text-decoration: line-through; text-decoration: line-through;
color: #999; color: #999;
} }
</style> </style>

View File

@@ -161,6 +161,7 @@
@tapweigh="tapweigh($event, goodsIndex)" @tapweigh="tapweigh($event, goodsIndex)"
:data="goodsItem" :data="goodsItem"
:limitTimeDiscount="data.limitTimeDiscount" :limitTimeDiscount="data.limitTimeDiscount"
:carsProductIdNumberMap="carsProductIdNumberMap"
></cart-goods-item> ></cart-goods-item>
</view> </view>
</view> </view>
@@ -208,6 +209,7 @@
@reduce="goodsUpdate($event, goodsIndex, false)" @reduce="goodsUpdate($event, goodsIndex, false)"
:index="index" :index="index"
@tapweigh="tapweigh($event, goodsIndex)" @tapweigh="tapweigh($event, goodsIndex)"
:carsProductIdNumberMap="carsProductIdNumberMap"
:data="goodsItem" :data="goodsItem"
></cart-goods-item> ></cart-goods-item>
</view> </view>
@@ -249,7 +251,7 @@
:orderInfo="data.orderInfo" :orderInfo="data.orderInfo"
:historyOrder="data.historyOrder" :historyOrder="data.historyOrder"
:tableCode="data.table.tableCode" :tableCode="data.table.tableCode"
@clear="cleaCart" @clear="clearCart"
></my-car> ></my-car>
</view> </view>
</template> </template>
@@ -361,7 +363,9 @@ import yskUtils from "@/lib/index";
provide("yskUtils", yskUtils); provide("yskUtils", yskUtils);
import { useAccountStore } from "@/stores/account"; import { useAccountStore } from "@/stores/account";
import { useCartStore } from "@/stores/cart";
const accountStore = useAccountStore(); const accountStore = useAccountStore();
const cartStore = useCartStore();
provide("accountStore", accountStore); provide("accountStore", accountStore);
@@ -406,7 +410,15 @@ const tapweigh = (foodsindex, index) => {
}; };
// wx拿到的数据 // wx拿到的数据
const cars = reactive([]); const cars = ref([]);
//购物中车的商品对应的数量
const carsProductIdNumberMap = computed(() => {
return cars.value.reduce((prev, cur) => {
const productId = cur.product_id;
prev[productId] = (prev[productId] || 0) + cur.number * 1;
return prev;
}, {});
});
const layout = reactive({ const layout = reactive({
listMap: { listMap: {
default: { default: {
@@ -496,7 +508,10 @@ function showDetail(goods) {
function onMessage() { function onMessage() {
websocketUtil.offMessage(); websocketUtil.offMessage();
websocketUtil.onMessage(async (res) => { websocketUtil.onMessage(async (res) => {
cartStore.onMessage(res);
let msg = JSON.parse(res); let msg = JSON.parse(res);
console.log("indexonMessage===", msg);
let cartItem; let cartItem;
let cartArr = []; let cartArr = [];
if (msg.msg_id) { if (msg.msg_id) {
@@ -523,9 +538,12 @@ function onMessage() {
return prve; return prve;
}, []); }, []);
} }
if (msg.type == "bc") {
initCart();
}
switch (msg.operate_type) { switch (msg.operate_type) {
case "pad_init": case "pad_init":
cars.length = 0; cars.value = [];
if (!data.table.tableCode) { if (!data.table.tableCode) {
data.table.tableCode = msg.table_code; data.table.tableCode = msg.table_code;
uni.setStorageSync("msg_id", msg.msg_id); uni.setStorageSync("msg_id", msg.msg_id);
@@ -560,6 +578,11 @@ function onMessage() {
// infoBox.showToast('操作成功') // infoBox.showToast('操作成功')
break; break;
case "pad_edit": case "pad_edit":
cartItem = getNowCart(msg.data, cartArr);
console.log(cartItem);
cartControls(cartItem, "edit");
break;
case "edit": case "edit":
cartItem = getNowCart(msg.data, cartArr); cartItem = getNowCart(msg.data, cartArr);
cartControls(cartItem, "edit"); cartControls(cartItem, "edit");
@@ -571,13 +594,9 @@ function onMessage() {
cartControls(cartItem, "del"); cartControls(cartItem, "del");
break; break;
case "pad_cleanup": case "pad_cleanup":
cars.value = [];
case "cleanup": case "cleanup":
cars.length = 0; cars.value = [];
for (let i in data.tabbar) {
for (let k in data.tabbar[i].foods) {
data.tabbar[i].foods[k].chooseNumber = 0;
}
}
getHistoryOrderDetail(); getHistoryOrderDetail();
break; break;
case "init": case "init":
@@ -627,7 +646,8 @@ async function getHistoryOrderDetail() {
let res = await getHistoryOrder({ let res = await getHistoryOrder({
tableCode: data.table.tableCode, tableCode: data.table.tableCode,
}); });
if (!res.id) { if (!res.id || (res && res.status != "unpaid")) {
data.orderInfo = {};
return; return;
} }
data.orderInfo = res; data.orderInfo = res;
@@ -686,7 +706,7 @@ function cartControls(cartItem, type) {
let cartIndex = 0; let cartIndex = 0;
let product_id = cartItem.product_id; let product_id = cartItem.product_id;
// console.log(cars, 'cars值看id是否与cartItem匹配') // console.log(cars, 'cars值看id是否与cartItem匹配')
cars.map((item, index) => { cars.value.map((item, index) => {
if (item.id == cartItem.id) { if (item.id == cartItem.id) {
cartIndex = index; cartIndex = index;
product_id = item.product_id; product_id = item.product_id;
@@ -694,10 +714,6 @@ function cartControls(cartItem, type) {
} }
}); });
let $goods; let $goods;
console.log("layoutData.list", layoutData.list);
console.log("type", type);
console.log(cartItem, "cartItemid");
console.log(product_id, "product_id");
layoutData.list.forEach((ele) => { layoutData.list.forEach((ele) => {
ele.productList.forEach((res) => { ele.productList.forEach((res) => {
if (res.id == product_id) { if (res.id == product_id) {
@@ -708,23 +724,18 @@ function cartControls(cartItem, type) {
if (type == "del") { if (type == "del") {
console.log("del", $goods); console.log("del", $goods);
cars.splice(cartIndex, 1); cars.value.splice(cartIndex, 1);
if ($goods) $goods.chooseNumber = 0;
return; return;
} }
if (type == "add") { if (type == "add") {
cars.push(cartItem); cars.value.push(cartItem);
if ($goods) { if ($goods) {
$goods.chooseNumber = cartItem.number;
console.log("$goods", $goods);
console.log("cartItem", cartItem);
} }
} }
if (type == "edit") { if (type == "edit") {
editItem.value = $goods; editItem.value = $goods;
cars[cartIndex].number = cartItem.number; cars.value[cartIndex].number = cartItem.number;
if ($goods) { if ($goods) {
$goods.chooseNumber = cartItem.number;
} }
} }
} }
@@ -814,13 +825,6 @@ function setTabBar(category, goods, carsC) {
prve[cur.categoryId].push(cur); prve[cur.categoryId].push(cur);
return prve; return prve;
}, {}); }, {});
const chooseGoodsNumberMap = carsC.reduce((prve, cur) => {
if (!prve.hasOwnProperty(cur.productId)) {
prve[cur.productId] = 0;
}
prve[cur.productId] += cur.number;
return prve;
}, {});
let tabbar = category.map((v) => { let tabbar = category.map((v) => {
const foods = goodsCategoryMap[v.id] || []; const foods = goodsCategoryMap[v.id] || [];
return { return {
@@ -828,24 +832,12 @@ function setTabBar(category, goods, carsC) {
foods: foods.map((fgoods, index) => { foods: foods.map((fgoods, index) => {
return { return {
...fgoods, ...fgoods,
chooseNumber: chooseGoodsNumberMap[fgoods.id],
price: fgoods.lowPrice, price: fgoods.lowPrice,
isDan: fgoods.typeEnum !== "sku", isDan: fgoods.typeEnum !== "sku",
}; };
}), }),
}; };
}); });
// tabbar.push({
// name: '附加费',
// foods: [{
// name: "餐位费",
// price:$shop.value.tableFee,
// chooseNumber: 0,
// isSeatFee:true,
// isDan: true
// }
// ]
// })
tabbar = tabbar.filter((v) => { tabbar = tabbar.filter((v) => {
return v.foods.length; return v.foods.length;
}); });
@@ -948,16 +940,27 @@ function setUser(par) {
/** /**
* 清除购物车 * 清除购物车
*/ */
async function cleaCart(e) { async function clearCart(e) {
console.log("clearCart===", e);
if (e == "cart") { if (e == "cart") {
let params = { let params = {
...data.socketData, ...data.socketData,
operate_type: "cleanup", operate_type: "cleanup",
table_code: data.table.tableCode, table_code: data.table.tableCode,
}; };
console.log("购物车清空菜品参数===", params);
websocketUtil.send(JSON.stringify(params)); websocketUtil.send(JSON.stringify(params));
// websocketUtil.send(
// JSON.stringify({
// ...data.socketData,
// operate_type: "init",
// table_code: data.table.tableCode,
// })
// );
} else if (e == "allHistoryOrder") { } else if (e == "allHistoryOrder") {
if (!data.orderInfo.id) {
return;
}
await cancelOrder({ await cancelOrder({
orderId: data.orderInfo.id, orderId: data.orderInfo.id,
shopId: uni.getStorageSync("shopId"), shopId: uni.getStorageSync("shopId"),
@@ -987,12 +990,7 @@ async function cleaCart(e) {
} }
//点击清空购物车 //点击清空购物车
async function onClearCart() { async function onClearCart() {
cars.length = 0; cars.value = [];
for (let i in layoutData.list) {
for (let k in layoutData.list[i].productList) {
layoutData.list[i].productList[k].chooseNumber = 0;
}
}
} }
let $originGoods = []; let $originGoods = [];
@@ -1074,17 +1072,7 @@ async function getGoodsData(max = 6, isGetPrve = false) {
: "6-grid", : "6-grid",
productList: res2.productList.map((v) => { productList: res2.productList.map((v) => {
v.salePrice = v.lowPrice; v.salePrice = v.lowPrice;
const findGoodsInCar = cars.find((cars) => { return v;
return cars.productId == v.id;
});
if (findGoodsInCar) {
return {
...v,
chooseNumber: findGoodsInCar.number,
};
} else {
return v;
}
}), }),
hasAjax: true, hasAjax: true,
}; };
@@ -1164,10 +1152,7 @@ async function init() {
if (option.type == "add") { if (option.type == "add") {
setTabBar($category, $originGoods, []); setTabBar($category, $originGoods, []);
} }
let shopInfo = await getShopInfo({ let shopInfo = accountStore.shopInfo;
id: uni.getStorageSync("shopInfo").id,
});
uni.setStorageSync("shopInfo", shopInfo);
// 获取布局 // 获取布局
// const getLayoutData = await getLayout({}) // const getLayoutData = await getLayout({})
// 获取分类数据-获取商品分类 // 获取分类数据-获取商品分类
@@ -1227,12 +1212,12 @@ async function init() {
}); });
$originGoods = goods; $originGoods = goods;
if (option.type == "add") { if (option.type == "add") {
cars.length = 0; cars.value = [];
initCart(); initCart();
setTabBar($category, goods, []); setTabBar($category, goods, []);
return; return;
} }
setTabBar($category, goods, cars); setTabBar($category, goods, cars.value);
initCart(); initCart();
} }
@@ -1247,7 +1232,6 @@ function categoryEleInit() {
getElRect("u-tab-item" + i, instance.value, { getElRect("u-tab-item" + i, instance.value, {
rect: true, rect: true,
}).then((res) => { }).then((res) => {
console.log(res);
tabsEle.tabsItems[i] = { tabsEle.tabsItems[i] = {
width: res.width, width: res.width,
left: res.left, left: res.left,
@@ -1259,10 +1243,7 @@ function categoryEleInit() {
const surcharge = ref(null); const surcharge = ref(null);
function surchargeConfirm(e) { function surchargeConfirm(e) {
data.tabbar[data.tabbar.length - 1].foods.unshift({ data.tabbar[data.tabbar.length - 1].foods.unshift(e);
...e,
chooseNumber: 0,
});
} }
function surchargeShow() { function surchargeShow() {
@@ -1653,7 +1634,7 @@ async function guigeConfirm(sku, number, is_time_discount) {
if (res) { if (res) {
//更新 //更新
let { index } = res; let { index } = res;
let carGoods = cars[index]; let carGoods = cars.value[index];
let cartId = carGoods.id; let cartId = carGoods.id;
let newNumber = carGoods.number * 1 + suitNum; let newNumber = carGoods.number * 1 + suitNum;
let suitNum = goods.skuList[0].suitNum || 1; let suitNum = goods.skuList[0].suitNum || 1;
@@ -1712,7 +1693,7 @@ const $cacheGoods = {};
//修改购物车商品备注 //修改购物车商品备注
function updateCartRemark(e) { function updateCartRemark(e) {
let { remark, index, goods } = e; let { remark, index, goods } = e;
cars[index].note = remark; cars.value[index].note = remark;
let params = { let params = {
number: e.num, number: e.num,
id: e.goods.id, id: e.goods.id,
@@ -1784,10 +1765,10 @@ async function carsNumberChange(e) {
// 找到该规格商品在购物车中是否存在并返回index值以及对应的数据 // 找到该规格商品在购物车中是否存在并返回index值以及对应的数据
function findGoodsInCar($goods, skuId) { function findGoodsInCar($goods, skuId) {
const productId = $goods.id; const productId = $goods.id;
const goodsInCarIndex = cars.findIndex((carsGoods) => { const goodsInCarIndex = cars.value.findIndex((carsGoods) => {
return carsGoods.skuId == skuId && carsGoods.productId == productId; return carsGoods.skuId == skuId && carsGoods.productId == productId;
}); });
const carGoods = cars[goodsInCarIndex]; const carGoods = cars.value[goodsInCarIndex];
return carGoods return carGoods
? { ? {
index: goodsInCarIndex, index: goodsInCarIndex,
@@ -1796,16 +1777,6 @@ function findGoodsInCar($goods, skuId) {
: false; : false;
} }
function searchGoodsUpdate(goodsItem, goodsIndex, isAdd) {
goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd, goodsIndex);
}
function setSearchGoods(index, chooseNumber) {
if (index !== undefined) {
console.log(searchResult.value[index]);
searchResult.value[index].chooseNumber = chooseNumber;
}
}
async function goodsUpdate( async function goodsUpdate(
foodsindex, foodsindex,
index, index,
@@ -1835,7 +1806,7 @@ async function goodsUpdate(
if ($goods.type != "sku") { if ($goods.type != "sku") {
const step = isAdd ? 1 : -1; const step = isAdd ? 1 : -1;
//增加 //增加
let isShop = cars.find((ele) => ele.product_id == $goods.id); let isShop = cars.value.find((ele) => ele.product_id == $goods.id);
if (isShop) { if (isShop) {
let { sku_id, product_id, id, number, discount_sale_amount } = isShop; let { sku_id, product_id, id, number, discount_sale_amount } = isShop;
// 数量加减 // 数量加减
@@ -1848,15 +1819,14 @@ async function goodsUpdate(
operate_type: "del", operate_type: "del",
}; };
websocketUtil.send(JSON.stringify(params)); websocketUtil.send(JSON.stringify(params));
$goods.chooseNumber = num;
} else { } else {
let suitNum = $goods.skuList[0].suitNum || 1; let suitNum = $goods.skuList[0].suitNum || 1;
if (showCurrentInput) { if (showCurrentInput) {
//单规格 //单规格
let goodsInCarIndex = cars.findIndex((carsGoods) => { let goodsInCarIndex = cars.value.findIndex((carsGoods) => {
return carsGoods.product_id == $goods.skuList[0].productId; return carsGoods.product_id == $goods.skuList[0].productId;
}); });
let cartItem = cars[goodsInCarIndex]; let cartItem = cars.value[goodsInCarIndex];
num = cartItem.number * 1 + Number(showCurrentInput); num = cartItem.number * 1 + Number(showCurrentInput);
} }
@@ -1875,11 +1845,11 @@ async function goodsUpdate(
pack_number: 0, //数量 pack_number: 0, //数量
is_temporary: 0, //是否是临时菜 is_temporary: 0, //是否是临时菜
is_time_discount, is_time_discount,
is_print: 1,
}) })
); );
// $goods.chooseNumber = 1 // $goods.chooseNumber = 1
$goods.chooseNumber = num;
} }
} else { } else {
// 起售数量 // 起售数量
@@ -1904,6 +1874,7 @@ async function goodsUpdate(
pack_number: 0, //数量 pack_number: 0, //数量
is_temporary: 0, //是否是临时菜 is_temporary: 0, //是否是临时菜
is_time_discount, is_time_discount,
is_print: 1,
}; };
console.log(params, "发送消息"); console.log(params, "发送消息");
websocketUtil.send(JSON.stringify(params)); websocketUtil.send(JSON.stringify(params));
@@ -1950,12 +1921,12 @@ async function onSelTable() {
const { masterId } = await getMasterId(); const { masterId } = await getMasterId();
data.masterId = masterId; data.masterId = masterId;
const cartRes = await getCart(); const cartRes = await getCart();
cars.length = 0; cars.value = [];
const cartArr = getNowCart(cartRes); const cartArr = getNowCart(cartRes);
for (let i in cartArr) { for (let i in cartArr) {
cars.push(cartArr[i]); cars.value.push(cartArr[i]);
} }
setTabBar($category, $originGoods, cars); setTabBar($category, $originGoods, cars.value);
} }
onBeforeUnmount(() => {}); onBeforeUnmount(() => {});
@@ -1966,7 +1937,7 @@ function watchUpdate() {
// data.table = { // data.table = {
// tableId: "" // tableId: ""
// } // }
cars.length = 0; cars.value = [];
init(); init();
}); });
// 添加临时菜到购物车 // 添加临时菜到购物车
@@ -1988,6 +1959,8 @@ onShow(() => {
if (!data.userInfo.shopName) { if (!data.userInfo.shopName) {
loginShowOut(); loginShowOut();
} }
getHistoryOrderDetail();
nextTick(() => { nextTick(() => {
uni.showLoading({ uni.showLoading({
title: "购物车加载中", title: "购物车加载中",
@@ -2014,22 +1987,26 @@ let sysInfo = ref({
}); });
const limitTimeDiscountRes = ref(null); const limitTimeDiscountRes = ref(null);
async function getLimit() { async function getLimit() {
const res = await limitTimeDiscountApi.limitTimeDiscount(); const res = await limitTimeDiscountApi.limitTimeDiscount({
limitTimeDiscountRes.value = res; shopId: accountStore.shopId,
if (data.table.tableCode) { });
data.limitTimeDiscount = limitTimeDiscountRes.value; if (res && res.id) {
limitTimeDiscountRes.value = res;
if (data.table.tableCode) {
data.limitTimeDiscount = limitTimeDiscountRes.value;
websocketUtil.send( websocketUtil.send(
JSON.stringify({ JSON.stringify({
type: "shopping", type: "shopping",
operate_type: "time_discount_save", operate_type: "time_discount_save",
table_code: data.table.tableCode, table_code: data.table.tableCode,
shop_id: uni.getStorageSync("shopInfo").id, shop_id: uni.getStorageSync("shopInfo").id,
operate_type: "time_discount_save", operate_type: "time_discount_save",
data: limitTimeDiscountRes.value, data: limitTimeDiscountRes.value,
}) })
); );
console.log("limitTimeDiscount", data.limitTimeDiscount); console.log("limitTimeDiscount", data.limitTimeDiscount);
}
} }
} }
@@ -2037,7 +2014,6 @@ async function getTableDetail() {
let res = await $returnTableDetail({ let res = await $returnTableDetail({
tableCode: data.table.tableCode, tableCode: data.table.tableCode,
}); });
console.log(res, "getTableDetail");
if (res && res.tableCode) { if (res && res.tableCode) {
data.table = res; data.table = res;
} }

View File

@@ -26,7 +26,7 @@
:key="index" :key="index"
class="item" class="item"
@click="itemClick(item)" @click="itemClick(item)"
:class="[selItem && selItem.id == item.id ? 'selected' : '']" :class="[selItem && selItem.tableCode == item.tableCode ? 'selected' : '']"
> >
<view class="u-flex u-row-between"> <view class="u-flex u-row-between">
<view class="u-flex gap-20"> <view class="u-flex gap-20">
@@ -91,7 +91,7 @@ const props = defineProps({
const selItem = ref(""); const selItem = ref("");
function itemClick(item) { function itemClick(item) {
if (selItem.value && selItem.value.id == item.id) { if (selItem.value && selItem.value.tableCode == item.tableCode) {
selItem.value = ""; selItem.value = "";
return; return;
} }
@@ -112,7 +112,7 @@ watch(
() => modelValue.value, () => modelValue.value,
(newVal, oldVal) => { (newVal, oldVal) => {
console.log(newVal, oldVal); console.log(newVal, oldVal);
selItem.value = list.value.find((item) => item.id == newVal); selItem.value = list.value.find((item) => item.tableCode == newVal);
console.log(selItem.value); console.log(selItem.value);
if (selItem.value) { if (selItem.value) {
goodsName.value = selItem.value.name; goodsName.value = selItem.value.name;
@@ -123,10 +123,10 @@ watch(
watch( watch(
() => list.value.length, () => list.value.length,
(newVal, oldVal) => { (newVal, oldVal) => {
selItem.value = list.value.find((item) => item.id == modelValue.value); selItem.value = list.value.find((item) => item.tableCode == modelValue.value);
console.log(selItem.value); console.log(selItem.value);
if (selItem.value) { if (selItem.value) {
modelValue.value = selItem.value.id; modelValue.value = selItem.value.tableCode;
goodsName.value = selItem.value.name; goodsName.value = selItem.value.name;
} }
} }
@@ -143,12 +143,12 @@ function confirm() {
}); });
return; return;
} }
modelValue.value = selItem.value.id; modelValue.value = selItem.value.tableCode;
show.value = false; show.value = false;
} }
async function getTablelist() { async function getTablelist() {
const res = await tableApi.getShopTable({ size: 999 }); const res = await tableApi.getShopTable({ size: 999 });
list.value = res.records || []; list.value = (res.records || []).filter((item) => item.tableCode);
} }
onMounted(() => { onMounted(() => {
getTablelist(); getTablelist();

View File

@@ -43,7 +43,7 @@
import { ref, reactive, toRaw, watch, computed ,inject} from "vue"; import { ref, reactive, toRaw, watch, computed ,inject} from "vue";
const accountStore=inject('accountStore') const accountStore=inject('accountStore')
const cartStore=inject('cartStore') const cartStore=inject('cartStore')
const orderBtns = [ const $orderBtns = [
{ {
name: "单品改价", name: "单品改价",
value: "changePrice", value: "changePrice",
@@ -56,6 +56,22 @@ const orderBtns = [
name: "赠菜", name: "赠菜",
value: "gift", value: "gift",
}, },
{
name: "打包",
value: "pack",
},
// {
// name: "等叫",
// value: "wait",
// },
// {
// name: "免厨打",
// value: "noPrint",
// },
// {
// name: "单品备注",
// value: "remark",
// },
{ {
name: "单品上菜", name: "单品上菜",
value: "serve", value: "serve",
@@ -69,9 +85,6 @@ const orderBtns = [
value: "startCooking", value: "startCooking",
}, },
]; ];
const selCart = defineModel("selCart", {
default: null,
});
const tableBtns = [ const tableBtns = [
{ {
name: "换台", name: "换台",
@@ -82,6 +95,21 @@ const tableBtns = [
value: "clearTable", value: "clearTable",
}, },
]; ];
const payBeforeBtns = ['单品改价','单品转台','赠菜','打包'];
const orderBtns=computed(()=>{
if(cartStore.shopInfo.registerType=='after'){
return $orderBtns
}
return $orderBtns.filter(v=>payBeforeBtns.find(item=>item==v.name))
})
const selCart = defineModel("selCart", {
default: null,
});
const servingSel = ref(""); const servingSel = ref("");
const tableSel = ref(""); const tableSel = ref("");
const emits = defineEmits(["btnClick"]); const emits = defineEmits(["btnClick"]);

View File

@@ -18,9 +18,13 @@
> >
<view class="u-flex"> <view class="u-flex">
<text>{{ item.productName }}</text> <text>{{ item.productName }}</text>
<view class="u-flex gap-10" style="margin-left: 40rpx"> <view class="u-flex gap-20" style="margin-left: 40rpx">
<text class="status gift" v-if="item.isGift"></text> <text class="status gift" v-if="item.isGift"></text>
<template v-if="item.subStatus"> <text class="status pack" v-if="item.packNumber > 0"
>
<view class="badge">{{ item.packNumber }}</view>
</text>
<template v-if="item.subStatus &&cartStore.shopInfo.registerType=='after'">
<text <text
class="status" class="status"
:class="[ :class="[
@@ -78,7 +82,7 @@
</view> </view>
<text class="u-flex-1"> <text class="u-flex-1">
{{ cartStore.packFee }} {{ cartStore.orderCostSummary.packFee }}
</text> </text>
</view> </view>
</view> </view>
@@ -107,12 +111,18 @@ const timer = setInterval(() => {
}, 1000); }, 1000);
//超时时间 //超时时间
const maxTime = 10 * 60 * 1000; const maxTime = cartStore.shopInfo.serveTime*60*1000;
function returnStatusClass(item) { function returnStatusClass(item) {
if (item.subStatus == "DELIVERED") { if (item.subStatus == "DELIVERED") {
return "success"; return "success";
} }
if (item.subStatus == "READY_TO_SERVE") {
return "warning";
}
if (item.subStatus == "SENT_OUT") {
return "green";
}
} }
/** /**
* 返回商品状态文本 * 返回商品状态文本
@@ -123,7 +133,7 @@ function returnSubStatusText(item) {
return "待起菜"; return "待起菜";
} }
if (item.subStatus == "READY_TO_SERVE") { if (item.subStatus == "READY_TO_SERVE") {
if (item.startOrderTime) { if (item.startOrderTime&&cartStore.shopInfo.isServeTimeControl) {
const maxWaitTime = dayjs(item.startOrderTime).add( const maxWaitTime = dayjs(item.startOrderTime).add(
maxTime, maxTime,
"millisecond" "millisecond"
@@ -215,6 +225,7 @@ function itemClick(item) {
color: #999; color: #999;
border-color: #999; border-color: #999;
background-color: rgba(153, 153, 153, 0.25); background-color: rgba(153, 153, 153, 0.25);
position: relative;
&.default { &.default {
} }
&.timeout { &.timeout {
@@ -227,13 +238,44 @@ function itemClick(item) {
border-color: $my-main-color; border-color: $my-main-color;
background-color: rgba(63, 158, 255, 0.25); background-color: rgba(63, 158, 255, 0.25);
} }
&.green {
$color: rgba(52, 199, 89, 1);
border-color: $color;
color: $color;
background-color: rgba(52, 199, 89, 0.25);
}
&.warning {
$color: #ff8d28;
border-color: $color;
color: $color;
background-color: rgba(255, 141, 40, 0.25);
}
&.gift { &.gift {
$color: rgb(255, 159, 46); $color: rgb(255, 159, 46);
color: $color; color: $color;
background-color: rgb(255, 240, 223); background-color: rgb(255, 240, 223);
border-color: $color; border-color: $color;
} }
&.pack {
$color: rgb(49, 138, 254);
color: $color;
background-color: rgb(49, 138, 254, 0.25);
border-color: $color;
}
.badge {
position: absolute;
text-align: center;
$height:32rpx;
line-height: $height;
height: $height;
top: calc(-#{$height} / 2);
right: calc(-#{$height} / 2);
width: $height;
border-radius: 50%;
font-size: 20rpx;
color: #fff;
background-color: #ff383c;
}
} }
.old-price { .old-price {
text-decoration: line-through; text-decoration: line-through;

View File

@@ -52,7 +52,7 @@
<!-- 转桌 --> <!-- 转桌 -->
<Modal <Modal
v-model="modalData.show" v-model="modalData.show"
:width="modalData.key != 'editPersonCount' ? '800rpx' : ''" :width="modalData.key == 'btnClick' ? '800rpx' : ''"
:title="modalData.title" :title="modalData.title"
confirmText="确定" confirmText="确定"
@confirm="modalConfirm" @confirm="modalConfirm"
@@ -68,6 +68,17 @@
></up-number-box> ></up-number-box>
</view> </view>
</template> </template>
<template v-if="modalData.key == 'pack'">
<view class="u-p-40 u-font-32 color-333 u-flex u-flex-x-center">
<up-number-box
v-model="modalData.form.packNumber"
integer
:min="0"
:max="packNumberMax"
inputWidth="200"
></up-number-box>
</view>
</template>
<template v-if="modalData.key == 'btnClick'"> <template v-if="modalData.key == 'btnClick'">
<view class="u-p-40 u-font-32 color-333"> <view class="u-p-40 u-font-32 color-333">
<view class="u-flex"> <view class="u-flex">
@@ -80,22 +91,23 @@
></chooseTables> ></chooseTables>
</view> </view>
</view> </view>
<view class="u-flex u-m-t-44">
<text class="font-bold u-m-r-52">转入类型</text>
<up-radio-group v-model="modalData.form.type" placement="row">
<up-radio
:key="1"
label="转桌(部分商品转入)"
:name="1"
></up-radio>
<up-radio
:key="2"
label="并桌(全部商品转入)"
:name="2"
></up-radio>
</up-radio-group>
</view>
<template v-if="modalData.form.type == 1"> <template v-if="modalData.form.type == 1">
<!-- <view class="u-flex u-m-t-44">
<text class="font-bold u-m-r-52">转入类型</text>
<up-radio-group v-model="modalData.form.type" placement="row">
<up-radio
:key="1"
label="转桌(部分商品转入)"
:name="1"
></up-radio>
<up-radio
:key="2"
label="并桌(全部商品转入)"
:name="2"
></up-radio>
</up-radio-group>
</view> -->
<view class="u-flex u-m-t-44"> <view class="u-flex u-m-t-44">
<text class="font-bold u-m-r-52">购物车商品</text> <text class="font-bold u-m-r-52">购物车商品</text>
</view> </view>
@@ -130,13 +142,14 @@ import * as areaApi from "@/http/api/area.js";
import yskUtils from "ysk-utils"; import yskUtils from "ysk-utils";
import go from "@/commons/utils/go.js"; import go from "@/commons/utils/go.js";
import { reactive, ref, provide, computed,inject } from "vue"; import { reactive, ref, provide, computed, inject } from "vue";
const websocketUtil=inject("websocketUtil") const websocketUtil = inject("websocketUtil");
const cartStore = useCartStore(); const cartStore = useCartStore();
const accountStore = useAccountStore(); const accountStore = useAccountStore();
cartStore.shopInfo=accountStore.shopInfo; cartStore.shopInfo = accountStore.shopInfo;
websocketUtil.offMessage();
websocketUtil.onMessage((data) => { websocketUtil.onMessage((data) => {
cartStore.onMessage(data); cartStore.onMessage(data);
}); });
@@ -145,6 +158,7 @@ const modalData = reactive({
key: "", key: "",
title: "", title: "",
form: { form: {
packNumber: 0,
personCount: 0, personCount: 0,
targetTableCode: "", targetTableCode: "",
checks: [], checks: [],
@@ -192,35 +206,69 @@ async function transferTable() {
targetTableCode: modalData.form.targetTableCode, targetTableCode: modalData.form.targetTableCode,
detailIds, detailIds,
}); });
if (!res) {
uni.showModal({
title: "转桌失败",
icon: "none",
});
return;
}
uni.showToast({ uni.showToast({
title: "转桌成功", title: "转桌成功",
icon: "none", icon: "none",
}); });
if (modalData.form.type == 2) {
await orderApi.cancelOrder({
orderId: cartStore.order.id,
shopId: cartStore.order.shopId,
});
const orderRes = await orderApi.getHistoryOrder({ const tableRes = await tableApi.getShopTableDetail({
tableCode: modalData.form.targetTableCode, tableCode: modalData.form.targetTableCode,
}); });
if (orderRes) { if (tableRes && tableRes.id) {
options.orderId = orderRes.id; uni.$emit("choose-table", tableRes);
getOrderById(); }
modalData.show = false; const orderRes = await orderApi.getHistoryOrder({
modalData.form.targetTableCode = []; tableCode: modalData.form.targetTableCode,
modalData.form.checks = []; });
modalData.form.type = 1; if (orderRes) {
options.orderId = orderRes.id;
}
} }
getOrderById();
modalData.show = false;
modalData.form.targetTableCode = [];
modalData.form.checks = [];
modalData.form.type = 1;
} }
async function editPersonCount() { async function editPersonCount() {
cartStore.personCount = modalData.form.personCount; cartStore.personCount = modalData.form.personCount;
modalData.show = false; modalData.show = false;
} }
function editPackNumber() {
const par = {
id: selCart.value.id,
product_id: selCart.value.product_id,
sku_id: selCart.value.sku_id,
pack_number: modalData.form.packNumber,
};
modalData.show = false;
modalData.form.packNumber = 0;
updateCart(par);
}
async function modalConfirm(key) { async function modalConfirm(key) {
if (modalData.key == "transferTable") { if (modalData.key == "btnClick") {
transferTable(); transferTable();
} }
if (modalData.key == "editPersonCount") { if (modalData.key == "editPersonCount") {
editPersonCount(); editPersonCount();
} }
if (modalData.key == "pack") {
editPackNumber();
}
} }
provide("cartStore", cartStore); provide("cartStore", cartStore);
@@ -229,6 +277,13 @@ provide("accountStore", accountStore);
const selCart = ref(null); const selCart = ref(null);
const packNumberMax = computed(() => {
if (selCart.value) {
return selCart.value.num;
}
return 0;
});
function back() { function back() {
uni.navigateBack(); uni.navigateBack();
} }
@@ -282,9 +337,19 @@ async function getTablelist() {
tableList.value = res.records || []; tableList.value = res.records || [];
} }
async function shopTableClear() { async function shopTableClear() {
const res = await tableApi.shopTableClear({ const res = await orderApi.cancelOrder({
id: cartStore.table.id, orderId: cartStore.order.id,
shopId: accountStore.shopInfo.id,
}); });
if (res) {
uni.showToast({
title: "清台成功",
icon: "none",
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
}
} }
async function btnClick(type) { async function btnClick(type) {
if (type == "editPersonCount") { if (type == "editPersonCount") {
@@ -300,7 +365,7 @@ async function btnClick(type) {
if (type == "clearTable") { if (type == "clearTable") {
uni.showModal({ uni.showModal({
title: "提示", title: "提示",
content: "是否清空该桌订单", content: "该操作会取消未支付的订单,且无法恢复,是否确认清空该桌订单",
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
console.log("清空该桌订单"); console.log("清空该桌订单");
@@ -310,15 +375,14 @@ async function btnClick(type) {
}); });
} }
if (type == "transfer") { if (type == "transfer") {
modalData.form.type == 1; modalData.form.type = 1;
modalData.title = "转桌"; modalData.title = "转桌";
modalData.show = true; modalData.show = true;
} }
if (type == "changeTable") { if (type == "changeTable") {
modalData.form.type == 2; modalData.form.type = 2;
modalData.title = "转桌"; modalData.title = "转桌";
modalData.show = true; modalData.show = true;
} }
if (type == "serveAll") { if (type == "serveAll") {
@@ -332,6 +396,15 @@ async function btnClick(type) {
if (!selCart.value) { if (!selCart.value) {
return; return;
} }
selCart.value = cartStore.allCartList.find((v) => v.id == selCart.value.id);
if (type === "pack") {
modalData.title = "打包";
modalData.key = "pack";
modalData.show = true;
console.log(selCart.value);
modalData.form.packNumber = selCart.value.packNumber;
}
if (type == "changePrice") { if (type == "changePrice") {
showModel("discount"); showModel("discount");
return; return;

View File

@@ -26,6 +26,7 @@ export function getNowCart(carItem,goodsList,user) {
carItem.packFee = goodsItem.packFee carItem.packFee = goodsItem.packFee
carItem.type = goodsItem.type carItem.type = goodsItem.type
carItem.isGrounding = true; carItem.isGrounding = true;
carItem.groupType = goodsItem.groupType
} }
carItem.number = parseFloat(carItem.number) carItem.number = parseFloat(carItem.number)
}) })
@@ -37,7 +38,6 @@ export function getNowCart(carItem,goodsList,user) {
carItem.discount_sale_amount = carItem.discount_sale_amount?carItem.discount_sale_amount*1:0 carItem.discount_sale_amount = carItem.discount_sale_amount?carItem.discount_sale_amount*1:0
carItem.discountSaleAmount = carItem.discount_sale_amount carItem.discountSaleAmount = carItem.discount_sale_amount
} }
console.log("carItem===",carItem)
return carItem return carItem
} }

View File

@@ -15,7 +15,7 @@
<view style="height: 200rpx;"></view> <view style="height: 200rpx;"></view>
<view class="u-fixed bottom bg-fff "> <view class="u-fixed bottom bg-fff ">
<view class="u-flex u-abso"> <view class="u-flex u-abso">
<template v-if="orderDetail.info.dineMode=='take-out'||!orderDetail.info.tableCode||pageData.shopInfo.registerType=='before'"> <template v-if="orderDetail.info.dineMode=='take-out'||!orderDetail.info.tableCode|| (pageData.shopInfo&&pageData.shopInfo.registerType=='before')">
<view class="u-flex-1" v-if="orderDetail.info.status=='unpaid'"> <view class="u-flex-1" v-if="orderDetail.info.status=='unpaid'">
<my-button @tap="toPay" borderRadius="100rpx" shape="circle" <my-button @tap="toPay" borderRadius="100rpx" shape="circle"
type="primary">结账</my-button> type="primary">结账</my-button>

View File

@@ -347,6 +347,9 @@ import {
} from "../quan_util.js"; } from "../quan_util.js";
import { mathFloorPrice } from "@/commons/utils/goodsUtil.js"; import { mathFloorPrice } from "@/commons/utils/goodsUtil.js";
import { getDiscountByUserId } from "@/http/yskApi/market/consumeDiscount.js"; import { getDiscountByUserId } from "@/http/yskApi/market/consumeDiscount.js";
import { useCartStore } from "@/stores/cart.js";
const cartStore = useCartStore();
// import { getCouponList } from '@/http/api/coupon.js' // import { getCouponList } from '@/http/api/coupon.js'
import { getHistoryOrder } from "@/http/api/order.js"; import { getHistoryOrder } from "@/http/api/order.js";
@@ -1251,6 +1254,7 @@ async function pay(par) {
function paySuccess() { function paySuccess() {
infoBox.showToast("支付成功"); infoBox.showToast("支付成功");
payStatus = "success"; payStatus = "success";
cartStore.personCount=0;
setTimeout(() => { setTimeout(() => {
// uni.$emit('orderDetail:update') // uni.$emit('orderDetail:update')
uni.$emit("get:table"); uni.$emit("get:table");

View File

@@ -11,6 +11,7 @@ export function formatCartGoods(goods) {
number: goods.number || goods.num, number: goods.number || goods.num,
isGift: goods.isGift || goods.is_gift || 0, isGift: goods.isGift || goods.is_gift || 0,
is_gift: goods.is_gift || goods.isGift || 0, is_gift: goods.is_gift || goods.isGift || 0,
packFee: goods.packFee || goods.packAmount,
}; };
} }
@@ -201,11 +202,10 @@ export const useCartStore = defineStore("cart", {
case "pad_init": case "pad_init":
this.cartList = msg.data; this.cartList = msg.data;
this.limitTimeDiscount = msg.time_dis_info; this.limitTimeDiscount = msg.time_dis_info;
this.getOrder();
break; break;
case "pad_add": case "pad_add":
case "add": case "add":
cartItem = getNowCart(msg.data, $goods, pageData.user);
cartControls(cartItem, "add");
break; break;
case "pad_edit": case "pad_edit":
break; break;
@@ -217,28 +217,18 @@ export const useCartStore = defineStore("cart", {
this.getOrder(); this.getOrder();
break; break;
case "edit": case "edit":
getCart();
break; break;
case "pad_del": case "pad_del":
break; break;
case "del": case "del":
cartItem = getNowCart(msg.data, $goods, pageData.user);
cartControls(cartItem, "del");
break; break;
case "pad_cleanup": case "pad_cleanup":
case "cleanup": case "cleanup":
goods.list = []; this.goodsList=[]
$seatFee.totalNumber = 0;
$seatFee.totalAmount = 0;
userNumbers.defaultCateIndex = 0;
init();
break; break;
case "product_update": case "product_update":
init();
break; break;
case "pad_batch": case "batch":
init();
break; break;
} }
}, },