问题修复

This commit is contained in:
2025-12-05 19:22:28 +08:00
parent 2c2a87ab19
commit 7fdabf1507
10 changed files with 442 additions and 345 deletions

View File

@@ -1,95 +1,142 @@
import { import { reactive, ref } from 'vue';
reactive,
ref
} from 'vue';
// WebSocket 工具类,封装了 WebSocket 的连接、发送、接收、心跳、重连和关闭等操作 // WebSocket 工具类,封装了 WebSocket 的连接、发送、接收、心跳、重连和关闭等操作
class WebsocketUtil { class WebsocketUtil {
// 构造函数,初始化 WebSocket 连接 // 构造函数,初始化 WebSocket 连接
constructor(url, time, params) { constructor(url, time, params) {
this.url = url; // WebSocket 服务器的 URL this.url = url; // WebSocket 服务器的 URL
this.params = params; // WebSocket 服务器的 URL this.params = params; // WebSocket 连接参数
this.time = time; // 心跳发送的间隔时间(秒) this.time = time; // 心跳发送的间隔时间(秒)
this.socketTask = null; // WebSocket 任务对象 this.socketTask = null; // WebSocket 任务对象
this.isOpen = false; // WebSocket 连接是否打开 this.isOpen = false; // WebSocket 连接是否打开
// 定时器相关
this.reconnectTimeout = null; // 重连定时器 this.reconnectTimeout = null; // 重连定时器
this.heartbeatInterval = null; // 心跳定时器 this.heartbeatInterval = null; // 心跳定时器
this.heartbeatTimeout = null; // 心跳超时定时器(检测 pong 响应)
this.checkConnectionInterval = null; // 连接状态主动检查定时器
// 消息回调数组
this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组 this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组
this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组
// 重连策略配置
this.reconnectAttempts = 0; // 当前重连次数
this.reconnectMaxAttempts = 5; // 最大重连次数(设为 Infinity 表示无限重试)
this.reconnectDelay = 3000; // 基础重连延迟(毫秒)
this.maxReconnectDelay = 30000; // 最大重连延迟(毫秒)
// 初始化 WebSocket 连接 // 初始化 WebSocket 连接
this.initializeWebSocket(); this.initializeWebSocket();
// 监听设备唤醒事件(浏览器环境)
if (typeof document !== 'undefined') {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
// 页面可见时,主动检查连接
this.checkConnection();
}
});
}
} }
// 初始化 WebSocket 连接 // 初始化 WebSocket 连接
initializeWebSocket() { initializeWebSocket() {
console.log('初始化WebSocket连接'); console.log('初始化WebSocket连接');
if (this.isOpen) { if (this.isOpen) {
return return;
} }
this.socketTask = uni.connectSocket({ this.socketTask = uni.connectSocket({
url: this.url, url: this.url,
success: () => { success: () => {
console.log('WebSocket连接成功'); console.log('WebSocket连接请求发送成功');
return this.socketTask;
}, },
fail: (error) => { fail: (error) => {
console.error('WebSocket连接失败', error); console.error('WebSocket连接失败', error);
uni.$emit('is-socket-open', true) uni.$emit('is-socket-open', false);
this.reconnect(); this.reconnect();
} }
}); });
// 连接打开事件
this.socketTask.onOpen((res) => { this.socketTask.onOpen((res) => {
console.log('WebSocket连接正常==', res); console.log('WebSocket连接正常==', res);
this.isOpen = true; this.isOpen = true;
// 连接成功后启动心跳和消息监听 // 重置重连状态
this.reconnectAttempts = 0;
this.reconnectDelay = 3000;
// 启动心跳和消息监听
this.startHeartbeat(); this.startHeartbeat();
this.listenForMessages(); this.listenForMessages();
uni.$emit('is-socket-open', true) uni.$emit('is-socket-open', true);
}); });
// 连接错误事件
this.socketTask.onError((res) => { this.socketTask.onError((res) => {
console.log('WebSocket连接失败==', res); console.log('WebSocket连接错误==', res);
uni.$emit('is-socket-open', false) uni.$emit('is-socket-open', false);
this.reconnect(); this.reconnect();
}); });
// 注意:这里的 onClose 监听器应该放在 uni.connectSocket 调用之后
this.socketTask.onClose((result) => {
this.isOpen = false;
// if( this.isOpen ){
this.reconnect();
// }
});
// 连接关闭事件
this.socketTask.onClose((result) => {
console.log('WebSocket连接已关闭', result);
this.isOpen = false;
this.reconnect();
});
// 启动连接状态主动检查30秒一次
this.startConnectionCheck();
} }
// 启动心跳检测 // 启动心跳检测
startHeartbeat() { startHeartbeat() {
if (this.heartbeatInterval) { // 清除现有定时器
clearInterval(this.heartbeatInterval); if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
} if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout);
this.heartbeatInterval = setInterval(() => { this.heartbeatInterval = setInterval(() => {
if (this.isOpen) { if (this.isOpen) {
this.send(JSON.stringify({"type": "ping_interval","set": "pad"})); // 发送心跳包
this.send(JSON.stringify({ "type": "ping_interval", "set": "pad" }));
// 设置5秒超时若未收到pong则重连
this.heartbeatTimeout = setTimeout(() => {
console.log('心跳超时,主动断开并重连');
this.closeSocket();
this.reconnect();
}, 5000);
} }
}, this.time); }, this.time);
} }
// 启动连接状态主动检查30秒一次
startConnectionCheck() {
if (this.checkConnectionInterval) clearInterval(this.checkConnectionInterval);
this.checkConnectionInterval = setInterval(() => {
if (!this.isOpen && !this.reconnectTimeout) {
console.log('主动检查到连接断开,触发重连');
this.reconnect();
}
}, 30000);
}
// 发送消息 // 发送消息
send(data, type) { send(data, type) {
if (this.socketTask && this.isOpen) { if (this.socketTask && this.isOpen) {
this.socketTask.send({ this.socketTask.send({
data: data, data: data,
success: (res) => { success: (res) => {
// console.log('消息发送成功', res); // 发送成功,重置心跳(可选,根据业务需求)
this.startHeartbeat(); this.startHeartbeat();
}, },
fail: (error) => { fail: (error) => {
console.error('消息发送失败', error); console.error('消息发送失败', error);
this.reconnect(); // 这里可能需要根据实际情况判断是否重连 this.reconnect();
} }
}); });
} else {
console.warn('WebSocket未连接无法发送消息');
} }
} }
@@ -97,26 +144,53 @@ class WebsocketUtil {
listenForMessages() { listenForMessages() {
if (this.socketTask) { if (this.socketTask) {
this.socketTask.onMessage((res) => { this.socketTask.onMessage((res) => {
const { const data = res.data.toString();
data try {
} = res; // 尝试解析JSON处理pong响应
this.messageCallbacks.forEach(callback => callback(data const message = JSON.parse(data);
.toString())); // 假设 data 是字符串或可转换为字符串 if (message.type === 'pong') {
// 收到pong清除心跳超时
if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout);
}
} catch (e) {
console.warn('消息解析失败非JSON格式:', e);
}
// 触发外部注册的回调函数
this.messageCallbacks.forEach(callback => callback(data));
}); });
// this.send("WebSocket连接正常");
} else { } else {
console.error('WebSocket 连接尚未建立,无法监听消息'); console.error('WebSocket 连接尚未建立,无法监听消息');
} }
} }
// 重连 WebSocket // 重连 WebSocket(指数退避策略)
reconnect() { reconnect() {
if (this.reconnectTimeout) { if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
clearTimeout(this.reconnectTimeout);
// 达到最大重连次数,停止重试(可根据需求调整为无限重试)
if (this.reconnectAttempts >= this.reconnectMaxAttempts) {
console.log(`已达最大重连次数 ${this.reconnectMaxAttempts},停止重连`);
return;
} }
// 指数退避:延迟时间 = 基础延迟 * 2^重连次数最大不超过maxReconnectDelay
const delay = Math.min(
this.reconnectDelay * Math.pow(2, this.reconnectAttempts),
this.maxReconnectDelay
);
this.reconnectTimeout = setTimeout(() => { this.reconnectTimeout = setTimeout(() => {
this.reconnectAttempts++;
console.log(`重连尝试 ${this.reconnectAttempts}/${this.reconnectMaxAttempts},延迟 ${delay}ms`);
this.initializeWebSocket(); this.initializeWebSocket();
}, 3000); }, delay);
}
// 主动检查连接状态
checkConnection() {
if (!this.isOpen && !this.reconnectTimeout) {
this.reconnect();
}
} }
// 关闭 WebSocket 连接 // 关闭 WebSocket 连接
@@ -142,15 +216,25 @@ class WebsocketUtil {
// 外部注销消息回调函数 // 外部注销消息回调函数
offMessage(callback) { offMessage(callback) {
this.messageCallbacks = [] // 若传入callback则移除指定回调否则清空所有回调
if (callback) {
this.messageCallbacks = this.messageCallbacks.filter(cb => cb !== callback);
} else {
this.messageCallbacks = [];
}
} }
// 销毁 WebSocket 连接,清理资源 // 销毁 WebSocket 连接,清理资源
destroy() { destroy() {
this.closeSocket(); this.closeSocket();
// 清除所有定时器
clearInterval(this.heartbeatInterval); clearInterval(this.heartbeatInterval);
clearTimeout(this.heartbeatTimeout);
clearTimeout(this.reconnectTimeout); clearTimeout(this.reconnectTimeout);
clearInterval(this.checkConnectionInterval);
// 清空回调数组
this.messageCallbacks = []; this.messageCallbacks = [];
console.log('WebSocket资源已销毁');
} }
} }

