接入秒杀100%
parent
c2f29333dc
commit
1694a6f554
|
@ -106,13 +106,7 @@
|
||||||
import { useDurationTime } from '@/sheep/hooks/useGoods';
|
import { useDurationTime } from '@/sheep/hooks/useGoods';
|
||||||
import SeckillApi from "@/sheep/api/promotion/seckill";
|
import SeckillApi from "@/sheep/api/promotion/seckill";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import {TimeStatusEnum} from "@/sheep/util/const";
|
||||||
// 时间段的状态枚举
|
|
||||||
const TimeStatusEnum = {
|
|
||||||
WAIT_START: '即将开始',
|
|
||||||
STARTED: '进行中',
|
|
||||||
END: '已结束',
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算页面高度
|
// 计算页面高度
|
||||||
const { safeAreaInsets, safeArea } = sheep.$platform.device;
|
const { safeAreaInsets, safeArea } = sheep.$platform.device;
|
||||||
|
|
|
@ -133,7 +133,6 @@
|
||||||
</view>
|
</view>
|
||||||
</detail-tabbar>
|
</detail-tabbar>
|
||||||
</block>
|
</block>
|
||||||
<!-- 轮播 -->
|
|
||||||
</s-layout>
|
</s-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<detailNavbar />
|
<detailNavbar />
|
||||||
<!-- 骨架屏 -->
|
<!-- 骨架屏 -->
|
||||||
<detailSkeleton v-if="state.skeletonLoading" />
|
<detailSkeleton v-if="state.skeletonLoading" />
|
||||||
<!-- 空置页 -->
|
<!-- 下架/售罄提醒 -->
|
||||||
<s-empty
|
<s-empty
|
||||||
v-else-if="state.goodsInfo === null || state.goodsInfo.activity_type !== 'seckill'"
|
v-else-if="state.goodsInfo === null || state.goodsInfo.activity_type !== 'seckill'"
|
||||||
text="活动不存在或已结束"
|
text="活动不存在或已结束"
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
/>
|
/>
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<view class="detail-swiper-selector">
|
<view class="detail-swiper-selector">
|
||||||
<!-- 轮播 -->
|
<!-- 商品图轮播 -->
|
||||||
<su-swiper
|
<su-swiper
|
||||||
class="ss-m-b-14"
|
class="ss-m-b-14"
|
||||||
isPreview
|
isPreview
|
||||||
|
@ -63,14 +63,13 @@
|
||||||
<detail-progress :percent="state.percent" />
|
<detail-progress :percent="state.percent" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo.name }}</view>
|
<view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo?.name }}</view>
|
||||||
<view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view>
|
<view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 功能卡片 -->
|
<!-- 功能卡片 -->
|
||||||
<view class="detail-cell-card detail-card ss-flex-col">
|
<view class="detail-cell-card detail-card ss-flex-col">
|
||||||
<detail-cell-sku
|
<detail-cell-sku
|
||||||
v-model="state.selectedSku.goods_sku_text"
|
|
||||||
:sku="state.selectedSku"
|
:sku="state.selectedSku"
|
||||||
@tap="state.showSelectSku = true"
|
@tap="state.showSelectSku = true"
|
||||||
/>
|
/>
|
||||||
|
@ -108,30 +107,27 @@
|
||||||
<button v-else class="ss-reset-button origin-price-btn ss-flex-col">
|
<button v-else class="ss-reset-button origin-price-btn ss-flex-col">
|
||||||
<view
|
<view
|
||||||
class="no-original"
|
class="no-original"
|
||||||
:class="
|
:class="state.goodsInfo.stock === 0 || timeStatusEnum !== TimeStatusEnum.STARTED ? '' : ''"
|
||||||
state.goodsInfo.stock === 0 || activity.status != 'ing' ? '' : ''
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
秒杀价
|
秒杀价
|
||||||
</view>
|
</view>
|
||||||
</button>
|
</button>
|
||||||
<!-- TODO @疯狂:status 判断不太对 -->
|
|
||||||
<button
|
<button
|
||||||
class="ss-reset-button btn-box ss-flex-col"
|
class="ss-reset-button btn-box ss-flex-col"
|
||||||
@tap="state.showSelectSku = true"
|
@tap="state.showSelectSku = true"
|
||||||
:class="
|
:class="
|
||||||
activity.status === 'ing' && 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 || activity.status != 'ing'"
|
:disabled="state.goodsInfo.stock === 0 || timeStatusEnum !== TimeStatusEnum.STARTED"
|
||||||
>
|
>
|
||||||
<view class="btn-price">{{ fen2yuan(state.goodsInfo.price) }}</view>
|
<view class="btn-price">{{ fen2yuan(state.goodsInfo.price) }}</view>
|
||||||
<view v-if="activity.status === 'ing'">
|
<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>立即秒杀</view>
|
<view v-else>立即秒杀</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-else>{{ activity.status_text }}</view>
|
<view v-else>{{ timeStatusEnum }}</view>
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</detail-tabbar>
|
</detail-tabbar>
|
||||||
|
@ -154,6 +150,7 @@
|
||||||
import detailProgress from './components/detail/detail-progress.vue';
|
import detailProgress from './components/detail/detail-progress.vue';
|
||||||
import SeckillApi from "@/sheep/api/promotion/seckill";
|
import SeckillApi from "@/sheep/api/promotion/seckill";
|
||||||
import SpuApi from "@/sheep/api/product/spu";
|
import SpuApi from "@/sheep/api/product/spu";
|
||||||
|
import {getTimeStatusEnum, TimeStatusEnum} from "@/sheep/util/const";
|
||||||
|
|
||||||
const headerBg = sheep.$url.css('/static/img/shop/goods/seckill-bg.png');
|
const headerBg = sheep.$url.css('/static/img/shop/goods/seckill-bg.png');
|
||||||
const btnBg = sheep.$url.css('/static/img/shop/goods/seckill-btn.png');
|
const btnBg = sheep.$url.css('/static/img/shop/goods/seckill-btn.png');
|
||||||
|
@ -186,49 +183,51 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// 立即购买
|
// 立即购买
|
||||||
function onBuy(e) {
|
function onBuy(sku) {
|
||||||
sheep.$router.go('/pages/order/confirm', {
|
sheep.$router.go('/pages/order/confirm', {
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
order_type: 'goods',
|
order_type: 'goods',
|
||||||
buy_type: 'seckill',
|
buy_type: 'seckill',
|
||||||
activityId: activity.value.id,
|
seckillActivityId: activity.value.id,
|
||||||
goods_list: [
|
items: [
|
||||||
{
|
{
|
||||||
goods_id: e.goods_id,
|
skuId: sku.id,
|
||||||
goods_num: e.goods_num,
|
count: sku.count,
|
||||||
goods_sku_price_id: e.id,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分享信息
|
||||||
const shareInfo = computed(() => {
|
const shareInfo = computed(() => {
|
||||||
if (isEmpty(state.goodsInfo?.activity)) return {};
|
if (isEmpty(activity)) return {};
|
||||||
return sheep.$platform.share.getShareInfo(
|
return sheep.$platform.share.getShareInfo(
|
||||||
{
|
{
|
||||||
title: state.goodsInfo.name,
|
title: activity.value.name,
|
||||||
image: sheep.$url.cdn(state.goodsInfo.picUrl),
|
image: sheep.$url.cdn(state.goodsInfo.picUrl),
|
||||||
params: {
|
params: {
|
||||||
page: '4',
|
page: '4',
|
||||||
query: state.goodsInfo.id + ',' + activity.value.id,
|
query: activity.value.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'goods', // 商品海报
|
type: 'goods', // 商品海报
|
||||||
title: state.goodsInfo.name, // 商品标题
|
title: activity.value.name, // 商品标题
|
||||||
image: sheep.$url.cdn(state.goodsInfo.picUrl), // 商品主图
|
image: sheep.$url.cdn(state.goodsInfo.picUrl), // 商品主图
|
||||||
price: state.goodsInfo.price[0], // 商品价格
|
price: state.goodsInfo.price, // 商品价格
|
||||||
marketPrice: state.goodsInfo.marketPrice, // 商品原价
|
marketPrice: state.goodsInfo.marketPrice, // 商品原价
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const activity = ref()
|
const activity = ref()
|
||||||
|
const timeStatusEnum = ref('')
|
||||||
// 查询活动
|
// 查询活动
|
||||||
const getActivity = async (id) => {
|
const getActivity = async (id) => {
|
||||||
const { data } = await SeckillApi.getSeckillActivity(id)
|
const { data } = await SeckillApi.getSeckillActivity(id)
|
||||||
activity.value = data
|
activity.value = data
|
||||||
|
timeStatusEnum.value = getTimeStatusEnum(activity.startTime, activity.endTime)
|
||||||
|
|
||||||
// 查询商品
|
// 查询商品
|
||||||
await getSpu(data.spuId)
|
await getSpu(data.spuId)
|
||||||
|
@ -247,7 +246,6 @@
|
||||||
|
|
||||||
// 价格、库存使用活动的
|
// 价格、库存使用活动的
|
||||||
data.skus.forEach(sku => {
|
data.skus.forEach(sku => {
|
||||||
debugger
|
|
||||||
const product = activity.value.products.find(product => product.skuId === sku.id);
|
const product = activity.value.products.find(product => product.skuId === sku.id);
|
||||||
if (product) {
|
if (product) {
|
||||||
sku.price = product.seckillPrice;
|
sku.price = product.seckillPrice;
|
||||||
|
|
|
@ -281,7 +281,7 @@
|
||||||
|
|
||||||
// 判断所有 property 大类是否选择完成
|
// 判断所有 property 大类是否选择完成
|
||||||
if (choosePropertyId.length === propertyList.length && newSkuList.length) {
|
if (choosePropertyId.length === propertyList.length && newSkuList.length) {
|
||||||
newSkuList[0].goods_num = state.selectedSku.goods_num || 1;
|
newSkuList[0].count = state.selectedSku.count || 1;
|
||||||
state.selectedSku = newSkuList[0];
|
state.selectedSku = newSkuList[0];
|
||||||
} else {
|
} else {
|
||||||
state.selectedSku = {};
|
state.selectedSku = {};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// ========== MALL - 营销模块 ==========
|
// ========== MALL - 营销模块 ==========
|
||||||
|
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠类型枚举
|
* 优惠类型枚举
|
||||||
*/
|
*/
|
||||||
|
@ -45,3 +47,22 @@ export const PromotionProductScopeEnum = {
|
||||||
name: '品类劵'
|
name: '品类劵'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 时间段的状态枚举
|
||||||
|
export const TimeStatusEnum = {
|
||||||
|
WAIT_START: '即将开始',
|
||||||
|
STARTED: '进行中',
|
||||||
|
END: '已结束',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getTimeStatusEnum = (startTime, endTime) => {
|
||||||
|
const now = dayjs();
|
||||||
|
if (now.isBefore(startTime)) {
|
||||||
|
return TimeStatusEnum.WAIT_START;
|
||||||
|
} else if (now.isAfter(endTime)) {
|
||||||
|
return TimeStatusEnum.END;
|
||||||
|
} else {
|
||||||
|
return TimeStatusEnum.STARTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue