拼团与秒杀详情页面判断是否超出限购数量

This commit is contained in:
77 2024-10-12 17:10:36 +08:00
parent 5828d37b1a
commit a18bd4f01a
6 changed files with 24 additions and 10 deletions

View File

@ -264,7 +264,7 @@
// //
.header { .header {
width: 710rpx; width: 100%;
height: 330rpx; height: 330rpx;
margin: 0 auto 0 auto; margin: 0 auto 0 auto;
border-radius: 14rpx; border-radius: 14rpx;

View File

@ -90,7 +90,7 @@
</view> </view>
<!-- 规格与数量弹框 --> <!-- 规格与数量弹框 -->
<s-select-groupon-sku :show="state.showSelectSku" :goodsInfo="state.goodsInfo" <s-select-groupon-sku :activity="state.activity" :show="state.showSelectSku" :goodsInfo="state.goodsInfo"
:grouponAction="state.grouponAction" :grouponNum="state.grouponNum" @buy="onBuy" :grouponAction="state.grouponAction" :grouponNum="state.grouponNum" @buy="onBuy"
@change="onSkuChange" @close="onSkuClose" /> @change="onSkuChange" @close="onSkuClose" />
</view> </view>
@ -115,7 +115,7 @@
state.activity.status === 0 && state.goodsInfo.stock !== 0 state.activity.status === 0 && state.goodsInfo.stock !== 0
? 'check-btn-box' ? 'check-btn-box'
: 'disabled-btn-box' : 'disabled-btn-box'
" :disabled="state.goodsInfo.stock === 0 || state.activity.status !== 0"> " :disabled="state.goodsInfo.stock === 0 || state.activity.status !== 0 || state.activity.remainingPurchases == 0"">
<view class="btn-price">{{ <view class="btn-price">{{
fen2yuan(state.activity.price || state.goodsInfo.price) fen2yuan(state.activity.price || state.goodsInfo.price)
}}</view> }}</view>
@ -263,6 +263,7 @@
data: activity data: activity
} = await CombinationApi.getCombinationActivity(state.grouponId); } = await CombinationApi.getCombinationActivity(state.grouponId);
state.activity = activity; state.activity = activity;
// console.log(activity,"activity")
// //
const { const {
data: spu data: spu

View File

@ -68,7 +68,7 @@
<detail-cell-sku :sku="state.selectedSku" @tap="state.showSelectSku = true" /> <detail-cell-sku :sku="state.selectedSku" @tap="state.showSelectSku = true" />
</view> </view>
<!-- 规格与数量弹框 --> <!-- 规格与数量弹框 -->
<s-select-seckill-sku v-model="state.goodsInfo" :show="state.showSelectSku" <s-select-seckill-sku :activity="activity" v-model="state.goodsInfo" :show="state.showSelectSku"
:single-limit-count="activity.singleLimitCount" @buy="onBuy" @change="onSkuChange" :single-limit-count="activity.singleLimitCount" @buy="onBuy" @change="onSkuChange"
@close="state.showSelectSku = false" /> @close="state.showSelectSku = false" />
@ -102,14 +102,16 @@
timeStatusEnum === TimeStatusEnum.STARTED && state.goodsInfo.stock != 0 timeStatusEnum === TimeStatusEnum.STARTED && state.goodsInfo.stock != 0
? 'check-btn-box' ? 'check-btn-box'
: 'disabled-btn-box' : 'disabled-btn-box'
" :disabled="state.goodsInfo.stock === 0 || timeStatusEnum !== TimeStatusEnum.STARTED"> " :disabled="state.goodsInfo.stock === 0 || timeStatusEnum !== TimeStatusEnum.STARTED || activity.remainingPurchases == 0">
<view class="btn-price">{{ fen2yuan(state.goodsInfo.price) }}</view> <view class="btn-price">{{ fen2yuan(state.goodsInfo.price) }}</view>
<view v-if="timeStatusEnum === TimeStatusEnum.STARTED"> <view v-if="timeStatusEnum === TimeStatusEnum.STARTED">
<view v-if="state.goodsInfo.stock === 0">已售罄</view> <view v-if="state.goodsInfo.stock === 0">已售罄</view>
<!-- <view v-else-if=" activity.remainingPurchases == 0">立即秒杀</view> -->
<view v-else>立即秒杀</view> <view v-else>立即秒杀</view>
</view> </view>
<view v-else>{{ timeStatusEnum }}</view> <view v-else>{{ timeStatusEnum }}</view>
</button> </button>
<!-- {{timeStatusEnum}}---{{TimeStatusEnum.STARTED}} -->
</view> </view>
</detail-tabbar> </detail-tabbar>
</view> </view>
@ -223,6 +225,7 @@
data data
} = await SeckillApi.getSeckillActivity(id); } = await SeckillApi.getSeckillActivity(id);
activity.value = data; activity.value = data;
// console.log(activity.value,"activity.value")
timeStatusEnum.value = getTimeStatusEnum(activity.startTime, activity.endTime); timeStatusEnum.value = getTimeStatusEnum(activity.startTime, activity.endTime);
// //

