商品弹窗吸怪
This commit is contained in:
@@ -63,17 +63,23 @@
|
||||
<view class="u-m-t-48 u-p-30">
|
||||
<view class="font-bold u-font-32 ">推荐搭配</view>
|
||||
<view class="u-flex recommand-goods">
|
||||
<view class=" item" v-for="(item,index) in 6" :key="index">
|
||||
<up-image width="210rpx" height="210rpx" radius="12rpx"></up-image>
|
||||
<view class=" item" v-for="(product,index) in goods.relatedRecommendJson" :key="index">
|
||||
<up-image width="210rpx" height="210rpx" radius="12rpx" :src="product.coverImg"></up-image>
|
||||
<view class="info">
|
||||
<view class="u-line-2 name u-m-t-10 u-font-32 font-500">
|
||||
商品名
|
||||
{{product.name}}
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="font-bold">
|
||||
<text class="u-font-24">¥</text>
|
||||
<text class="u-font-32">40</text>
|
||||
|
||||
<text class="u-font-32">
|
||||
|
||||
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount"
|
||||
:cart="returnFirstSku(product)" :shopUserInfo="shopUserInfo"
|
||||
:shopInfo="shopInfo"></GoodsPrice>
|
||||
</text>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<up-icon name="plus-circle-fill" color="#E9AB7A" size="25"></up-icon>
|
||||
@@ -178,12 +184,14 @@
|
||||
import {
|
||||
APIminiAppinfo,
|
||||
APIminiAppskuinfo,
|
||||
productRelated
|
||||
} from '@/common/api/product/product.js';
|
||||
import GoodsPrice from '@/components/goods-price.vue';
|
||||
import {
|
||||
computed,
|
||||
inject,
|
||||
ref
|
||||
ref,
|
||||
watch
|
||||
} from "vue";
|
||||
const cartStore = inject('cartStore')
|
||||
const shopUserInfo = inject('shopUserInfo')
|
||||
@@ -196,7 +204,9 @@
|
||||
goods: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
return {
|
||||
relatedRecommendJson:[]
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -262,6 +272,12 @@
|
||||
|
||||
const swiperCurrent = ref(0);
|
||||
|
||||
function returnFirstSku(product) {
|
||||
return product.skuList[0]
|
||||
}
|
||||
|
||||
|
||||
|
||||
function swiperChange(e) {
|
||||
swiperCurrent.value = e.current;
|
||||
}
|
||||
@@ -276,6 +292,7 @@
|
||||
default: false,
|
||||
});
|
||||
|
||||
|
||||
function stockNumberIsFull(item) {
|
||||
if (item.isStock && item.stockNumber < item.suitNum) {
|
||||
return false
|
||||
@@ -297,31 +314,31 @@
|
||||
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;
|
||||
};
|
||||
// 提交选择并执行下一步操作的方法
|
||||
@@ -339,17 +356,17 @@
|
||||
return;
|
||||
}
|
||||
let res = await shoppingcart();
|
||||
|
||||
if ((specifications.item.type == 'package' && allConditionsSatisfied.value) || (specifications.item.type ==
|
||||
|
||||
if ((props.goods.type == 'package' && allConditionsSatisfied.value) || (props.goods.type ==
|
||||
'sku' && canSubmit.value)) {
|
||||
// 是否是套餐 有就传
|
||||
if (specifications.item.type == 'package') {
|
||||
if (props.goods.type == 'package') {
|
||||
// 需求更改:所所有商品套餐都是add,没有修改
|
||||
res = null;
|
||||
} else {
|
||||
selectedGroupSnap.value = [];
|
||||
}
|
||||
console.log('specifications.item', specifications.item);
|
||||
console.log('props.goods', props.goods);
|
||||
websocketsendMessage({
|
||||
id: res ? res.cartListId : '',
|
||||
type: 'shopping',
|
||||
@@ -362,11 +379,11 @@
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
shopCartNumber.value,
|
||||
pro_group_info: selectedGroupSnap.value,
|
||||
goods_type: specifications.item.type == 'package' ? 'package' : '',
|
||||
memberPrice: specifications.item.memberPrice,
|
||||
goods_type: props.goods.type == 'package' ? 'package' : '',
|
||||
memberPrice: props.goods.memberPrice,
|
||||
is_print: 1,
|
||||
product_type: specifications.item.type,
|
||||
is_time_discount: showLimitDiscount(specifications.item)
|
||||
product_type: props.goods.type,
|
||||
is_time_discount: showLimitDiscount(props.goods)
|
||||
});
|
||||
// 清空套餐选中
|
||||
selectedGroupSnap.value = [];
|
||||
@@ -383,16 +400,52 @@
|
||||
sku_id: specifications.sku_id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
shopCartNumber.value,
|
||||
memberPrice: specifications.item.memberPrice,
|
||||
memberPrice: props.goods.memberPrice,
|
||||
is_print: 1,
|
||||
product_type: specifications.item.type,
|
||||
is_time_discount: showLimitDiscount(specifications.item)
|
||||
product_type: props.goods.type,
|
||||
is_time_discount: showLimitDiscount(props.goods)
|
||||
});
|
||||
showShopsku.value = false;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 多规格 套餐 单规格添加数量
|
||||
const shopCart = async (i) => {
|
||||
if (i == '-' && shopCartNumber.value <= (props.goods.suitNum || 1)) {
|
||||
shopCartNumber.value = 0;
|
||||
return false;
|
||||
}
|
||||
let res = await shoppingcart();
|
||||
|
||||
if (props.goods.result === 'kong') {
|
||||
//没有满足可添加或者编辑的规格
|
||||
return;
|
||||
}
|
||||
if (i == '-') {
|
||||
if (!res && shopCartNumber.value == props.goods.suitNum) {
|
||||
uni.showToast({
|
||||
title: `起点${props.goods.suitNum}个`,
|
||||
icon: 'none'
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
shopCartNumber.value--;
|
||||
}
|
||||
} else {
|
||||
if (!res && shopCartNumber.value < 1) {
|
||||
if (specifications.type == 'sku') {
|
||||
shopCartNumber.value = parseFloat(selSku.value.suitNum);
|
||||
} else {
|
||||
shopCartNumber.value = parseFloat(selSku.value.suitNum);
|
||||
}
|
||||
} else {
|
||||
shopCartNumber.value++;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.shop_sku {
|
||||
|
||||
Reference in New Issue
Block a user