498 lines
12 KiB
Vue
498 lines
12 KiB
Vue
<template>
|
|
<s-layout title="商品详情">
|
|
<view>
|
|
<detailSkeleton v-if="state.skeletonLoading" />
|
|
<!-- 下架/售罄提醒 -->
|
|
<s-empty v-else-if="state.goodsInfo === null" text="商品不存在或已下架" icon="/static/soldout-empty.png" showAction
|
|
actionText="再逛逛" actionUrl="/pages/AI/index" />
|
|
<block v-else>
|
|
<view class="detail-swiper-selector">
|
|
<!-- 商品轮播图 -->
|
|
<su-swiper class="" isPreview :list="formatGoodsSwiper(state.goodsInfo.sliderPicUrls)" otStyle="tag"
|
|
imageMode="widthFix" dotCur="bg-mask-40" :seizeHeight="750" />
|
|
<!-- 限时折扣/会员价的优惠信息 -->
|
|
<view v-if="!show" class="session">
|
|
<view class="bg w100 h100 h_152">
|
|
<image class="w100 h100" :src="$url + 'ai/2.png'" mode="scaleToFill" />
|
|
</view>
|
|
<view class="sessionCon w100 h100 h_152 flex-center ju-between p-x-40">
|
|
<view>
|
|
<view class="flex-row al-flex-end m-b-8" style="color: #fff">
|
|
<view class="size44 weight500">
|
|
<span class="size32">¥</span>{{ $fen2yuan(state.goodsInfo.discountedPrice?state.goodsInfo.discountedPrice:state.goodsInfo.price) }}
|
|
</view>
|
|
<view class="size24 m-l-14 m-r-6 through" v-if="state.goodsInfo.marketPrice">
|
|
¥{{ $fen2yuan(state.goodsInfo.discountedPrice?state.goodsInfo.price:state.goodsInfo.marketPrice) }}</view>
|
|
<view class="size24">已售</view>
|
|
</view>
|
|
<view class="flex-row relative">
|
|
<view class="w_348 h_37">
|
|
<image class="w100 h100" :src="$url + 'ai/3.png'" mode="scaleToFill" />
|
|
</view>
|
|
<view class="absolute t0 l0 size20 c27 line37 p-l-10">
|
|
限时省{{ $fen2yuan(state.goodsInfo.marketPrice - state.goodsInfo.price) }}元
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view>
|
|
<view class="c15 size28 m-b-22">距离活动{{ timeText }}</view>
|
|
<view>
|
|
<uni-countdown color="#FFFFFF" background-color="#FF393A" border-color="#FF393A" :show-day="false"
|
|
:hour="hour" :minute="minute" :second="second" @timeup="timeup"></uni-countdown>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- 价格+标题 -->
|
|
<view class="title-card detail-card ss-p-y-32 ss-p-x-32" :class="{ 'm-t-52': !show }">
|
|
<view class="title-text ss-line-2 ss-m-b-6 flex-center ju-flex-start">
|
|
<view class="label m-r-10 shrink" v-if="state.goodsInfo.tagSaleName">{{
|
|
state.goodsInfo.tagSaleName
|
|
}}</view>
|
|
<view>{{ state.goodsInfo.name }}</view>
|
|
</view>
|
|
<view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view>
|
|
</view>
|
|
|
|
<!-- 功能卡片 -->
|
|
<view class="detail-cell-card detail-card ss-flex-col">
|
|
<detail-cell-sku v-model="state.selectedSku.goods_sku_text" :sku="state.selectedSku" @tap="addCar" theme="2"
|
|
v-if="timeText !== '开始'" />
|
|
<detail-cell v-if="state.goodsInfo.deliverPlace || state.goodsInfo.deliverTime" label="发货" :value="`${state.goodsInfo.deliverPlace || ''} ${state.goodsInfo.deliverPlace || state.goodsInfo.deliverTime ? '|' : ''
|
|
} ${state.goodsInfo.deliverTime || ''}`" />
|
|
<detail-cell theme="2" label="运费" value="免运费(请以提交订单为准)" />
|
|
</view>
|
|
|
|
<!-- 详情 -->
|
|
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
|
|
</view>
|
|
</block>
|
|
<view class="theme-ai" v-if="state.goodsInfo && state.goodsInfo.id">
|
|
<card_payment ref="paymentRef" source="orderInfo" :actionStatus="timeText" :bottomOffset="paymentBottomOffset"
|
|
@addCar="addCar" @updatePrice="updatePrice" />
|
|
</view>
|
|
<su-fixed bottom placeholder bg="bg24" :zIndex="1"
|
|
v-if="state.goodsInfo && state.goodsInfo.id && !hasCartItems">
|
|
<view class="buy-now-bar bg24">
|
|
<view class="ai-button1 buy-now-btn" @tap="addCar">立即购买</view>
|
|
</view>
|
|
</su-fixed>
|
|
</view>
|
|
</s-layout>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { computed, ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
|
|
import { onLoad, onPageScroll } from '@dcloudio/uni-app';
|
|
import sheep from '@/sheep';
|
|
// import { onPageScroll} from '@dcloudio/uni-app';
|
|
|
|
import card_payment from '@/components/card_payment/card_payment';
|
|
import detailNavbar from '../goods/components/detail/detail-navbar.vue';
|
|
import detailCellSku from '../goods/components/detail/detail-cell-sku.vue';
|
|
|
|
import detailCell from '../goods/components/detail/detail-cell.vue';
|
|
import detailTabbar from '../goods/components/detail/detail-tabbar.vue';
|
|
import detailSkeleton from '../goods/components/detail/detail-skeleton.vue';
|
|
import detailCommentCard from '../goods/components/detail/detail-comment-card.vue';
|
|
import detailContentCard from '../goods/components/detail/detail-content-card.vue';
|
|
import detailActivityTip from '../goods/components/detail/detail-activity-tip.vue';
|
|
import {
|
|
formatSales,
|
|
formatGoodsSwiper,
|
|
fen2yuan,
|
|
fen2yuanSimple,
|
|
formatDiscountPercent,
|
|
getRewardActivityRuleItemDescriptions,
|
|
} from '@/sheep/hooks/useGoods';
|
|
import * as api from '@/sheep/api/ai/index';
|
|
let { proxy } = getCurrentInstance();
|
|
const state = reactive({
|
|
skeletonLoading: false,
|
|
goodsInfo: {},
|
|
selectedSku: {}, // 选中的 SKU
|
|
});
|
|
const getInfo = async () => {
|
|
let res = await api.getSpuDetail(id.value, shoppingPlazaId.value);
|
|
if (res.code === 0) {
|
|
state.goodsInfo = res.data;
|
|
timeChange();
|
|
}
|
|
};
|
|
let id = ref();
|
|
let shoppingPlazaId = ref();
|
|
const hasCartItems = ref(false);
|
|
onLoad(async (options) => {
|
|
// 滚到顶部
|
|
uni.pageScrollTo({
|
|
scrollTop: 0,
|
|
});
|
|
id.value = options.id;
|
|
shoppingPlazaId.value = options.shopId;
|
|
getInfo();
|
|
}); // 规格变更
|
|
function onSkuChange(e) {
|
|
state.selectedSku = e;
|
|
state.settlementSku = e;
|
|
}
|
|
const onAddCart = () => { };
|
|
const onBuy = () => { };
|
|
let paymentRef = ref(null);
|
|
const updatePrice = (val) => {
|
|
hasCartItems.value = !!val;
|
|
};
|
|
const addCar = () => {
|
|
paymentRef.value.addCar({ ...state.goodsInfo, shoppingPlazaId: shoppingPlazaId.value });
|
|
};
|
|
/**
|
|
* 倒计时
|
|
*/
|
|
|
|
let show = ref(false);
|
|
let timeText = ref('开始');
|
|
let hour = ref(0);
|
|
let minute = ref(0);
|
|
let second = ref(0);
|
|
const timeup = () => {
|
|
show.value = true;
|
|
timeChange();
|
|
};
|
|
const timeChange = () => {
|
|
show.value = false;
|
|
let data = state.goodsInfo;
|
|
let endTime = data.endTime;
|
|
let startTime = data.startTime;
|
|
// 当前时间戳
|
|
let currentTime = Date.now();
|
|
let time = null;
|
|
if (currentTime < startTime) {
|
|
timeText.value = '开始';
|
|
time = startTime - currentTime;
|
|
} else if (currentTime > startTime && currentTime < endTime) {
|
|
timeText.value = '结束';
|
|
time = endTime - currentTime;
|
|
} else {
|
|
show.value = true;
|
|
timeText.value = '已结束';
|
|
}
|
|
if (time) {
|
|
hour.value = Math.floor(time / 1000 / 60 / 60);
|
|
minute.value = Math.floor(time / 1000 / 60) % 60;
|
|
second.value = Math.floor(time / 1000) % 60;
|
|
}
|
|
};
|
|
// inner
|
|
let navBar = ref('inner');
|
|
let scrollTop = ref(0);
|
|
onPageScroll((e) => {
|
|
//console.log(e)
|
|
scrollTop.value = e.scrollTop;
|
|
if (e.scrollTop > 20) {
|
|
navBar.value = 'normal';
|
|
} else {
|
|
navBar.value = 'inner';
|
|
}
|
|
});
|
|
|
|
let sysInfo = uni.getSystemInfoSync();
|
|
const windowHeight = sysInfo.windowHeight;
|
|
let height = ref(0);
|
|
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
|
|
const buyBarOffset =
|
|
uni.upx2px(120) + Number(sheep?.$platform?.device?.safeAreaInsets?.bottom || 0);
|
|
const paymentBottomOffset = computed(() => (hasCartItems.value ? 0 : buyBarOffset));
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.detail-card {
|
|
background-color: #ffffff;
|
|
border-radius: 10rpx;
|
|
overflow: hidden;
|
|
margin-bottom: 40rpx;
|
|
// color: #ffffff;
|
|
}
|
|
|
|
// 价格标题卡片
|
|
.title-card {
|
|
.price-box {
|
|
.price-text {
|
|
font-size: 42rpx;
|
|
font-weight: 500;
|
|
color: #ff3000;
|
|
line-height: 30rpx;
|
|
font-family: OPPOSANS;
|
|
|
|
&::before {
|
|
content: '¥';
|
|
font-size: 30rpx;
|
|
}
|
|
}
|
|
|
|
.origin-price-text {
|
|
font-size: 26rpx;
|
|
font-weight: 400;
|
|
text-decoration: line-through;
|
|
color: $gray-c;
|
|
font-family: OPPOSANS;
|
|
|
|
&::before {
|
|
content: '¥';
|
|
}
|
|
}
|
|
}
|
|
|
|
.sales-text {
|
|
font-size: 26rpx;
|
|
font-weight: 500;
|
|
color: $gray-c;
|
|
}
|
|
|
|
.discounts-box {
|
|
.tag-content {
|
|
flex: 1;
|
|
min-width: 0;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.tag-box {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.tag {
|
|
flex-shrink: 0;
|
|
padding: 4rpx 10rpx;
|
|
font-size: 24rpx;
|
|
font-weight: 500;
|
|
border-radius: 4rpx;
|
|
color: var(--ui-BG-Main);
|
|
background: var(--ui-BG-Main-tag);
|
|
}
|
|
|
|
.discounts-title {
|
|
font-size: 24rpx;
|
|
font-weight: 500;
|
|
color: var(--ui-BG-Main);
|
|
line-height: normal;
|
|
}
|
|
|
|
.cicon-forward {
|
|
color: var(--ui-BG-Main);
|
|
font-size: 24rpx;
|
|
line-height: normal;
|
|
margin-top: 4rpx;
|
|
}
|
|
}
|
|
|
|
.title-text {
|
|
font-size: 32rpx;
|
|
line-height: 42rpx;
|
|
}
|
|
|
|
.subtitle-text {
|
|
font-size: 26rpx;
|
|
font-weight: 400;
|
|
color: $dark-9;
|
|
line-height: 42rpx;
|
|
}
|
|
}
|
|
|
|
// 购买
|
|
.buy-box {
|
|
.add-btn {
|
|
width: 240rpx;
|
|
height: 72rpx;
|
|
font-weight: 500;
|
|
font-size: 30rpx;
|
|
border-radius: 12rpx 0 0 12rpx;
|
|
background: #fa8735;
|
|
color: #ffffff;
|
|
}
|
|
|
|
.buy-btn {
|
|
width: 240rpx;
|
|
height: 72rpx;
|
|
font-weight: 500;
|
|
font-size: 30rpx;
|
|
border-radius: 0 12rpx 12rpx 0;
|
|
background: #fe3b48;
|
|
color: #ffffff;
|
|
}
|
|
|
|
.disabled-btn {
|
|
width: 428rpx;
|
|
height: 72rpx;
|
|
border-radius: 40rpx;
|
|
background: #999999;
|
|
color: $white;
|
|
}
|
|
}
|
|
|
|
.model-box {
|
|
height: 60vh;
|
|
|
|
.model-content {
|
|
height: 56vh;
|
|
}
|
|
|
|
.title {
|
|
font-size: 36rpx;
|
|
font-weight: bold;
|
|
color: #333333;
|
|
}
|
|
|
|
.subtitle {
|
|
font-size: 26rpx;
|
|
font-weight: 500;
|
|
color: #333333;
|
|
}
|
|
}
|
|
|
|
// 限时折扣
|
|
.discount {
|
|
position: relative;
|
|
}
|
|
|
|
.disImg {
|
|
width: 750rpx;
|
|
height: 100rpx;
|
|
position: absolute;
|
|
top: 0;
|
|
z-index: -1;
|
|
}
|
|
|
|
.discountCont {
|
|
width: 680rpx;
|
|
height: 90rpx;
|
|
margin: 10rpx auto 0 auto;
|
|
// background-color: gold;
|
|
}
|
|
|
|
.disContT {
|
|
width: 680rpx;
|
|
height: 50rpx;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.disContT1 {
|
|
// width: 400rpx;
|
|
// height: 50rpx;
|
|
// background-color: green;
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
}
|
|
|
|
.disContT2 {
|
|
width: 200rpx;
|
|
height: 50rpx;
|
|
line-height: 50rpx;
|
|
// background-color: gold;
|
|
font-size: 30rpx;
|
|
text-align: end;
|
|
color: #ff393a;
|
|
font-weight: bolder;
|
|
font-style: oblique 20deg;
|
|
letter-spacing: 0.1rem;
|
|
}
|
|
|
|
.disContT1P {
|
|
color: white;
|
|
font-size: 44rpx;
|
|
}
|
|
|
|
.disContT1End {
|
|
// width: 180rpx;
|
|
padding: 0 20rpx;
|
|
height: 36rpx;
|
|
line-height: 36rpx;
|
|
text-align: center;
|
|
background-color: #fee2be;
|
|
color: #f71b1b;
|
|
font-size: 23rpx;
|
|
border-radius: 20rpx;
|
|
margin-left: 26rpx;
|
|
}
|
|
|
|
.disContB {
|
|
width: 680rpx;
|
|
height: 40rpx;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
font-size: 20rpx;
|
|
color: white;
|
|
align-items: center;
|
|
}
|
|
|
|
.disContB1 {
|
|
width: 300rpx;
|
|
height: 40rpx;
|
|
line-height: 40rpx;
|
|
color: #ffcccc;
|
|
font-size: 24rpx;
|
|
// 删除线
|
|
text-decoration: line-through;
|
|
padding-left: 6rpx;
|
|
}
|
|
|
|
.disContB2 {
|
|
width: 300rpx;
|
|
height: 40rpx;
|
|
line-height: 40rpx;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.label {
|
|
display: inline-block;
|
|
font-size: 20rpx;
|
|
color: #ff5040;
|
|
border: 1px solid #ff5040;
|
|
border-radius: 8rpx;
|
|
padding: 0 8rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.session {
|
|
position: relative;
|
|
}
|
|
|
|
.bg {
|
|
position: absolute;
|
|
top: 0;
|
|
top: -100rpx;
|
|
left: 0;
|
|
}
|
|
|
|
.sessionCon {
|
|
position: absolute;
|
|
top: 0;
|
|
top: -100rpx;
|
|
left: 0;
|
|
}
|
|
|
|
.buy-now-bar {
|
|
height: 120rpx;
|
|
padding: 20rpx 32rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.buy-now-btn {
|
|
width: 100%;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
text-align: center;
|
|
}
|
|
|
|
:deep(.uni-countdown__number) {
|
|
font-size: 24rpx !important;
|
|
width: 40rpx !important;
|
|
height: 40rpx !important;
|
|
line-height: 40rpx !important;
|
|
}
|
|
|
|
:deep(.uni-countdown__splitor) {
|
|
color: #ff393a !important;
|
|
}
|
|
</style>
|