购物车,订单,霸王餐
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
ref,
|
||||
reactive,
|
||||
onMounted,
|
||||
computed
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
@@ -113,7 +114,7 @@
|
||||
|
||||
// 去使用优惠券
|
||||
const navigatorGo = (item) => {
|
||||
console.log(Orderinfo.payAmount, item)
|
||||
// console.log(Orderinfo.payAmount, item)
|
||||
if (Orderinfo.payAmount < item.fullAmount) {
|
||||
uni.showToast({
|
||||
title: "当前订单金额不足使用金额",
|
||||
@@ -138,6 +139,23 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 计算合并后的数组 num相加
|
||||
const mergedArray = computed(() => {
|
||||
const map = new Map();
|
||||
Orderinfo.shoppingCart.forEach(item => {
|
||||
if (map.has(item.productId)) {
|
||||
const existingItem = map.get(item.productId);
|
||||
existingItem.num += item.num;
|
||||
} else {
|
||||
map.set(item.productId, {
|
||||
...item
|
||||
});
|
||||
}
|
||||
});
|
||||
return Array.from(map.values());
|
||||
});
|
||||
|
||||
const Selectedlist = ref([])
|
||||
|
||||
// 商品卷
|
||||
@@ -146,12 +164,31 @@
|
||||
if (!item.show) {
|
||||
return false;
|
||||
}
|
||||
console.log(Orderinfo.shoppingCart)
|
||||
if (Orderinfo.shoppingCart.length < Selectedlist.value.length) {
|
||||
// 查找选中的数组里面 统计指定 id 的重复次数
|
||||
const count = Selectedlist.value.filter(item => item.id === item.id).length;
|
||||
|
||||
// 查找选中的数组里面 统计指定 id 的重复次数
|
||||
const foundObject = mergedArray.value.find(i => i.productId === item.proId)
|
||||
if (foundObject.num <= count) {
|
||||
uni.showToast({
|
||||
title: '不可多余下单参数哦!'
|
||||
title: '不可多余商品!',
|
||||
icon: 'none'
|
||||
})
|
||||
return false;
|
||||
}
|
||||
// 查找选中的数组里面 统计指定 id 的重复次数
|
||||
|
||||
console.log(mergedArray.value)
|
||||
console.log(item)
|
||||
console.log(Selectedlist.value)
|
||||
console.log(Orderinfo.shoppingCart)
|
||||
// if (Orderinfo.shoppingCart.length <= Selectedlist.value.length) {
|
||||
// uni.showToast({
|
||||
// title: '不可多余下单数!',
|
||||
// icon:'none'
|
||||
// })
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (item.Selected) {
|
||||
Selectedlist.value = Selectedlist.value.filter(i => i.id !== item.id)
|
||||
@@ -251,15 +288,12 @@
|
||||
};
|
||||
});
|
||||
}
|
||||
console.log(res)
|
||||
if (res.length > 0) {
|
||||
fromInfo.list = res
|
||||
} else {
|
||||
fromInfo.list = []
|
||||
return false
|
||||
}
|
||||
console.log(res)
|
||||
|
||||
}
|
||||
// 商品取消
|
||||
const cancelCoupon = () => {
|
||||
@@ -296,12 +330,8 @@
|
||||
|
||||
uni.setNavigationBarTitle({
|
||||
title: Orderinfo.typeOrder == 2 ? '商品卷' : '优惠卷',
|
||||
success: () => {
|
||||
console.log('导航栏标题修改成功');
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('导航栏标题修改失败', err);
|
||||
}
|
||||
success: () => {},
|
||||
fail: (err) => {}
|
||||
});
|
||||
|
||||
Orderinfo.shopUserId = options.shopUserId
|
||||
|
||||
Reference in New Issue
Block a user