View File

@@ -2,12 +2,18 @@
<view class="page-gray u-font-28"> <view class="page-gray u-font-28">
<up-sticky offsetTop="0" customNavHeight="0"> <up-sticky offsetTop="0" customNavHeight="0">
<view class="navbar"> <view class="navbar">
<view class="u-flex"
@click="loginOut()"
>
<image <image
src="/static/iconImg/exit.svg" src="/static/iconImg/exit.svg"
class="exit" class="exit"
mode="" mode=""
@click="toDiancan"
></image> ></image>
<text class="u-font-32 color-333 u-m-l-16">退出</text>
</view>
<text class="font-700 u-font-40 color-333">台桌列表</text> <text class="font-700 u-font-40 color-333">台桌列表</text>
<view class="u-flex navbar-right" style="gap: 134rpx"> <view class="u-flex navbar-right" style="gap: 134rpx">
<up-icon name="scan" size="64rpx" color="#999"></up-icon> <up-icon name="scan" size="64rpx" color="#999"></up-icon>
@@ -215,6 +221,13 @@ onShow(async () => {
getTable(); getTable();
}); });
function loginOut() {
uni.clearStorage();
uni.redirectTo({
url: "/pages/login/index",
});
}
/** /**
* 扫码上传 * 扫码上传
*/ */

