修改易购模块部分bug
This commit is contained in:
parent
567af67ef1
commit
6d0a011836
@ -108,6 +108,7 @@ image {
|
||||
color: #C7C7C7;
|
||||
margin-left: 30rpx;
|
||||
padding-bottom: 4rpx;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.GGBox {
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
<view class="group-price">
|
||||
<view>¥{{ item.commodity_goods_info.sales_price }}/{{
|
||||
item.commodity_goods_info.goods_unit
|
||||
}}</view>
|
||||
}}</view>
|
||||
<!-- 运费 -->
|
||||
<view class="goods-desc" style="margin-top: 10rpx;">运费 ¥{{
|
||||
item.commodity_goods_info.freight }}</view>
|
||||
@ -240,7 +240,7 @@
|
||||
</view>
|
||||
<view @click.stop="changeShadow">
|
||||
<view class="shadowBox1">
|
||||
<button class="shadowBox1Item_btn" open-type="share" bindtap="onShareButtonClick"/>
|
||||
<button class="shadowBox1Item_btn" open-type="share" bindtap="onShareButtonClick" />
|
||||
<view class="shadowBox1Item" @click="shareFriend">
|
||||
<image
|
||||
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_WX.png"
|
||||
@ -301,7 +301,7 @@ export default {
|
||||
activeTab: 'pickup', // 默认选中自提
|
||||
quantity: 1, // 商品数量
|
||||
selectedPayment: 'wechat',
|
||||
boxshadow1: true,
|
||||
boxshadow1: false,
|
||||
boxshadow2: false,
|
||||
defAddress: {},
|
||||
defZTAddress: [],
|
||||
@ -345,7 +345,8 @@ export default {
|
||||
item.commodity_goods_info.commodity_pic = picUrl + item.commodity_goods_info.commodity_pic
|
||||
}
|
||||
|
||||
const list = item.commodity_goods_info.group_buy_activity_info
|
||||
// const list = item.commodity_goods_info.group_buy_activity_info
|
||||
const list = true
|
||||
if (list) {
|
||||
this.orderList2.push(item)
|
||||
} else {
|
||||
@ -368,36 +369,59 @@ export default {
|
||||
NavgateTo('../ztLocation/index?item=' + JSON.stringify(item));
|
||||
},
|
||||
decreaseQuantity(item) {
|
||||
const currentTime = new Date().getTime();
|
||||
const startTime = new Date(item.commodity_goods_info.group_buy_activity_info.start_time).getTime();
|
||||
const endTime = new Date(item.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (item.count > 0) {
|
||||
if (item.count == item.commodity_goods_info.min_order_quantity) {
|
||||
uni.showToast({
|
||||
title: '最少购买' + item.commodity_goods_info.min_order_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
item.count = 0
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
if (item.count == item.commodity_goods_info.min_order_quantity) {
|
||||
uni.showToast({
|
||||
title: '最少购买' + item.commodity_goods_info.min_order_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
item.count = 0
|
||||
} else {
|
||||
item.count--
|
||||
}
|
||||
} else {
|
||||
item.count--
|
||||
}
|
||||
|
||||
// 当数量减到0时,从carList中删除该商品
|
||||
if (item.count === 0) {
|
||||
const index = this.carList.findIndex(carItem => carItem.goods_id === item.goods_id);
|
||||
if (index > -1) {
|
||||
this.carList.splice(index, 1);
|
||||
// 重新加载商品列表以更新页面显示
|
||||
this.getGoodsList();
|
||||
}
|
||||
}
|
||||
|
||||
this.changeCart(item)
|
||||
}
|
||||
},
|
||||
increaseQuantity(item) {
|
||||
if (item.count == 0) {
|
||||
item.count += item.commodity_goods_info.min_order_quantity
|
||||
} else {
|
||||
if (item.count == item.commodity_goods_info.total_stock) {
|
||||
uni.showToast({
|
||||
title: '库存不足',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (item.count == item.commodity_goods_info.max_limit_quantity) {
|
||||
uni.showToast({
|
||||
title: '一次最多购买' + item.commodity_goods_info.max_limit_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
const currentTime = new Date().getTime();
|
||||
const startTime = new Date(item.commodity_goods_info.group_buy_activity_info.start_time).getTime();
|
||||
const endTime = new Date(item.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
if (item.count == 0) {
|
||||
item.count += item.commodity_goods_info.min_order_quantity
|
||||
} else {
|
||||
if (item.count == item.commodity_goods_info.total_stock) {
|
||||
uni.showToast({
|
||||
title: '库存不足',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (item.count == item.commodity_goods_info.max_limit_quantity) {
|
||||
uni.showToast({
|
||||
title: '一次最多购买' + item.commodity_goods_info.max_limit_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
item.count++;
|
||||
@ -423,17 +447,32 @@ export default {
|
||||
|
||||
// 计算总金额
|
||||
calculateTotal(order) {
|
||||
const currentTime = new Date().getTime();
|
||||
if (order === 'order1') {
|
||||
let total = 0;
|
||||
this.orderList1.forEach(item => {
|
||||
total += item.commodity_goods_info.sales_price * item.count + item.commodity_goods_info.freight;
|
||||
this.orderList1.forEach(goods => {
|
||||
// 团购活动时间判断
|
||||
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info.start_time).getTime();
|
||||
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
total += goods.commodity_goods_info.group_buy_price * goods.count + goods.commodity_goods_info.freight;
|
||||
} else {
|
||||
total += goods.commodity_goods_info.sales_price * goods.count + goods.commodity_goods_info.freight;
|
||||
}
|
||||
});
|
||||
// 加运费
|
||||
return total;
|
||||
} else {
|
||||
let total = 0;
|
||||
this.orderList2.forEach(item => {
|
||||
total += item.commodity_goods_info.group_buy_price * item.count + item.commodity_goods_info.freight;
|
||||
this.orderList2.forEach(goods => {
|
||||
// 团购活动时间判断
|
||||
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info.start_time).getTime();
|
||||
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
total += goods.commodity_goods_info.group_buy_price * goods.count + goods.commodity_goods_info.freight;
|
||||
} else {
|
||||
total += goods.commodity_goods_info.sales_price * goods.count + goods.commodity_goods_info.freight;
|
||||
}
|
||||
});
|
||||
// 加运费
|
||||
return total;
|
||||
|
||||
@ -106,6 +106,10 @@ page {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.slide_item_active{
|
||||
color: #ff5f3c;
|
||||
}
|
||||
|
||||
.Con {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
@ -511,7 +515,7 @@ page {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.GGItem_Image image{
|
||||
.GGItem_Image image {
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
@ -567,9 +571,16 @@ page {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
position: fixed;
|
||||
right: 33rpx;
|
||||
right: -95rpx;
|
||||
bottom: 180rpx;
|
||||
z-index: 10;
|
||||
transition: right 0.3s ease;
|
||||
}
|
||||
|
||||
.shop_car:hover,
|
||||
.shop_car.show {
|
||||
right: 33rpx;
|
||||
/* 鼠标悬停或滚动时完全显示 */
|
||||
}
|
||||
|
||||
.shop_car image {
|
||||
@ -579,6 +590,8 @@ page {
|
||||
|
||||
.u-badge {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
right: 70rpx;
|
||||
/* 调整角标位置,使其在隐藏状态下也能看到 */
|
||||
top: -10rpx;
|
||||
z-index: 11;
|
||||
}
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
<view class="slide">
|
||||
<view class="slide_con">
|
||||
<view v-for="(item, index) in CateList" :key="index" class="slide_conBox">
|
||||
<view v-for="(item, index) in CateList" :key="index" class="slide_conBox" @click="changeCate(item.id)">
|
||||
<view class="slide_item">
|
||||
<image :src="picUrl + item.category_pic" mode="aspectFill"></image>
|
||||
<text>{{ item.category_name }}</text>
|
||||
@ -227,6 +227,7 @@ export default {
|
||||
search: "",
|
||||
value: "1",
|
||||
cateListShow: false,
|
||||
conRightElement: null,
|
||||
iconList: [
|
||||
{
|
||||
icon: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_icon1.png",
|
||||
@ -296,15 +297,45 @@ export default {
|
||||
NavgateTo('1')
|
||||
},
|
||||
|
||||
// 显示购物车图标
|
||||
showShopCar() {
|
||||
this.$nextTick(() => {
|
||||
try {
|
||||
const shopCar = document.querySelector('.shop_car');
|
||||
if (shopCar) {
|
||||
shopCar.classList.add('show');
|
||||
|
||||
// 2秒后自动隐藏
|
||||
clearTimeout(this.hideShopCarTimer);
|
||||
this.hideShopCarTimer = setTimeout(() => {
|
||||
const carElement = document.querySelector('.shop_car');
|
||||
if (carElement) {
|
||||
carElement.classList.remove('show');
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
changeCate(id) {
|
||||
// 根据id查找对应的分类
|
||||
const category = this.CateList.find((item) => item.id === id);
|
||||
if (category) {
|
||||
// 将leftCateList设置为该分类的二级分类,若为null则设为空数组
|
||||
this.leftCateList = category.level_two_category || [];
|
||||
this.secondId = this.leftCateList[0]?.id;
|
||||
if (this.leftCateList.length > 0) {
|
||||
this.currentLeftCateId = this.leftCateList[0].id;
|
||||
this.secondId = this.leftCateList[0].id;
|
||||
} else {
|
||||
this.currentLeftCateId = null;
|
||||
this.secondId = null;
|
||||
}
|
||||
this.getGoodsList();
|
||||
}
|
||||
this.topShow = false;
|
||||
},
|
||||
//顶部分类点击
|
||||
changeCateListShow() {
|
||||
@ -440,10 +471,39 @@ export default {
|
||||
this.localHeight = meun.height;
|
||||
this.getCateList();
|
||||
// this.getShopCarList();
|
||||
|
||||
// 初始化定时器
|
||||
this.hideShopCarTimer = null;
|
||||
},
|
||||
onShow() {
|
||||
this.getShopCarList();
|
||||
this.getGoodsList();
|
||||
|
||||
// 添加滚动事件监听 - 使用nextTick确保DOM已渲染
|
||||
this.$nextTick(() => {
|
||||
try {
|
||||
const conRight = document.querySelector('.Con_right');
|
||||
if (conRight) {
|
||||
this.conRightElement = conRight;
|
||||
conRight.addEventListener('scroll', this.showShopCar);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onHide() {
|
||||
// 移除滚动事件监听
|
||||
if (this.conRightElement) {
|
||||
this.conRightElement.removeEventListener('scroll', this.showShopCar);
|
||||
this.conRightElement = null;
|
||||
}
|
||||
|
||||
// 清除定时器
|
||||
if (this.hideShopCarTimer) {
|
||||
clearTimeout(this.hideShopCarTimer);
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.flag) {
|
||||
|
||||
@ -70,9 +70,10 @@
|
||||
</view>
|
||||
<view class="goodsItem_msg_right_msg">
|
||||
<view class="goodsItem_msg_right_msg_left">
|
||||
<span>¥</span>{{ item.commodity_goods_info.group_buy_price ?
|
||||
<span>¥</span>{{ getPrice(item) }}
|
||||
<!-- {{ item.commodity_goods_info.group_buy_price ?
|
||||
item.commodity_goods_info.group_buy_price :
|
||||
item.commodity_goods_info.sales_price }}
|
||||
item.commodity_goods_info.sales_price }} -->
|
||||
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
||||
</view>
|
||||
<view class="goodsItem_msg_right_msg_right">
|
||||
@ -148,9 +149,10 @@
|
||||
</view>
|
||||
<view class="goodsItem_msg_right_msg">
|
||||
<view class="goodsItem_msg_right_msg_left">
|
||||
<span>¥</span>{{ item.commodity_goods_info.group_buy_price ?
|
||||
<span>¥</span>{{ getPrice(item) }}
|
||||
<!-- {{ item.commodity_goods_info.group_buy_price ?
|
||||
item.commodity_goods_info.group_buy_price :
|
||||
item.commodity_goods_info.sales_price }}
|
||||
item.commodity_goods_info.sales_price }} -->
|
||||
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
||||
</view>
|
||||
<view class="goodsItem_msg_right_msg_right">
|
||||
@ -457,15 +459,20 @@ export default {
|
||||
// 计算金额
|
||||
calcTotal() {
|
||||
let total = 0;
|
||||
const currentTime = new Date().getTime();
|
||||
|
||||
// 计算当日达购物车金额
|
||||
this.isDayCarList.forEach(carItem => {
|
||||
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
||||
if (goods.checked) {
|
||||
const price = goods.commodity_goods_info.group_buy_price !== undefined && goods.commodity_goods_info.group_buy_price !== null ?
|
||||
goods.commodity_goods_info.group_buy_price :
|
||||
goods.commodity_goods_info.sales_price;
|
||||
total += price * goods.count;
|
||||
// 团购活动时间判断
|
||||
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info.start_time).getTime();
|
||||
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
total += goods.commodity_goods_info.group_buy_price * goods.count;
|
||||
} else {
|
||||
total += goods.commodity_goods_info.sales_price * goods.count;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -474,10 +481,14 @@ export default {
|
||||
this.shopCarList.forEach(carItem => {
|
||||
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
||||
if (goods.checked) {
|
||||
const price = goods.commodity_goods_info.group_buy_price !== undefined && goods.commodity_goods_info.group_buy_price !== null ?
|
||||
goods.commodity_goods_info.group_buy_price :
|
||||
goods.commodity_goods_info.sales_price;
|
||||
total += price * goods.count;
|
||||
// 团购活动时间判断
|
||||
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info.start_time).getTime();
|
||||
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
total += goods.commodity_goods_info.group_buy_price * goods.count;
|
||||
} else {
|
||||
total += goods.commodity_goods_info.sales_price * goods.count;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -486,81 +497,119 @@ export default {
|
||||
},
|
||||
|
||||
// 减少数量
|
||||
minus(carItem, goodsIndex, item) {
|
||||
let that = this;
|
||||
// 删除商品的通用方法
|
||||
deleteCarItem(carItem, goodsIndex, item) {
|
||||
const that = this;
|
||||
request(apiArr.deleteCar, "POST", {
|
||||
ids: [carItem.id],
|
||||
}).then((res) => {
|
||||
// 从商品列表中移除该商品
|
||||
item.splice(goodsIndex, 1);
|
||||
|
||||
if (carItem.count > 0) {
|
||||
if (carItem.count == carItem.commodity_goods_info.min_order_quantity) {
|
||||
uni.showToast({
|
||||
title: '最少购买' + carItem.commodity_goods_info.min_order_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
request(apiArr.deleteCar, "POST", {
|
||||
ids: [carItem.id],
|
||||
}).then((res) => {
|
||||
// 从商品列表中移除该商品
|
||||
item.splice(goodsIndex, 1);
|
||||
// 如果商家没有商品了,移除该商家
|
||||
if (item.length === 0) {
|
||||
// 分别检查并移除当日达和普通购物车中的商家
|
||||
const dayCarIndex = that.isDayCarList.findIndex(dayItem =>
|
||||
dayItem.commodity_cart_and_goods_model === item
|
||||
);
|
||||
const normalCarIndex = that.shopCarList.findIndex(normalItem =>
|
||||
normalItem.commodity_cart_and_goods_model === item
|
||||
);
|
||||
|
||||
// 更新购物车总数(API删除成功后再更新)
|
||||
that.shopCarTotal = that.shopCarTotal - carItem.commodity_goods_info.min_order_quantity;
|
||||
|
||||
// 如果商家没有商品了,移除该商家
|
||||
if (item.length === 0) {
|
||||
// 分别检查并移除当日达和普通购物车中的商家
|
||||
const dayCarIndex = that.isDayCarList.findIndex(dayItem =>
|
||||
dayItem.commodity_cart_and_goods_model === item
|
||||
);
|
||||
const normalCarIndex = that.shopCarList.findIndex(normalItem =>
|
||||
normalItem.commodity_cart_and_goods_model === item
|
||||
);
|
||||
|
||||
if (dayCarIndex !== -1) {
|
||||
that.isDayCarList.splice(dayCarIndex, 1);
|
||||
// 如果当日达购物车为空,更新显示状态
|
||||
if (that.isDayCarList.length === 0) {
|
||||
that.isDayshow = false;
|
||||
}
|
||||
}
|
||||
if (normalCarIndex !== -1) {
|
||||
that.shopCarList.splice(normalCarIndex, 1);
|
||||
// 如果普通购物车为空,更新显示状态
|
||||
if (that.shopCarList.length === 0) {
|
||||
that.parcelPostshow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
that.calcTotal();
|
||||
});
|
||||
} else {
|
||||
this.shopCarTotal = this.shopCarTotal - 1;
|
||||
carItem.count = carItem.count - 1;
|
||||
this.handleQuantityChange(carItem.count, carItem);
|
||||
if (dayCarIndex !== -1) {
|
||||
that.isDayCarList.splice(dayCarIndex, 1);
|
||||
// 如果当日达购物车为空,更新显示状态
|
||||
if (that.isDayCarList.length === 0) {
|
||||
that.isDayshow = false;
|
||||
}
|
||||
}
|
||||
if (normalCarIndex !== -1) {
|
||||
that.shopCarList.splice(normalCarIndex, 1);
|
||||
// 如果普通购物车为空,更新显示状态
|
||||
if (that.shopCarList.length === 0) {
|
||||
that.parcelPostshow = false;
|
||||
}
|
||||
}
|
||||
this.calcTotal();
|
||||
}
|
||||
},
|
||||
|
||||
that.calcTotal();
|
||||
}).catch(error => {
|
||||
console.error('删除商品失败:', error);
|
||||
uni.showToast({
|
||||
title: '删除失败,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 减少商品数量
|
||||
minus(carItem, goodsIndex, item) {
|
||||
const that = this;
|
||||
const currentTime = new Date().getTime();
|
||||
|
||||
// 检查商品是否有团购活动且在活动时间内
|
||||
const isGroupBuyActive = carItem.commodity_goods_info.group_buy_activity_info &&
|
||||
currentTime >= new Date(carItem.commodity_goods_info.group_buy_activity_info.start_time).getTime() &&
|
||||
currentTime <= new Date(carItem.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
|
||||
if (carItem.count > 0) {
|
||||
if (isGroupBuyActive && carItem.count === carItem.commodity_goods_info.min_order_quantity) {
|
||||
// 团购商品达到最小购买数量,提示用户并删除商品
|
||||
uni.showToast({
|
||||
title: '最少购买' + carItem.commodity_goods_info.min_order_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
// 更新购物车总数
|
||||
that.shopCarTotal = Math.max(0, that.shopCarTotal - carItem.commodity_goods_info.min_order_quantity);
|
||||
// 删除商品
|
||||
that.deleteCarItem(carItem, goodsIndex, item);
|
||||
} else {
|
||||
// 正常减少数量
|
||||
this.shopCarTotal = Math.max(0, this.shopCarTotal - 1);
|
||||
carItem.count = carItem.count - 1;
|
||||
this.handleQuantityChange(carItem.count, carItem);
|
||||
|
||||
// 如果数量减为0,删除商品
|
||||
if (carItem.count === 0) {
|
||||
that.deleteCarItem(carItem, goodsIndex, item);
|
||||
} else {
|
||||
// 只在数量不为0时计算总价
|
||||
this.calcTotal();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 添加数量
|
||||
add(carItem, goodsIndex) {
|
||||
if (carItem.count == 0) {
|
||||
carItem.count = carItem.commodity_goods_info.min_order_quantity
|
||||
this.shopCarTotal += carItem.commodity_goods_info.min_order_quantity;
|
||||
const currentTime = new Date().getTime();
|
||||
|
||||
const isGroupBuyActive = carItem.commodity_goods_info.group_buy_activity_info &&
|
||||
currentTime >= new Date(carItem.commodity_goods_info.group_buy_activity_info.start_time).getTime() &&
|
||||
currentTime <= new Date(carItem.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (isGroupBuyActive) {
|
||||
if (carItem.count == 0) {
|
||||
carItem.count = carItem.commodity_goods_info.min_order_quantity
|
||||
this.shopCarTotal += carItem.commodity_goods_info.min_order_quantity;
|
||||
} else {
|
||||
if (carItem.count == carItem.commodity_goods_info.total_stock) {
|
||||
uni.showToast({
|
||||
title: '库存不足',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (carItem.count == carItem.commodity_goods_info.max_limit_quantity) {
|
||||
uni.showToast({
|
||||
title: '一次最多购买' + carItem.commodity_goods_info.max_limit_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
carItem.count++;
|
||||
this.shopCarTotal++;
|
||||
}
|
||||
} else {
|
||||
if (carItem.count == carItem.commodity_goods_info.total_stock) {
|
||||
uni.showToast({
|
||||
title: '库存不足',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (carItem.count == carItem.commodity_goods_info.max_limit_quantity) {
|
||||
uni.showToast({
|
||||
title: '一次最多购买' + carItem.commodity_goods_info.max_limit_quantity + '件',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
carItem.count++;
|
||||
this.shopCarTotal++;
|
||||
}
|
||||
@ -647,6 +696,17 @@ export default {
|
||||
return Promise.resolve();
|
||||
});
|
||||
},
|
||||
//获取价格 - 该显示团购价还是正常价
|
||||
getPrice(item) {
|
||||
const currentTime = new Date().getTime();
|
||||
const startTime = new Date(item.commodity_goods_info.group_buy_activity_info.start_time).getTime();
|
||||
const endTime = new Date(item.commodity_goods_info.group_buy_activity_info.end_time).getTime();
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
return item.commodity_goods_info.group_buy_price;
|
||||
} else {
|
||||
return item.commodity_goods_info.sales_price;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@ -655,6 +715,9 @@ export default {
|
||||
this.localHeight = meun.height;
|
||||
this.getShopCar();
|
||||
},
|
||||
onShow() {
|
||||
this.getShopCar();
|
||||
},
|
||||
onReachBottom() { },
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user