库存不足营业时间完善
This commit is contained in:
@@ -7,8 +7,11 @@
|
||||
:src="shopExtend?shopExtend.value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/topBanner.png'"
|
||||
mode="aspectFill">
|
||||
</image>
|
||||
<view class="panelone">
|
||||
{{ shopInfo.shopName }}
|
||||
<view class="panelone flex-start">
|
||||
<view>
|
||||
{{ shopInfo.shopName }}
|
||||
</view>
|
||||
<!-- <up-icon name="arrow-right" color="#999999" size="14"></up-icon> -->
|
||||
</view>
|
||||
<view class="paneltow" v-if="distance">
|
||||
距离您{{ distance }}
|
||||
@@ -34,26 +37,41 @@
|
||||
<view class="panelfiveitem" @click="clickspecifications(item,index,index,'热销')"
|
||||
v-for="(item,index) in shopProductList.hots" :key="index">
|
||||
<image class="panelfiveitemimage" :src="item.coverImg" mode="aspectFill"></image>
|
||||
<view class="vifgoodsImg flex-center"
|
||||
v-if="item.isSale == 0 || (item.isSaleTime == 0 && !item.isSaleTimeshow) || item.isSoldStock == 1 || (item.isStock == 1 && item.stockNumber <= 0)">
|
||||
<image v-if="item.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
||||
style="width:200rpx; height: 100%;" mode=""></image>
|
||||
<image v-else-if="(item.isSaleTime == 0 && !item.isSaleTimeshow)"
|
||||
src="@/static/ztt/icon_goods_wks.svg" style="width:200rpx; height: 100%;" mode="">
|
||||
</image>
|
||||
<image v-else-if="item.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
||||
style="width:200rpx; height: 100%;" mode=""></image>
|
||||
<image v-else-if="item.isStock == 1 && item.stockNumber <= 0"
|
||||
src="@/static/ztt/icon_goods_kcbz.svg" style="width:200rpx; height: 100%;" mode="">
|
||||
</image>
|
||||
</view>
|
||||
<view class="panelfiveitemone">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
<view class="panelfiveitemtow">
|
||||
本店回头客第{{index+1}}名
|
||||
</view>
|
||||
<view class="panelfiveitemthere flex-start">
|
||||
<view class="panelfiveitemthere flex-between">
|
||||
<text>招牌</text>
|
||||
<view class="describe" v-if="item.suitNum>1 && item.type!= 'sku'"
|
||||
style="font-size: 20rpx;margin-top: 10rpx;">
|
||||
「{{item.suitNum}}{{item.unitName}}起点」
|
||||
</view>
|
||||
</view>
|
||||
<view class="describe" v-if="item.suitNum>1 && item.type!= 'sku'" style="font-size: 20rpx;">
|
||||
「{{item.suitNum}}{{item.unitName}}起点」
|
||||
</view>
|
||||
|
||||
<!-- <view class="panelfiveitemfour">
|
||||
{{item.shortTitle?item.shortTitle:''}}
|
||||
</view>
|
||||
<view class="panelfiveitemfive">
|
||||
月售{{item.stockNumber}}
|
||||
</view> -->
|
||||
<view v-if="item.isSoldStock == 1 || item.isSaleTime == 0" class="flex-between"
|
||||
style="margin-top: 32rpx;margin-bottom: 48rpx;">
|
||||
<view v-if="item.isSoldStock == 1 || (item.isSaleTime == 0 && !item.isSaleTimeshow)"
|
||||
class="flex-between" style="margin-top: 32rpx;margin-bottom: 48rpx;">
|
||||
<view class="panelfiveitemsex flex-between">
|
||||
<view class="panelfiveitemsex_oen">
|
||||
<text class="tips"
|
||||
@@ -68,7 +86,7 @@
|
||||
</view>
|
||||
<view class="panelfiveitemNum">
|
||||
<view class="sku-wrap flex-center" style="background-color: #CECECE;">
|
||||
<text class="t" v-if="item.isSaleTime == 0">非可售时间</text>
|
||||
<text class="t" v-if="(item.isSaleTime == 0 && !item.isSaleTimeshow)">未开售</text>
|
||||
<text class="t" v-if="item.isSoldStock == 1">已售罄</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -115,12 +133,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view v-if="item.isSoldStock == 1 || item.isSaleTime == 0"
|
||||
style="width: 100%;height: 100%;position: absolute;top: 0;left: 0;z-index: 9,background-color: rgba(255,255,255,0.5);">
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -156,6 +169,19 @@
|
||||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/1.gif" mode="" v-else
|
||||
:lazy-load="true">
|
||||
</image>
|
||||
<view class="vifgoodsImg"
|
||||
v-if="item1.isSale == 0 || (item1.isSaleTime == 0 && !item1.isSaleTimeshow) || item1.isSoldStock == 1 || (item1.isStock == 1 && item1.stockNumber <= 0)">
|
||||
<image v-if="item1.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
||||
style="width:200rpx; height: 100%;" mode=""></image>
|
||||
<image v-else-if="(item1.isSaleTime == 0 && !item1.isSaleTimeshow)"
|
||||
src="@/static/ztt/icon_goods_wks.svg" style="width:200rpx; height: 100%;"
|
||||
mode=""></image>
|
||||
<image v-else-if="item1.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
||||
style="width:200rpx; height: 100%;" mode=""></image>
|
||||
<image v-else-if="item1.isStock == 1 && item1.stockNumber <= 0"
|
||||
src="@/static/ztt/icon_goods_kcbz.svg" style="width:200rpx; height: 100%;"
|
||||
mode=""></image>
|
||||
</view>
|
||||
<view v-if="index=='0'" class="topSort" :class="'c'+(index1+1)">TOP{{index1+1}}</view>
|
||||
<view class="goods_right" style="overflow: hidden;">
|
||||
<view class="name">{{ item1.name }}</view>
|
||||
@@ -167,8 +193,9 @@
|
||||
style="font-size: 20rpx;">
|
||||
「{{item1.suitNum}}{{item1.unitName}}起点」
|
||||
</view>
|
||||
|
||||
<view v-if="item1.isSoldStock == 1 || item1.isSaleTime == 0" class="flex-between">
|
||||
<view
|
||||
v-if="item1.isSoldStock == 1 || (item1.isSaleTime == 0 && !item1.isSaleTimeshow)"
|
||||
class="flex-between">
|
||||
<view class="money">
|
||||
<view>¥</view>
|
||||
<text class="money_num" style="margin-right: 10rpx;">
|
||||
@@ -178,7 +205,8 @@
|
||||
</view>
|
||||
<view class="flex-end">
|
||||
<view class="sku-wrap flex-center" style="background-color: #CECECE;">
|
||||
<text class="t" v-if="item1.isSaleTime == 0">非可售时间</text>
|
||||
<text class="t"
|
||||
v-if="(item1.isSaleTime == 0 && !item1.isSaleTimeshow)">未开售</text>
|
||||
<text class="t" v-else-if="item1.isSoldStock == 1">已售罄</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -223,10 +251,6 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="item1.isSoldStock != 0 || item1.isSale == 0"
|
||||
style="width: 100%;height: 100%;position: absolute;top: 0;left: 0;z-index: 9background-color: rgba(255,255,255,0.5);">
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="fill-last" :style="{ 'height':fillHeight + 'px' }"></view>
|
||||
@@ -294,7 +318,7 @@
|
||||
:class="{ shop_sku_box_item_selected: selectedSpecs[specType] === option }">
|
||||
{{option}}
|
||||
<view class="shop_sku_box_item_tip"
|
||||
v-if="specifications.item.result&& specifications.item.result.isPauseSale== 1 && selectedSpecs[specType] === option">
|
||||
v-if="specifications.item.result&& specifications.item.result.isSoldStock== 1 && selectedSpecs[specType] === option">
|
||||
<view>售罄</view>
|
||||
</view>
|
||||
<view class="shop_sku_box_item_tip"
|
||||
@@ -319,7 +343,7 @@
|
||||
:disabled="isMaxSelected(setmenuindex) &&!isOptionSelected(setmenuindex, option)">
|
||||
{{option.proName}}
|
||||
<text v-if="option.unitName">/{{option.unitName}}</text>
|
||||
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
|
||||
<view class="shop_sku_box_item_tip" v-if="specifications.item.isSoldStock == 1">
|
||||
<view>售罄</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -353,7 +377,7 @@
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="operation-wrap">
|
||||
<view class="operation-wrap" v-if="specifications.item.type != 'package'">
|
||||
<view class="btn">
|
||||
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
|
||||
v-if="shopCartNumber>0"></up-icon>
|
||||
@@ -412,6 +436,9 @@
|
||||
import shoppingCartes from './components/shoppingCartes.vue'
|
||||
import confirmorder from './components/confirmorder.vue'
|
||||
import Loading from '@/components/Loading.vue';
|
||||
import dayjs from 'dayjs';
|
||||
import isBetween from 'dayjs/plugin/isBetween'
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
// 获取全局属性
|
||||
const {
|
||||
@@ -628,7 +655,7 @@
|
||||
item: {
|
||||
groupSnap: [],
|
||||
result: {
|
||||
isPauseSale: 0
|
||||
isSoldStock: 0
|
||||
}
|
||||
},
|
||||
|
||||
@@ -676,12 +703,13 @@
|
||||
specInfo: selectedSpecsStr.value,
|
||||
id: specifications.item.id
|
||||
});
|
||||
// skuList
|
||||
if (result != true) {
|
||||
specifications.sku_id = result.id
|
||||
specifications.product_id = result.productId
|
||||
// 添加多规格分组
|
||||
specifications.item.result = result
|
||||
if (result.isPauseSale == 0) {
|
||||
if (result.isSoldStock == 0) {
|
||||
canSubmit.value = true;
|
||||
} else {
|
||||
canSubmit.value = false;
|
||||
@@ -792,7 +820,12 @@
|
||||
}
|
||||
} else {
|
||||
if (!res && shopCartNumber.value < 1) {
|
||||
shopCartNumber.value = parseFloat(specifications.item.suitNum);
|
||||
console.log(res, specifications)
|
||||
if (specifications.type == 'sku') {
|
||||
shopCartNumber.value = parseFloat(specifications.item.result.suitNum);
|
||||
} else {
|
||||
shopCartNumber.value = parseFloat(specifications.item.suitNum);
|
||||
}
|
||||
} else {
|
||||
shopCartNumber.value++;
|
||||
}
|
||||
@@ -897,6 +930,14 @@
|
||||
|
||||
// 提交选择并执行下一步操作的方法
|
||||
const submitSelection = async () => {
|
||||
if (!isProductAvailable(specifications.productListitem.days, specifications.productListitem.startTime,
|
||||
specifications.productListitem.endTime)) {
|
||||
uni.showToast({
|
||||
title: '不在可售时间内'
|
||||
})
|
||||
return false;
|
||||
}
|
||||
// 判断购物车是否有该选中商品
|
||||
// 数量不能少于0
|
||||
if (shopCartNumber.value <= 0) {
|
||||
return;
|
||||
@@ -906,13 +947,17 @@
|
||||
let res = await shoppingcart()
|
||||
|
||||
// 是否是套餐 有就传
|
||||
if (specifications.item.type != "package") {
|
||||
if (specifications.item.type == "package") {
|
||||
// 需求更改:所所有商品套餐都是add,没有修改
|
||||
res = null
|
||||
} else {
|
||||
selectedGroupSnap.value = []
|
||||
}
|
||||
|
||||
websocketsendMessage({
|
||||
id: res ? res.cartListId : '',
|
||||
type: 'shopping',
|
||||
suitNum: specifications.productListitem.suitNum,
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: res ? 'edit' : 'add',
|
||||
@@ -932,15 +977,16 @@
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取多规格数据
|
||||
const clickspecifications = async (item, index, indexs, type) => {
|
||||
console.log(item)
|
||||
// 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
|
||||
if (item.isSoldStock == 1 || item.isSaleTime == 0 || item.type == 'single' || item.type == 'weight' || (item.type == 'package' && item.groupType == '0')) {
|
||||
if (item.isSoldStock == 1 || (item.isSaleTime == 0 && !item.isSaleTimeshow) || item.type == 'single' ||
|
||||
item
|
||||
.type == 'weight' || (
|
||||
item.type == 'package' && item.groupType == '0')) {
|
||||
return false;
|
||||
}
|
||||
// 数量清零
|
||||
@@ -948,6 +994,7 @@
|
||||
// 初始化
|
||||
let data = {
|
||||
item: item,
|
||||
productListitem: item,
|
||||
type: '',
|
||||
product_id: '',
|
||||
sku_id: ''
|
||||
@@ -964,6 +1011,7 @@
|
||||
selectedOptions.value = []
|
||||
specifications.product_id = res.id
|
||||
specifications.sku_id = item.skuId
|
||||
shopCartNumber.value = 1
|
||||
}
|
||||
// 购物车是否有商品
|
||||
specifications.type = res.type
|
||||
@@ -974,10 +1022,49 @@
|
||||
specifications.item.amountcartNumber = 0
|
||||
showShopsku.value = true
|
||||
}
|
||||
// 判断商品是否在可售时间内
|
||||
const isProductAvailable = async (sellDaysStr, startTimeStr, endTimeStr) => {
|
||||
// 将后端返回的字符串转换为数组
|
||||
const sellDays = sellDaysStr.split(',');
|
||||
const now = dayjs();
|
||||
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
const currentDay = days[now.day()];
|
||||
|
||||
// console.log('当前日期:', currentDay);
|
||||
// console.log('可售日期列表:', sellDays);
|
||||
|
||||
// 检查当前周几是否在可售周几列表中
|
||||
if (!sellDays.includes(currentDay)) {
|
||||
// console.log('当前日期不在可售日期列表中');
|
||||
return false;
|
||||
}
|
||||
|
||||
const startTime = dayjs(`${now.format('YYYY-MM-DD')} ${startTimeStr}`);
|
||||
let endTime = dayjs(`${now.format('YYYY-MM-DD')} ${endTimeStr}`);
|
||||
|
||||
// 处理跨天情况
|
||||
if (endTime.isBefore(startTime)) {
|
||||
endTime = endTime.add(1, 'day');
|
||||
}
|
||||
|
||||
// console.log('当前时间:', now.format('YYYY-MM-DD HH:mm:ss'));
|
||||
// console.log('开始时间:', startTime.format('YYYY-MM-DD HH:mm:ss'));
|
||||
// console.log('结束时间:', endTime.format('YYYY-MM-DD HH:mm:ss'));
|
||||
|
||||
const isInRange = now.isBetween(startTime, endTime, null, '[)');
|
||||
// console.log('当前时间是否在可售时间范围内:', isInRange);
|
||||
|
||||
return isInRange;
|
||||
}
|
||||
|
||||
// 单规格
|
||||
const singleclick = async (item, i) => {
|
||||
console.log(item)
|
||||
if (!isProductAvailable(item.days, item.startTime, item.endTime)) {
|
||||
uni.showToast({
|
||||
title: '不在可售时间内'
|
||||
})
|
||||
return false;
|
||||
}
|
||||
// 判断购物车是否有该选中商品
|
||||
let res = null
|
||||
try {
|
||||
@@ -987,6 +1074,10 @@
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
// 保存这次点击的
|
||||
specifications.productListitem = item
|
||||
|
||||
// 是否起售 如果小于或者大于都是1
|
||||
let suitNum = 1;
|
||||
const cartNumberFloat = parseFloat(item.cartNumber);
|
||||
@@ -998,6 +1089,7 @@
|
||||
websocketsendMessage({
|
||||
id: res ? item.cartListId : '',
|
||||
type: 'shopping',
|
||||
suitNum: item.suitNum,
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: await calculateValue(item.cartNumber, i, suitNum) == 'del' ? 'del' : res ?
|
||||
@@ -1105,6 +1197,7 @@
|
||||
if (Message) {
|
||||
// 心跳返回 过滤
|
||||
if (Message.type == "ping_interval" || Message.msg_id == "ping_interval") {
|
||||
isLoading.value = false;
|
||||
return false
|
||||
}
|
||||
// 检查消息是否已经处理过
|
||||
@@ -1115,7 +1208,6 @@
|
||||
|
||||
// 初始化
|
||||
if (Message.operate_type == "init") {
|
||||
console.log(Message)
|
||||
cartList.value = Message.data
|
||||
uni.hideLoading();
|
||||
isLoading.value = false;
|
||||
@@ -1161,6 +1253,33 @@
|
||||
productqueryProduct()
|
||||
}
|
||||
|
||||
// 提示
|
||||
if (Message.status == 0 && Message.type != 'no_suit_num') {
|
||||
uni.showToast({
|
||||
title: Message.msg,
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
|
||||
if (Message.type == 'no_suit_num') {
|
||||
// console.log(specifications)
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
showCancel: false,
|
||||
content: '此商品库存不足起售数量!',
|
||||
success: async (data) => {
|
||||
await websocketsendMessage({
|
||||
id: Message.id,
|
||||
type: 'shopping',
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: 'del',
|
||||
is_print: 1,
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//除去p 每次返回都回执消息
|
||||
await websocketsendMessage({
|
||||
type: 'receipt',
|
||||
@@ -1306,7 +1425,6 @@
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
console.log(cartone, 'orderinfo.value')
|
||||
// 购物车总数价格
|
||||
let cart = 0
|
||||
if (matchedProducts.value.length > 0) {
|
||||
@@ -1332,7 +1450,6 @@
|
||||
}, 0);
|
||||
}
|
||||
cart = parseFloat(cartone) + parseFloat(cart)
|
||||
console.log(cart, 'orderinfo.value')
|
||||
// 向上取整并保留两位小数
|
||||
return parseFloat(cart.toFixed(2));
|
||||
});
|
||||
@@ -1453,12 +1570,15 @@
|
||||
//TODO handle the exception
|
||||
//第一步:将所有商品的 cartNumber 初始化为 0
|
||||
shopProductList.productInfo.forEach((group) => {
|
||||
group.productList.forEach((product) => {
|
||||
group.productList.forEach(async (product) => {
|
||||
product.cartNumber = 0;
|
||||
product.isSaleTimeshow = await isProductAvailable(product.days, product
|
||||
.startTime, product.endTime)
|
||||
});
|
||||
});
|
||||
shopProductList.hots.forEach((i) => {
|
||||
shopProductList.hots.forEach(async (i) => {
|
||||
i.cartNumber = 0
|
||||
i.isSaleTimeshow = await isProductAvailable(i.days, i.startTime, i.endTime)
|
||||
})
|
||||
scrollTopSize.value = 0
|
||||
topArr.value = []
|
||||
@@ -1599,12 +1719,32 @@
|
||||
height: 204rpx;
|
||||
}
|
||||
|
||||
.vifgoodsImg {
|
||||
width: 100%;
|
||||
height: 204rpx;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 9;
|
||||
background-color: rgb(0, 0, 0, 0.5);
|
||||
|
||||
image {
|
||||
padding: 30rpx;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.panelfiveitemone {
|
||||
margin-top: 32rpx;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
overflow: hidden; //超出的文本隐藏
|
||||
text-overflow: ellipsis; //溢出用省略号显示
|
||||
white-space: nowrap; //溢出不换行
|
||||
}
|
||||
|
||||
.panelfiveitemtow {
|
||||
@@ -1893,16 +2033,32 @@
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
margin-right: 18rpx;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.goodsImg {
|
||||
position: relative;
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border-radius: 18rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.vifgoodsImg {
|
||||
width: 200rpx;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 9;
|
||||
background-color: rgb(0, 0, 0, 0.5);
|
||||
|
||||
image {
|
||||
padding: 30rpx;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.topSort {
|
||||
width: 92rpx;
|
||||
height: 38rpx;
|
||||
|
||||
Reference in New Issue
Block a user