2121
This commit is contained in:
parent
ebed330367
commit
ef64a56b54
|
|
@ -378,14 +378,23 @@
|
||||||
|
|
||||||
async getCoupon() {
|
async getCoupon() {
|
||||||
const res = await getAvailableCoupons();
|
const res = await getAvailableCoupons();
|
||||||
if (res.status == 1 && res.data.status != 2) {
|
if (res.status == 1 && res.data && res.data.status != 2) {
|
||||||
res.data.totalMoney = 0;
|
res.data.totalMoney = 0;
|
||||||
|
|
||||||
if (res.data.goods.list.length > 0) {
|
// 安全检查 goods 和 list 是否存在
|
||||||
res.data.totalMoney = res.data.goods.list.reduce((pre, item) => {
|
const goodsList = res.data.goods?.list || res.data.goods || [];
|
||||||
|
if (Array.isArray(goodsList) && goodsList.length > 0) {
|
||||||
|
res.data.totalMoney = goodsList.reduce((pre, item) => {
|
||||||
return pre + Number(item.price);
|
return pre + Number(item.price);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
// 确保 goods.list 格式正确
|
||||||
|
if (!res.data.goods) {
|
||||||
|
res.data.goods = { list: goodsList };
|
||||||
|
} else if (!res.data.goods.list) {
|
||||||
|
res.data.goods.list = goodsList;
|
||||||
|
}
|
||||||
|
|
||||||
this.$refs.couponPop.open();
|
this.$refs.couponPop.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user