问题修复
This commit is contained in:
parent
8e3bc9cc3b
commit
125365f3dc
File diff suppressed because one or more lines are too long
|
|
@ -27,7 +27,7 @@
|
||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"vue": "^3.3.8",
|
"vue": "^3.3.8",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"ysk-utils": "^1.0.42"
|
"ysk-utils": "^1.0.45"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.5.0",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
|
|
@ -7636,9 +7636,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ysk-utils": {
|
"node_modules/ysk-utils": {
|
||||||
"version": "1.0.42",
|
"version": "1.0.45",
|
||||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.42.tgz",
|
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.45.tgz",
|
||||||
"integrity": "sha512-bXeCu3hhUVpYaURf0LAYUqmcjRwhw2SC7TluyaowVlEjiFp9iaV/fsaC7gwj9Uu8i9gQGSY3EOTDNoEThAWVOQ==",
|
"integrity": "sha512-VXIwQ6uvPY0YJRomPx/b77e3r4+w2i+aXYHtmCliZHSdcbaQZUGeLLSkSWZBh8k+OE5YkQbM8pmrBdwuLTDW+A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bignumber.js": "^9.3.1",
|
"bignumber.js": "^9.3.1",
|
||||||
"lodash": "^4.17.21"
|
"lodash": "^4.17.21"
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"vue": "^3.3.8",
|
"vue": "^3.3.8",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"ysk-utils": "^1.0.42"
|
"ysk-utils": "^1.0.45"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.5.0",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,9 @@ function selectCoupon($event, e) {
|
||||||
|
|
||||||
updateSelCoupon();
|
updateSelCoupon();
|
||||||
|
|
||||||
|
console.log('goodsStore.cartInfo===', goodsStore.cartInfo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (query.value.type == 1) {
|
// if (query.value.type == 1) {
|
||||||
// emits('success', { type: query.value.type, couponList: [{ ...row }] })
|
// emits('success', { type: query.value.type, couponList: [{ ...row }] })
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,15 @@
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="t2">
|
<div class="t2">
|
||||||
<span>原价:¥{{ goodsStore.cartInfo.costSummary.goodsOriginalAmount }}</span>
|
<span>商品原价:¥{{ goodsStore.cartInfo.costSummary.goodsRealAmount || 0 }}</span>
|
||||||
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.seatFee || 0)
|
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.seatFee || 0)
|
||||||
}}</span>
|
}}</span>
|
||||||
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.packFee || 0)
|
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.packFee || 0)
|
||||||
}}</span>
|
}}</span>
|
||||||
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount -
|
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.totalDiscountAmount || 0) }}</span>
|
||||||
goodsStore.cartInfo.costSummary.finalPayAmount) }}</span>
|
<!-- <span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
||||||
<span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
|
||||||
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
|
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
|
||||||
</span>
|
</span> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -123,8 +122,9 @@
|
||||||
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
|
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
|
||||||
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog v-model="showCoupon" :title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount)})`"
|
<el-dialog v-model="showCoupon"
|
||||||
@open="couponDialogOpen" @closed="resetCouponFormHandle" top="5vh" width="80%">
|
:title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`"
|
||||||
|
top="5vh" width="80%" @open="couponDialogOpen">
|
||||||
<div class="coupom_dialog">
|
<div class="coupom_dialog">
|
||||||
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
||||||
<el-form-item label="选择会员">
|
<el-form-item label="选择会员">
|
||||||
|
|
@ -284,7 +284,9 @@ const props = defineProps({
|
||||||
const discountAmount = ref(null)
|
const discountAmount = ref(null)
|
||||||
|
|
||||||
watch(props, () => {
|
watch(props, () => {
|
||||||
money.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)
|
if (goodsStore.cartInfo.costSummary) {
|
||||||
|
money.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)
|
||||||
|
}
|
||||||
// originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
|
// originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
|
||||||
// (goodsStore.cartInfo.packFee || 0))
|
// (goodsStore.cartInfo.packFee || 0))
|
||||||
})
|
})
|
||||||
|
|
@ -449,7 +451,7 @@ function upadatePayData() {
|
||||||
otherCouponDiscountAmount: goodsStore.cartInfo.costSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
otherCouponDiscountAmount: goodsStore.cartInfo.costSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||||
couponList: couponResList1.value.map(item => item.id), // 用户使用的卡券
|
couponList: couponResList1.value.map(item => item.id), // 用户使用的卡券
|
||||||
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount, // 订单金额
|
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount, // 订单金额
|
||||||
roundAmount: goodsStore.cartInfo.costSummary.goodsDiscountAmount, // 抹零金额 减免多少钱
|
roundAmount: 0, // 抹零金额 减免多少钱
|
||||||
pointsDiscountAmount: goodsStore.cartInfo.costSummary.pointDeductionAmount, // 积分抵扣金额(tb_points_basic_setting表)
|
pointsDiscountAmount: goodsStore.cartInfo.costSummary.pointDeductionAmount, // 积分抵扣金额(tb_points_basic_setting表)
|
||||||
pointsNum: goodsStore.cartInfo.costSummary.pointUsed, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
pointsNum: goodsStore.cartInfo.costSummary.pointUsed, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||||
isPrint: 1
|
isPrint: 1
|
||||||
|
|
@ -564,29 +566,67 @@ function delHandle() {
|
||||||
payData.value.checkOrderPay.orderAmount = money.value;
|
payData.value.checkOrderPay.orderAmount = money.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查goodsStore.cartInfo.costSummary是否为真值的Promise
|
||||||
|
* @param {number} [interval=100] 轮询检查间隔(ms)
|
||||||
|
* @param {number} [timeout=5000] 超时时间(ms),超过则reject
|
||||||
|
* @returns {Promise} 当costSummary为真时resolve,超时则reject
|
||||||
|
*/
|
||||||
|
function checkCostSummaryIsTruthy(interval = 100, timeout = 5000) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// 记录开始时间,用于超时判断
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
|
// 轮询检查函数
|
||||||
|
const check = () => {
|
||||||
|
const targetValue = goodsStore.cartInfo.costSummary;
|
||||||
|
|
||||||
|
// 检查是否为真值(非null、undefined、0、''、false、NaN)
|
||||||
|
if (targetValue) {
|
||||||
|
resolve(targetValue); // 成功时返回该值
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否超时
|
||||||
|
if (Date.now() - startTime >= timeout) {
|
||||||
|
reject(new Error('检查超时:costSummary始终为假值'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未满足条件且未超时,继续轮询
|
||||||
|
setTimeout(check, interval);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 立即开始第一次检查
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 获取支付方式
|
// 获取支付方式
|
||||||
async function queryPayTypeAjax() {
|
function queryPayTypeAjax() {
|
||||||
try {
|
checkCostSummaryIsTruthy().then(async () => {
|
||||||
const res = await getPayType();
|
try {
|
||||||
|
const res = await getPayType();
|
||||||
|
|
||||||
res.map((item) => {
|
res.map((item) => {
|
||||||
if (goodsStore.cartInfo.costSummary.finalPayAmount <= 0 && item.payType == "scanCode") {
|
if (goodsStore.cartInfo.costSummary.finalPayAmount <= 0 && item.payType == "scanCode") {
|
||||||
item.disabled = true;
|
item.disabled = true;
|
||||||
} else {
|
} else {
|
||||||
item.disabled = false;
|
item.disabled = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
payList.value = res.filter(item => item.isDisplay);
|
payList.value = res.filter(item => item.isDisplay);
|
||||||
if (payList.value.length) {
|
if (payList.value.length) {
|
||||||
if (payList.value[0].payType == "scanCode" && !payList.value[0].disabled) {
|
if (payList.value[0].payType == "scanCode" && !payList.value[0].disabled) {
|
||||||
scanModalRef.value.show();
|
scanModalRef.value.show();
|
||||||
payType.value = payList.value[0].payType;
|
payType.value = payList.value[0].payType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
})
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 添加优惠 start */
|
/** 添加优惠 start */
|
||||||
|
|
@ -637,7 +677,7 @@ function clearCouponUser() {
|
||||||
|
|
||||||
updateCartCalc()
|
updateCartCalc()
|
||||||
|
|
||||||
resetCouponFormHandle()
|
// resetCouponFormHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 折扣格式化
|
// 折扣格式化
|
||||||
|
|
@ -756,16 +796,16 @@ const calcPointMoney = async () => {
|
||||||
|
|
||||||
// 当dialog打开时
|
// 当dialog打开时
|
||||||
function couponDialogOpen() {
|
function couponDialogOpen() {
|
||||||
couponResList2Amount.value = 0
|
// couponResList2Amount.value = 0
|
||||||
couponForm.value.discountRatio = ''
|
// couponForm.value.discountRatio = ''
|
||||||
|
|
||||||
// 需减去抹零金额
|
// // 需减去抹零金额
|
||||||
couponForm.value.amount = formatDecimal(originOrderAmount.value - roundAmount.value)
|
// couponForm.value.amount = formatDecimal(originOrderAmount.value - roundAmount.value)
|
||||||
couponForm.value.originAmount = couponForm.value.amount
|
// couponForm.value.originAmount = couponForm.value.amount
|
||||||
resetCouponForm.value = { ...couponForm.value }
|
// resetCouponForm.value = { ...couponForm.value }
|
||||||
|
|
||||||
couponResList1.value = []
|
// couponResList1.value = []
|
||||||
couponResList2.value = []
|
// couponResList2.value = []
|
||||||
|
|
||||||
// 当购物车已存在用户时
|
// 当购物车已存在用户时
|
||||||
if (goodsStore.vipUserInfo.id) {
|
if (goodsStore.vipUserInfo.id) {
|
||||||
|
|
@ -786,6 +826,10 @@ function couponDialogOpen() {
|
||||||
// 关闭后初始化dialog
|
// 关闭后初始化dialog
|
||||||
function resetCouponFormHandle() {
|
function resetCouponFormHandle() {
|
||||||
couponForm.value = { ...resetCouponForm.value }
|
couponForm.value = { ...resetCouponForm.value }
|
||||||
|
couponForm.value.pointsNum = ''
|
||||||
|
couponForm.value.discountRatio = ''
|
||||||
|
discountRateNumber.value = 0
|
||||||
|
// clearCouponUser()
|
||||||
cancelAllDiscount()
|
cancelAllDiscount()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1062,7 +1106,8 @@ async function payCardInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
payCardInit
|
payCardInit,
|
||||||
|
resetCouponFormHandle
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,18 @@ import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
import yskUtils from "ysk-utils";
|
import yskUtils from "ysk-utils";
|
||||||
|
|
||||||
|
const initialCostSummary = {
|
||||||
|
finalPayAmount: 0,
|
||||||
|
goodsRealAmount: 0,
|
||||||
|
seatFee: 0,
|
||||||
|
packFee: 0,
|
||||||
|
totalDiscountAmount: 0,
|
||||||
|
productCouponDeduction: 0,
|
||||||
|
fullCouponDeduction: 0,
|
||||||
|
pointDeductionAmount: 0,
|
||||||
|
pointUsed: 0,
|
||||||
|
};
|
||||||
|
|
||||||
// 商品store + 购物车store
|
// 商品store + 购物车store
|
||||||
export const useGoods = defineStore("goods", {
|
export const useGoods = defineStore("goods", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
|
|
@ -44,7 +56,11 @@ export const useGoods = defineStore("goods", {
|
||||||
// tableFee: 0,
|
// tableFee: 0,
|
||||||
// },
|
// },
|
||||||
// 购物车信息,
|
// 购物车信息,
|
||||||
cartInfo: '',
|
cartInfo: {
|
||||||
|
costSummary: {
|
||||||
|
...initialCostSummary
|
||||||
|
}
|
||||||
|
},
|
||||||
goodsName: "", // 商品名称,
|
goodsName: "", // 商品名称,
|
||||||
categoryIndex: useStorage.get("categoryIndex") || 0, // 商品分类索引,
|
categoryIndex: useStorage.get("categoryIndex") || 0, // 商品分类索引,
|
||||||
categoryList: [], // 商品分类列表
|
categoryList: [], // 商品分类列表
|
||||||
|
|
@ -681,7 +697,9 @@ export const useGoods = defineStore("goods", {
|
||||||
// 清空购物车回执操作
|
// 清空购物车回执操作
|
||||||
async successClearCart() {
|
async successClearCart() {
|
||||||
this.cartList = [];
|
this.cartList = [];
|
||||||
this.cartInfo = {};
|
this.cartInfo = {
|
||||||
|
costSummary: { ...initialCostSummary }
|
||||||
|
};
|
||||||
this.orderList = [];
|
this.orderList = [];
|
||||||
this.orderListInfo = "";
|
this.orderListInfo = "";
|
||||||
|
|
||||||
|
|
@ -914,6 +932,9 @@ export const useGoods = defineStore("goods", {
|
||||||
isEnabled: !store.shopInfo.isTableFee,
|
isEnabled: !store.shopInfo.isTableFee,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('seatFeeConfig', seatFeeConfig.value);
|
||||||
|
|
||||||
|
|
||||||
//积分规则
|
//积分规则
|
||||||
const pointDeductionRule = ref({
|
const pointDeductionRule = ref({
|
||||||
pointsPerYuan: options.pointsPerYuan,
|
pointsPerYuan: options.pointsPerYuan,
|
||||||
|
|
|
||||||
|
|
@ -181,17 +181,15 @@ export function returnCouponCanUse(args) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
|
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
|
||||||
if ([2, 4, 5].includes(coupon.type)) {
|
if ([2, 4, 5].includes(coupon.type)) {
|
||||||
console.log("商品兑换券", fullAmount, coupon.fullAmount);
|
|
||||||
if (coupon.type == 2 && fullAmount < coupon.fullAmount) {
|
if (coupon.type == 2 && fullAmount < coupon.fullAmount) {
|
||||||
console.log("商品兑换券", coupon);
|
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`,
|
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 没有符合条件的商品
|
// 没有符合条件的商品
|
||||||
if (isDikouAll && canDikouGoodsArr.length === 0) {
|
if (isDikouAll && canDikouGoodsArr.length === 0) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -219,8 +217,8 @@ export function returnCouponCanUse(args) {
|
||||||
let canUse = false;
|
let canUse = false;
|
||||||
if (isDikouAll) {
|
if (isDikouAll) {
|
||||||
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
|
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
|
||||||
} else if (canCalcGoodsArr.length > 0) {
|
} else if (canUseGoodsArr.length > 0) {
|
||||||
canUse = canCalcGoodsArr.some((v) => v.num >= 2);
|
canUse = canUseGoodsArr.some((v) => v.num >= 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canUse) {
|
if (!canUse) {
|
||||||
|
|
@ -236,10 +234,9 @@ export function returnCouponCanUse(args) {
|
||||||
let canUse = false;
|
let canUse = false;
|
||||||
if (isDikouAll) {
|
if (isDikouAll) {
|
||||||
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
|
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
|
||||||
} else if (canCalcGoodsArr.length > 0) {
|
} else if (canUseGoodsArr.length > 0) {
|
||||||
canUse = canCalcGoodsArr.some((v) => v.num >= 2);
|
canUse = canUseGoodsArr.some((v) => v.num >= 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canUse) {
|
if (!canUse) {
|
||||||
return {
|
return {
|
||||||
canUse: false,
|
canUse: false,
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@ function paySuccess() {
|
||||||
socket.cartInit()
|
socket.cartInit()
|
||||||
goodsStore.successClearCart()
|
goodsStore.successClearCart()
|
||||||
goodsStore.clearVipUserInfo()
|
goodsStore.clearVipUserInfo()
|
||||||
|
payCardRef.value.resetCouponFormHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
const payCardRef = ref(null)
|
const payCardRef = ref(null)
|
||||||
|
|
@ -294,6 +295,8 @@ function returnHandle() {
|
||||||
backendCoupons: [],
|
backendCoupons: [],
|
||||||
fixedAmount: ''
|
fixedAmount: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
payCardRef.value.resetCouponFormHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@
|
||||||
<el-text class="t">外带</el-text>
|
<el-text class="t">外带</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="left" v-else></div>
|
<div class="left" v-else></div>
|
||||||
<div class="right">
|
<div class="right" v-if="goodsStore.cartInfo.costSummary">
|
||||||
共<el-text>
|
共<el-text>
|
||||||
{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsTotal || 0, 2, true) }}件
|
{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsTotal || 0, 2, true) }}件
|
||||||
</el-text>,¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount || 0) }}
|
</el-text>,¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount || 0) }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue