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

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 {
width: 710rpx;
width: 100%;
height: 330rpx;
margin: 0 auto 0 auto;
border-radius: 14rpx;

View File

@ -90,7 +90,7 @@
</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"
@change="onSkuChange" @close="onSkuClose" />
</view>
@ -115,7 +115,7 @@
state.activity.status === 0 && state.goodsInfo.stock !== 0
? 'check-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">{{
fen2yuan(state.activity.price || state.goodsInfo.price)
}}</view>
@ -263,6 +263,7 @@
data: activity
} = await CombinationApi.getCombinationActivity(state.grouponId);
state.activity = activity;
// console.log(activity,"activity")
//
const {
data: spu

View File

@ -68,7 +68,7 @@
<detail-cell-sku :sku="state.selectedSku" @tap="state.showSelectSku = true" />
</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"
@close="state.showSelectSku = false" />
@ -102,14 +102,16 @@
timeStatusEnum === TimeStatusEnum.STARTED && state.goodsInfo.stock != 0
? 'check-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 v-if="timeStatusEnum === TimeStatusEnum.STARTED">
<view v-if="state.goodsInfo.stock === 0">已售罄</view>
<!-- <view v-else-if=" activity.remainingPurchases == 0">立即秒杀</view> -->
<view v-else>立即秒杀</view>
</view>
<view v-else>{{ timeStatusEnum }}</view>
</button>
<!-- {{timeStatusEnum}}---{{TimeStatusEnum.STARTED}} -->
</view>
</detail-tabbar>
</view>
@ -223,6 +225,7 @@
data
} = await SeckillApi.getSeckillActivity(id);
activity.value = data;
// console.log(activity.value,"activity.value")
timeStatusEnum.value = getTimeStatusEnum(activity.startTime, activity.endTime);
//

View File

@ -81,7 +81,7 @@
<!-- 用户组件用户订单 -->
<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'" />
</view>

View File

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

View File

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