View File

@@ -293,20 +293,7 @@ const vdata = reactive({
loginType: "merchant", loginType: "merchant",
}, },
}); });
vdata.formData.merchantName = "19107220837";
vdata.formData.username = "19111112222";
vdata.formData.pwd = "123456";
vdata.formData.code = "666666";
// #ifdef H5
// vdata.formData.merchantName = "19191703856";
// vdata.formData.username = "18888888888";
// vdata.formData.pwd = "123456";
// vdata.formData.code = "666666";
// #endif
// #ifdef MP-WEIXIN
// vdata.formData.username = '15699991111'
// vdata.formData.pwd = 'qwer1234'
// #endif
function accountTypeChange(e) { function accountTypeChange(e) {
// #ifdef H5 // #ifdef H5

View File

@@ -125,7 +125,7 @@
class="u-p-t-32 u-p-b-32 u-p-r-28 u-p-l-28 u-m-t-40 bg-fff u-flex u-row-between" class="u-p-t-32 u-p-b-32 u-p-r-28 u-p-l-28 u-m-t-40 bg-fff u-flex u-row-between"
> >
<view class="color-333" style="font-weight: bold">历史订单</view> <view class="color-333" style="font-weight: bold">历史订单</view>
<view class="color-666"> <!-- <view class="color-666">
<uni-icons color="#666" type="trash"></uni-icons> <uni-icons color="#666" type="trash"></uni-icons>
<text <text
class="u-m-l-10" class="u-m-l-10"
@@ -134,7 +134,7 @@
" "
>清空历史订单</text >清空历史订单</text
> >
</view> </view> -->
</view> </view>
<view <view
v-for="(item, index) in historyOrder" v-for="(item, index) in historyOrder"
@@ -581,7 +581,7 @@ function getshopsInfo() {
async function workerConfirm() { async function workerConfirm() {
//debugger //debugger
form.workerAccount=accountStore.staffUserName // form.workerAccount=accountStore.staffUserName
if (!form.workerAccount) { if (!form.workerAccount) {
return infoBox.showToast("请输入服务员账号"); return infoBox.showToast("请输入服务员账号");
} }
@@ -603,7 +603,7 @@ async function workerConfirm() {
placeNum: 1, //当前订单下单次数 placeNum: 1, //当前订单下单次数
waitCall: 0, //是否等叫 0 否 1 等叫 waitCall: 0, //是否等叫 0 否 1 等叫
vipPrice: false, //是否使用会员价 vipPrice: false, //是否使用会员价
limitRate: null, limitRate: props.limitTimeDiscount,
subStatus: subStatus.value, subStatus: subStatus.value,
orderId: props.orderInfo.id?props.orderInfo.id:"", orderId: props.orderInfo.id?props.orderInfo.id:"",
}); });

View File

@@ -523,10 +523,7 @@ function onMessage() {
); );
} }
if ( if (msg.status == 0 && msg.type != "time_discount") {
msg.status == 0 &&
msg.type != "time_discount"
) {
console.log("msg", msg); console.log("msg", msg);
infoBox.showToast(msg.msg || "添加失败"); infoBox.showToast(msg.msg || "添加失败");
data.isGoodsAdd = true; data.isGoodsAdd = true;
@@ -646,7 +643,7 @@ async function getHistoryOrderDetail() {
if (shopInfo.registerType == "before") { if (shopInfo.registerType == "before") {
return; return;
} }
if(!data.table.tableCode){ if (!data.table.tableCode) {
return; return;
} }
data.historyOrder = []; data.historyOrder = [];
@@ -1962,10 +1959,6 @@ onShow(() => {
data.userInfo = shopif; data.userInfo = shopif;
} }
} }
// 判断是否token过期,是否有名字
if (!data.userInfo.shopName) {
loginShowOut();
}
getHistoryOrderDetail(); getHistoryOrderDetail();
nextTick(() => { nextTick(() => {
@@ -2018,7 +2011,7 @@ async function getLimit() {
} }
async function getTableDetail() { async function getTableDetail() {
if(!data.table.tableCode){ if (!data.table.tableCode) {
return; return;
} }
let res = await $returnTableDetail({ let res = await $returnTableDetail({

View File

@@ -180,6 +180,10 @@ function returnLimitPrice(data) {
shopUserInfo: cartStore.shopUserInfo, shopUserInfo: cartStore.shopUserInfo,
idKey: "productId", idKey: "productId",
}); });
console.log("cartStore.shopInfo", cartStore.shopInfo);
console.log("cartStore.limitTimeDiscount", cartStore.limitTimeDiscount);
console.log("cartStore.shopUserInfo", cartStore.shopUserInfo);
return price; return price;
} }

View File

@@ -515,6 +515,7 @@ async function discountconfirm(form) {
product_id: modelData.data.product_id, product_id: modelData.data.product_id,
sku_id: modelData.data.sku_id, sku_id: modelData.data.sku_id,
discount_sale_amount: discount_sale_amount, discount_sale_amount: discount_sale_amount,
is_time_discount: discount_sale_amount>0 ? 0 : (modelData.data.is_time_discount||modelData.data.isTimeDiscount)
// discount_sale_note: str + form.note, // discount_sale_note: str + form.note,
}; };
updateCart(par); updateCart(par);

View File

@@ -2,24 +2,30 @@
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm"> <my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
<template #desc> <template #desc>
<view class="u-text-left u-p-30 color-666 u-font-28"> <view class="u-text-left u-p-30 color-666 u-font-28">
<view class="u-m-t-32 u-flex "> <view class="u-m-t-32 u-flex">
<view class="" v-if="accountPoints.calcRes.usable"> <view class="" v-if="accountPoints.calcRes.usable">
<text class="color-red">*</text> <text class="color-red">*</text>
<text class="" <text class="" v-if="accountPoints.calcRes.equivalentPoints"
v-if="accountPoints.calcRes.equivalentPoints">100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}},</text> >{{ accountPoints.calcRes.equivalentPoints }}积分等于1,</text
>
<text> <text>
最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}} 最大抵扣积分{{ accountPoints.calcRes.maxUsablePoints }}
</text>
<text>,
最小抵扣积分0
</text> </text>
<text>, 最小抵扣积分0 </text>
</view> </view>
</view> </view>
<view class="u-m-t-40 u-flex "> <view class="u-m-t-40 u-flex">
<view>积分</view> <view>积分</view>
<view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1"> <view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1">
<uni-easyinput type="number" @input="pointsInput" @change="pointsChange" paddingNone <uni-easyinput
:inputBorder="false" v-model="form.points" placeholder="输入积分抵扣数量"></uni-easyinput> type="number"
@input="pointsInput"
@change="pointsChange"
paddingNone
:inputBorder="false"
v-model="form.points"
placeholder="输入积分抵扣数量"
></uni-easyinput>
</view> </view>
</view> </view>
</view> </view>
@@ -27,9 +33,13 @@
<template #btn> <template #btn>
<view class="u-p-30"> <view class="u-p-30">
<view class="u-m-t-10"> <view class="u-m-t-10">
<my-button @tap="confirm" shape="circle" fontWeight="700">修改</my-button> <my-button @tap="confirm" shape="circle" fontWeight="700"
>修改</my-button
>
<view class=""> <view class="">
<my-button @tap="close" type="cancel" bgColor="#fff">取消</my-button> <my-button @tap="close" type="cancel" bgColor="#fff"
>取消</my-button
>
</view> </view>
</view> </view>
</view> </view>
@@ -38,114 +48,112 @@
</template> </template>
<script setup> <script setup>
import { import { reactive, nextTick, ref, watch } from "vue";
reactive, import myModel from "@/components/my-components/my-model.vue";
nextTick, import myButton from "@/components/my-components/my-button.vue";
ref, import myTabs from "@/components/my-components/my-tabs.vue";
watch import infoBox from "@/commons/utils/infoBox.js";
} from 'vue'; const props = defineProps({
import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue'
import myTabs from '@/components/my-components/my-tabs.vue'
import infoBox from '@/commons/utils/infoBox.js'
const props = defineProps({
title: { title: {
type: String, type: String,
default: '积分抵扣' default: "积分抵扣",
}, },
accountPoints:{ accountPoints: {
type:Object, type: Object,
default:()=>{ default: () => {
return { return {
calcRes:{ calcRes: {
usable: false, usable: false,
unusableReason: '', unusableReason: "",
minDeductionPoints: 0, minDeductionPoints: 0,
maxUsablePoints: 0 maxUsablePoints: 0,
} },
} };
} },
}, },
price: { price: {
type: [Number, String], type: [Number, String],
default: 0 default: 0,
} },
}) });
function to2(n) { function to2(n) {
if (!n) { if (!n) {
return '' return "";
}
return n.toFixed(2)
} }
return n.toFixed(2);
}
function pointsInput(e){ function pointsInput(e) {
setTimeout(()=>{ setTimeout(() => {
form.points=Math.floor(e) form.points = Math.floor(e);
},100) }, 100);
} }
function pointsChange(newval) {
function pointsChange(newval) { form.points = Math.floor(newval);
form.points=Math.floor(newval)
if (newval < 0) { if (newval < 0) {
form.points = 0 form.points = 0;
return infoBox.showToast('积分抵扣不能小于0') return infoBox.showToast("积分抵扣不能小于0");
} }
if (newval > props.accountPoints.calcRes.maxUsablePoints) { if (newval > props.accountPoints.calcRes.maxUsablePoints) {
form.points = props.price form.points = props.price;
return infoBox.showToast('积分抵扣不能大于'+props.accountPoints.calcRes.maxUsablePoints) return infoBox.showToast(
} "积分抵扣不能大于" + props.accountPoints.calcRes.maxUsablePoints
);
} }
}
const form = reactive({
const form = reactive({
points: props.price, points: props.price,
}) });
watch(() => props.price, (newval) => { watch(
form.points = newval () => props.price,
}) (newval) => {
form.points = newval;
function resetForm() {
form.points=0
} }
);
const model = ref(null) function resetForm() {
form.points = 0;
}
function open() { const model = ref(null);
model.value.open()
form.points = props.price
}
function close() { function open() {
model.value.close() model.value.open();
} form.points = props.price;
const emits = defineEmits(['confirm']) }
function confirm() { function close() {
emits('confirm',Math.floor(form.points) ) model.value.close();
close() }
} const emits = defineEmits(["confirm"]);
defineExpose({
function confirm() {
emits("confirm", Math.floor(form.points));
close();
}
defineExpose({
open, open,
close close,
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.border { .border {
border-radius: 8rpx; border-radius: 8rpx;
overflow: hidden; overflow: hidden;
border-color: #999; border-color: #999;
} }
.lh34 { .lh34 {
line-height: 34rpx; line-height: 34rpx;
} }
.tag { .tag {
background-color: #fff; background-color: #fff;
border: 1px solid #E5E5E5; border: 1px solid #e5e5e5;
line-height: inherit; line-height: inherit;
font-size: 24rpx; font-size: 24rpx;
color: #666666; color: #666666;
@@ -153,43 +161,43 @@
border-radius: 8rpx; border-radius: 8rpx;
&.active { &.active {
border-color: #E6F0FF; border-color: #e6f0ff;
color: $my-main-color; color: $my-main-color;
} }
} }
.hover-class { .hover-class {
background-color: #E5E5E5; background-color: #e5e5e5;
} }
.discount { .discount {
.u-absolute { .u-absolute {
top: 0; top: 0;
bottom: 0; bottom: 0;
right: 0; right: 0;
} }
} }
.bg1 { .bg1 {
background: #F7F7FA; background: #f7f7fa;
} }
.tab { .tab {
padding: 0 80rpx; padding: 0 80rpx;
} }
.border { .border {
border: 1px solid #E5E5E5; border: 1px solid #e5e5e5;
border-radius: 4rpx; border-radius: 4rpx;
} }
.input-box { .input-box {
padding: 22rpx 32rpx; padding: 22rpx 32rpx;
font-size: 28rpx; font-size: 28rpx;
color: #666; color: #666;
} }
.placeholder-class { .placeholder-class {
font-size: 28rpx; font-size: 28rpx;
} }
</style> </style>

View File

@@ -998,6 +998,9 @@ watch(
if (newval) { if (newval) {
getNewUserDiscount(); getNewUserDiscount();
// getShopUserDetail(); // getShopUserDetail();
}else{
newUserDiscount.value =0
newUserDiscountRes.value =null
} }
} }
); );

View File

@@ -188,7 +188,7 @@ export const useCartStore = defineStore("cart", {
}) })
); );
} }
if (msg.status == 0&&msg.type!="time_discount") { if (msg.status == 0 && msg.type != "time_discount") {
uni.showToast({ uni.showToast({
title: "添加失败", title: "添加失败",
icon: "none", icon: "none",
@@ -204,6 +204,9 @@ export const useCartStore = defineStore("cart", {
this.limitTimeDiscount = msg.time_dis_info; this.limitTimeDiscount = msg.time_dis_info;
this.getOrder(); this.getOrder();
break; break;
case "reload":
this.getOrder();
break;
case "pad_add": case "pad_add":
case "add": case "add":
break; break;
@@ -224,7 +227,7 @@ export const useCartStore = defineStore("cart", {
break; break;
case "pad_cleanup": case "pad_cleanup":
case "cleanup": case "cleanup":
this.goodsList=[] this.goodsList = [];
break; break;
case "product_update": case "product_update":
break; break;
@@ -277,6 +280,7 @@ export const useCartStore = defineStore("cart", {
*/ */
setOrder(order) { setOrder(order) {
this.order = order; this.order = order;
this.limitTimeDiscount = order.limitRate;
this.oldCartList = Object.values(order.detailMap).reduce((pre, cur) => { this.oldCartList = Object.values(order.detailMap).reduce((pre, cur) => {
pre.push( pre.push(
...cur.map((v) => { ...cur.map((v) => {