购物车,订单,霸王餐
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -145,6 +145,7 @@
|
||||
product_id: item.id,
|
||||
sku_id: item.skuId,
|
||||
number: await calculateValue(item.cartNumber, i),
|
||||
is_print: 1,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view>
|
||||
<Nav />
|
||||
<!-- 顶部面板 -->
|
||||
<view class="top--panel">
|
||||
<view class="top--panel" :class="{ 'grayscale':!isBusinessTime }">
|
||||
<image class="panelimgbackground"
|
||||
:src="shopExtend?shopExtend.value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/topBanner.png'"
|
||||
mode="aspectFill">
|
||||
@@ -126,7 +126,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 滚动区域 -->
|
||||
<view class="scroll-panel" id="scroll-panel">
|
||||
<view class="scroll-panel" id="scroll-panel" :class="{ 'grayscale':!isBusinessTime }">
|
||||
<view class="list-box">
|
||||
<view class="left" :style="{top: `${store.height}px`}">
|
||||
<scroll-view :scroll-into-view="leftIntoView" :scroll-with-animation="false" :scroll-y="true"
|
||||
@@ -319,7 +319,8 @@
|
||||
</view>
|
||||
<view class="operation-wrap">
|
||||
<view class="btn">
|
||||
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"></up-icon>
|
||||
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
|
||||
v-if="shopCartNumber>0"></up-icon>
|
||||
<view class="btnClick" @click="shopCart('-')">
|
||||
</view>
|
||||
</view>
|
||||
@@ -611,28 +612,35 @@
|
||||
const selectSpec = async (specType, option) => {
|
||||
// 规格清零
|
||||
shopCartNumber.value = 0
|
||||
|
||||
// 更新 selectedSpecs 对象,将当前规格类型的选中值设置为用户点击的选项
|
||||
selectedSpecs.value = {
|
||||
...selectedSpecs.value,
|
||||
[specType]: option
|
||||
};
|
||||
if (allSpecsSelected.value) {
|
||||
try {
|
||||
let result = await APIminiAppskuinfo({
|
||||
specInfo: selectedSpecsStr.value,
|
||||
id: specifications.item.id
|
||||
});
|
||||
specifications.sku_id = result.id
|
||||
specifications.product_id = result.productId
|
||||
// 添加多规格分组
|
||||
specifications.item.result = result
|
||||
if (result.isPauseSale == 0) {
|
||||
canSubmit.value = true;
|
||||
// skuBtnText.value = '添加到购物车'
|
||||
}
|
||||
} catch (error) {
|
||||
canSubmit.value = false;
|
||||
const newSelectedSpecs = {};
|
||||
const specKeys = Object.keys(specifications.item.selectSpecInfo);
|
||||
for (const key of specKeys) {
|
||||
if (key === specType) {
|
||||
newSelectedSpecs[key] = option;
|
||||
} else {
|
||||
newSelectedSpecs[key] = selectedSpecs.value[key];
|
||||
}
|
||||
}
|
||||
selectedSpecs.value = newSelectedSpecs;
|
||||
if (allSpecsSelected.value) {
|
||||
// try {
|
||||
let result = await APIminiAppskuinfo({
|
||||
specInfo: selectedSpecsStr.value,
|
||||
id: specifications.item.id
|
||||
});
|
||||
specifications.sku_id = result.id
|
||||
specifications.product_id = result.productId
|
||||
// 添加多规格分组
|
||||
specifications.item.result = result
|
||||
if (result.isPauseSale == 0) {
|
||||
canSubmit.value = true;
|
||||
// skuBtnText.value = '添加到购物车'
|
||||
}
|
||||
// } catch (error) {
|
||||
// canSubmit.value = false;
|
||||
// }
|
||||
} else {
|
||||
canSubmit.value = false;
|
||||
}
|
||||
@@ -691,12 +699,17 @@
|
||||
return false;
|
||||
};
|
||||
|
||||
// 计算所有选中条件是否都符合
|
||||
// 计算所有选中条件是否都符合
|
||||
const allConditionsSatisfied = computed(() => {
|
||||
return specifications.item.groupSnap.every((setmenu, index) => {
|
||||
// 检查 specifications.item.groupSnap 是否存在
|
||||
if (!specifications.item?.groupSnap) {
|
||||
return false;
|
||||
}
|
||||
return specifications.item.groupSnap.every((optionGroup, index) => {
|
||||
// 获取当前索引对应的已选选项,如果不存在则默认为空数组
|
||||
const selected = selectedOptions.value[index] || [];
|
||||
// 检查是否达到最大选择数量
|
||||
const hasEnoughSelection = selected.length === setmenu.number;
|
||||
const hasEnoughSelection = selected.length === optionGroup.number;
|
||||
return hasEnoughSelection;
|
||||
});
|
||||
});
|
||||
@@ -836,7 +849,8 @@
|
||||
shopCartNumber.value,
|
||||
pro_group_info: selectedGroupSnap.value,
|
||||
goods_type: specifications.item.type == "package" ? 'package' : '',
|
||||
is_print: 1
|
||||
is_print: 1,
|
||||
product_type: specifications.item.type
|
||||
})
|
||||
// 清空套餐选中
|
||||
selectedGroupSnap.value = []
|
||||
@@ -884,6 +898,7 @@
|
||||
|
||||
// 单规格
|
||||
const singleclick = async (item, i) => {
|
||||
console.log(item, i)
|
||||
// 判断购物车是否有该选中商品
|
||||
let res = await matchingProduct(item)
|
||||
websocketsendMessage({
|
||||
@@ -895,7 +910,8 @@
|
||||
product_id: item.id,
|
||||
sku_id: item.skuId,
|
||||
number: await calculateValue(item.cartNumber, i),
|
||||
is_print: 1
|
||||
is_print: 1,
|
||||
product_type: item.type
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1017,7 +1033,9 @@
|
||||
|
||||
// 删除除购物车
|
||||
if (Message.operate_type == 'del' && Message.status == 1) {
|
||||
cartList.value = cartList.value.filter(item => item.id != Message.data.id);
|
||||
// 优化:使用可选链操作符避免报错
|
||||
cartList.value = cartList.value.filter(item => item.id !== Message.data?.id);
|
||||
// cartList.value = cartList.value.filter(item => item.id != Message.data.id);
|
||||
}
|
||||
|
||||
// 添加或者减少购物后返回
|
||||
@@ -1084,49 +1102,6 @@
|
||||
}
|
||||
if (cartItem.is_temporary === 1) {
|
||||
return [{
|
||||
// cartListId: 5309
|
||||
// cartListinfo: Proxy {id: 5309, shop_id: 203, table_code: "40309814459", sku_id: 2863, product_id: 1273, …}
|
||||
// cartNumber: "2.00"
|
||||
// coverImg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/490de935cc9042bfa56d0c392f806484.jpg"
|
||||
// groupType: null
|
||||
// id: "1273"
|
||||
// isHot: 1
|
||||
// isSaleTime: 1
|
||||
// isSoldStock: 0
|
||||
// memberPrice: 0.88
|
||||
// name: "连衣裙"
|
||||
// originPrice: 0.88
|
||||
// packFee: 0
|
||||
// salePrice: 2.88
|
||||
// skuId: "2863"
|
||||
// skuList: Proxy {0: {…}}
|
||||
// stockNumber: 0
|
||||
// suitNum: 1
|
||||
// type: "single"
|
||||
// unitName: "个"
|
||||
|
||||
// cartListId: 5324
|
||||
// cartListinfo: Proxy {id: 5324, shop_id: 203, table_code: "40309814459", sku_id: 0, product_id: -74982031, …}
|
||||
// cartNumber: "25.00"
|
||||
// create_time: "2025-03-18 15:05:37"
|
||||
// discount_sale_amount: "357.00"
|
||||
// discount_sale_note: ""
|
||||
// id: 5324
|
||||
// is_gift: 0
|
||||
// is_print: 0
|
||||
// is_temporary: 1
|
||||
// is_wait_call: 0
|
||||
// number: "25.00"
|
||||
// pack_number: "0.00"
|
||||
// pro_group_info: ""
|
||||
// product_id: -74982031
|
||||
// product_name: "零食吃"
|
||||
// remark: ""
|
||||
// shop_id: 203
|
||||
// sku_id: 0
|
||||
// sku_name: "VB宝贝"
|
||||
// table_code: "40309814459"
|
||||
// update_time: null
|
||||
...cartItem,
|
||||
memberPrice: cartItem.discount_sale_amount,
|
||||
salePrice: cartItem.discount_sale_amount,
|
||||
@@ -1174,7 +1149,7 @@
|
||||
}
|
||||
}, 0);
|
||||
// 向上取整并保留两位小数
|
||||
return cart = Math.ceil(cart * 100) / 100;
|
||||
return parseFloat(cart.toFixed(2));
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
@@ -1250,6 +1225,54 @@
|
||||
}));
|
||||
})
|
||||
|
||||
// // 获取当前时间
|
||||
// const getCurrentDateTime = () => {
|
||||
// const now = new Date();
|
||||
// const dayOfWeek = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][now.getDay()];
|
||||
// const hours = now.getHours().toString().padStart(2, '0');
|
||||
// const minutes = now.getMinutes().toString().padStart(2, '0');
|
||||
// const currentTime = `${hours}:${minutes}`;
|
||||
// return {
|
||||
// dayOfWeek,
|
||||
// currentTime
|
||||
// };
|
||||
// };
|
||||
// // 计算是否在营业时间内
|
||||
// const isBusinessTime = computed(() => {
|
||||
// const {
|
||||
// dayOfWeek,
|
||||
// currentTime
|
||||
// } = getCurrentDateTime();
|
||||
// console.log(shopInfo)
|
||||
// const [startDay, endDay] = [shopInfo.businessStartDay, shopInfo.businessEndDay];
|
||||
// const [startTime, endTime] = shopInfo.businessTime.split('-');
|
||||
|
||||
// const dayIndex = ['周一', '周二', '周三', '周四', '周五', '周六', '周天'].indexOf(dayOfWeek);
|
||||
// const startDayIndex = ['周一', '周二', '周三', '周四', '周五', '周六', '周天'].indexOf(startDay);
|
||||
// const endDayIndex = ['周一', '周二', '周三', '周四', '周五', '周六', '周天'].indexOf(endDay);
|
||||
// console.log(shopInfo.businessTime, 1111)
|
||||
// const isInDayRange = dayIndex >= startDayIndex && dayIndex <= endDayIndex;
|
||||
// const isInTimeRange = currentTime >= startTime && currentTime <= endTime;
|
||||
// console.log(isInDayRange, isInTimeRange, 1111)
|
||||
// return isInDayRange && isInTimeRange;
|
||||
// });
|
||||
|
||||
// 获取当前时间
|
||||
const getCurrentTime = () => {
|
||||
const now = new Date();
|
||||
const hours = now.getHours().toString().padStart(2, '0');
|
||||
const minutes = now.getMinutes().toString().padStart(2, '0');
|
||||
return `${hours}:${minutes}`;
|
||||
};
|
||||
|
||||
// 计算是否在营业时间内
|
||||
const isBusinessTime = computed(() => {
|
||||
const currentTime = getCurrentTime();
|
||||
const [startTime, endTime] = shopInfo.businessTime.split('-');
|
||||
return currentTime >= startTime && currentTime <= endTime;
|
||||
});
|
||||
|
||||
|
||||
// 列表请求
|
||||
const productqueryProduct = async () => {
|
||||
try {
|
||||
@@ -1272,9 +1295,10 @@
|
||||
// userStore.actionsAPIuser()
|
||||
// 数据可以更新
|
||||
isDataLoaded.value = true;
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '错误二维码'
|
||||
title: '暂无列表数据...'
|
||||
});
|
||||
isDataLoaded.value = false;
|
||||
setTimeout(() => {
|
||||
@@ -1307,20 +1331,6 @@
|
||||
const currentPage = pages[pages.length - 1];
|
||||
// 获取页面参数
|
||||
const options = currentPage.options;
|
||||
|
||||
// // #ifdef MP-WEIXIN
|
||||
// if (options.q) {
|
||||
// console.log(options.q)
|
||||
// const store = productStore();
|
||||
// await store.scanCodeactions(options.q)
|
||||
// }
|
||||
// // #endif
|
||||
// // #ifdef MP-ALIPAY
|
||||
// if (getApp().globalData.tableCode) {
|
||||
// await store.scanCodeactions(getApp().globalData.tableCode)
|
||||
// }
|
||||
// // #endif
|
||||
|
||||
await productqueryProduct()
|
||||
setTimeout(() => {
|
||||
// 启动网络监听
|
||||
@@ -1331,6 +1341,11 @@
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.grayscale {
|
||||
filter: grayscale(100%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.top--panel {
|
||||
// padding: 0 20rpx;
|
||||
background-color: #fff;
|
||||
@@ -1920,9 +1935,12 @@
|
||||
border-bottom: 2rpx solid #F0F0F0;
|
||||
}
|
||||
|
||||
.shop_sku_box:last-child {
|
||||
padding-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.shop_sku_box {
|
||||
padding: 20rpx 28rpx;
|
||||
padding: 20rpx;
|
||||
|
||||
.shop_sku_box_name {
|
||||
margin-top: 20rpx;
|
||||
|
||||
Reference in New Issue
Block a user