View File

@ -81,7 +81,7 @@
<!-- 用户组件用户订单 --> <!-- 用户组件用户订单 -->
<s-order-card v-if="type === 'UserOrder'" :data="data" /> <s-order-card v-if="type === 'UserOrder'" :data="data" />
<!-- 用户组件用户资产 --> <!-- 用户组件用户资产 -->
<s-wallet-card v-if="type === 'UserWallet'" /> <s-wallet-card v-if="type === 'UserCard'" />
<!-- 用户组件用户卡券 --> <!-- 用户组件用户卡券 -->
<s-coupon-card v-if="type === 'UserCoupon'" /> <s-coupon-card v-if="type === 'UserCoupon'" />
</view> </view>

View File

@ -65,7 +65,7 @@
<view class="label-text">购买数量</view> <view class="label-text">购买数量</view>
<su-number-box <su-number-box
:min="1" :min="1"
:max="state.selectedSku.stock" :max="min([skuList[0].stock,activity.singleLimitCount,activity.remainingPurchases])"
:step="1" :step="1"
v-model="state.selectedSku.count" v-model="state.selectedSku.count"
@change="onNumberChange($event)" @change="onNumberChange($event)"
@ -97,6 +97,7 @@
<script setup> <script setup>
import { computed, reactive, watch } from 'vue'; import { computed, reactive, watch } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { isEmpty, min } from 'lodash-es';
import { convertProductPropertyList, fen2yuan } from '@/sheep/hooks/useGoods'; import { convertProductPropertyList, fen2yuan } from '@/sheep/hooks/useGoods';
const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-btn-long.png'); const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-btn-long.png');
@ -118,6 +119,10 @@
type: [Number, String], type: [Number, String],
default: 0, default: 0,
}, },
activity:{
type: Array,
default: 0,
}
}); });
const state = reactive({ const state = reactive({
selectedSku: {}, // SKU selectedSku: {}, // SKU
@ -133,6 +138,7 @@
for (let price of skuPrices) { for (let price of skuPrices) {
price.value_id_array = price.properties.map((item) => item.valueId); price.value_id_array = price.properties.map((item) => item.valueId);
} }
console.log(props.activity,"skuPrices")
return skuPrices; return skuPrices;
}); });
@ -152,8 +158,8 @@
if (e === 0) return; if (e === 0) return;
if (state.selectedSku.count === e) return; if (state.selectedSku.count === e) return;
state.selectedSku.count = e; state.selectedSku.count = e;
console.log(state.selectedSku)
} }
// //
function onBuy() { function onBuy() {
if (!state.selectedSku.id || state.selectedSku.id <= 0) { if (!state.selectedSku.id || state.selectedSku.id <= 0) {
@ -166,7 +172,6 @@
} }
emits('buy', state.selectedSku); emits('buy', state.selectedSku);
} }
// property // property
function changeDisabled(isChecked = false, propertyId = 0, valueId = 0) { function changeDisabled(isChecked = false, propertyId = 0, valueId = 0) {
let newSkus = []; // sku let newSkus = []; // sku

View File

@ -75,7 +75,7 @@
<view class="label-text">购买数量</view> <view class="label-text">购买数量</view>
<su-number-box <su-number-box
:min="1" :min="1"
:max="min([singleLimitCount, state.selectedSku.stock])" :max="min([skuList[0].stock,activity.singleLimitCount,activity.remainingPurchases])"
:step="1" :step="1"
v-model="state.selectedSku.count" v-model="state.selectedSku.count"
@change="onBuyCountChange($event)" @change="onBuyCountChange($event)"
@ -122,12 +122,17 @@
type: Number, type: Number,
default: 1, default: 1,
}, },
activity:{
type: Array,
default: 0,
}
}); });
const state = reactive({ const state = reactive({
goodsInfo: computed(() => props.modelValue), goodsInfo: computed(() => props.modelValue),
selectedSku: {}, selectedSku: {},
currentPropertyArray: [], currentPropertyArray: [],
}); });
// console.log(props.activity,"activity");
const getShowPriceText = computed(() => { const getShowPriceText = computed(() => {
let priceText = `${fen2yuan(state.goodsInfo.price)}`; let priceText = `${fen2yuan(state.goodsInfo.price)}`;
if (!isEmpty(state.selectedSku)) { if (!isEmpty(state.selectedSku)) {