【功能修复】修复商品拼团和秒杀价格的显示

pull/81/head
卢越 2024-08-16 17:29:09 +08:00
parent 283449fc3d
commit f4adfde90b
2 changed files with 262 additions and 270 deletions

View File

@ -1,154 +1,150 @@
<!-- 装修组件 - 拼团 --> <!-- 装修组件 - 拼团 -->
<template> <template>
<view> <view>
<view <view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap"
v-if="layoutType === 'threeCol'" :style="[{ margin: '-' + data.space + 'rpx' }]">
class="goods-sm-box ss-flex ss-flex-wrap" <view v-for="product in productList" :key="product.id" class="goods-card-box" :style="[
:style="[{ margin: '-' + data.space + 'rpx' }]"
>
<view
v-for="product in productList"
:key="product.id"
class="goods-card-box"
:style="[
{ {
padding: data.space + 'rpx', padding: data.space + 'rpx',
}, },
]" ]">
> <s-goods-column class="goods-card" size="sm" :goodsFields="data.fields" :tagStyle="tagStyle"
<s-goods-column :data="product" :titleColor="data.fields.name?.color" :topRadius="data.borderRadiusTop"
class="goods-card" :bottomRadius="data.borderRadiusBottom" @click="
size="sm"
:goodsFields="data.fields"
:tagStyle="tagStyle"
:data="product"
:titleColor="data.fields.name?.color"
:topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom"
@click="
sheep.$router.go('/pages/goods/groupon', { sheep.$router.go('/pages/goods/groupon', {
id: props.data.activityId, id: props.data.activityId,
}) })
" "></s-goods-column>
></s-goods-column> </view>
</view> </view>
</view> <!-- 样式2 一行一个 图片左 文案右 -->
<!-- 样式2 一行一个 图片左 文案右 --> <view class="goods-box" v-if="layoutType === 'oneCol'">
<view class="goods-box" v-if="layoutType === 'oneCol'"> <view class="goods-list" v-for="(product, index) in productList" :key="index"
<view :style="[{ marginBottom: space + 'px' }]">
class="goods-list" <s-goods-column class="goods-card" size="lg" :goodsFields="data.fields" :tagStyle="tagStyle"
v-for="(product, index) in productList" :data="product" :titleColor="data.fields.name?.color"
:key="index" :subTitleColor="data.fields.introduction?.color" :topRadius="data.borderRadiusTop"
:style="[{ marginBottom: space + 'px' }]" :bottomRadius="data.borderRadiusBottom" @click="
>
<s-goods-column
class="goods-card"
size="lg"
:goodsFields="data.fields"
:tagStyle="tagStyle"
:data="product"
:titleColor="data.fields.name?.color"
:subTitleColor="data.fields.introduction?.color"
:topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom"
@click="
sheep.$router.go('/pages/goods/groupon', { sheep.$router.go('/pages/goods/groupon', {
id: props.data.activityId, id: props.data.activityId,
}) })
" ">
> <template v-slot:cart>
<template v-slot:cart> <button class="ss-reset-button cart-btn" :style="[buyStyle]">
<button class="ss-reset-button cart-btn" :style="[buyStyle]"> {{ btnBuy?.type === 'text' ? btnBuy.text : '' }}
{{ btnBuy?.type === 'text' ? btnBuy.text : '' }} </button>
</button> </template>
</template> </s-goods-column>
</s-goods-column> </view>
</view> </view>
</view> </view>
</view>
</template> </template>
<script setup> <script setup>
/** /**
* 拼团 * 拼团
*/ */
import { computed, onMounted, ref } from 'vue'; import {
import sheep from '@/sheep'; computed,
import SpuApi from "@/sheep/api/product/spu"; onMounted,
import CombinationApi from "@/sheep/api/promotion/combination"; ref
} from 'vue';
import sheep from '@/sheep';
import SpuApi from "@/sheep/api/product/spu";
import CombinationApi from "@/sheep/api/promotion/combination";
// //
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
default() {}, default () {},
}, },
styles: { styles: {
type: Object, type: Object,
default() {}, default () {},
}, },
}); });
let { layoutType, tagStyle, btnBuy, space } = props.data; let {
let { marginLeft, marginRight } = props.styles; layoutType,
tagStyle,
btnBuy,
space
} = props.data;
let {
marginLeft,
marginRight
} = props.styles;
// //
const buyStyle = computed(() => { const buyStyle = computed(() => {
let btnBuy = props.data.btnBuy; let btnBuy = props.data.btnBuy;
if (btnBuy?.type === 'text') { if (btnBuy?.type === 'text') {
return { return {
background: `linear-gradient(to right, ${btnBuy.bgBeginColor}, ${btnBuy.bgEndColor})`, background: `linear-gradient(to right, ${btnBuy.bgBeginColor}, ${btnBuy.bgEndColor})`,
}; };
} }
if (btnBuy?.type === 'img') { if (btnBuy?.type === 'img') {
return { return {
width: '54rpx', width: '54rpx',
height: '54rpx', height: '54rpx',
background: `url(${sheep.$url.cdn(btnBuy.imgUrl)}) no-repeat`, background: `url(${sheep.$url.cdn(btnBuy.imgUrl)}) no-repeat`,
backgroundSize: '100% 100%', backgroundSize: '100% 100%',
}; };
} }
}); });
const productList = ref([]); const productList = ref([]);
onMounted(async () => { onMounted(async () => {
// todo@owen Yudao // todo@owen Yudao
const { data: activity } = await CombinationApi.getCombinationActivity(props.data.activityId); const {
const { data: spu } = await SpuApi.getSpuDetail(activity.spuId) data: activity
productList.value = [spu]; } = await CombinationApi.getCombinationActivity(props.data.activityId);
}); const {
data: spu
} = await SpuApi.getSpuDetail(activity.spuId)
//
activity.products.forEach((product) => {
spu.price = Math.min(spu.price, product.combinationPrice); // SPU
});
productList.value = [spu];
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.goods-list { .goods-list {
position: relative; position: relative;
.cart-btn {
position: absolute; .cart-btn {
bottom: 10rpx; position: absolute;
right: 20rpx; bottom: 10rpx;
z-index: 11; right: 20rpx;
height: 50rpx; z-index: 11;
line-height: 50rpx; height: 50rpx;
padding: 0 20rpx; line-height: 50rpx;
border-radius: 25rpx; padding: 0 20rpx;
font-size: 24rpx; border-radius: 25rpx;
color: #fff; font-size: 24rpx;
} color: #fff;
} }
.goods-list { }
&:nth-last-of-type(1) {
margin-bottom: 0 !important; .goods-list {
} &:nth-last-of-type(1) {
} margin-bottom: 0 !important;
.goods-sm-box { }
margin: 0 auto; }
box-sizing: border-box;
.goods-card-box { .goods-sm-box {
flex-shrink: 0; margin: 0 auto;
overflow: hidden; box-sizing: border-box;
width: 33.3%;
box-sizing: border-box; .goods-card-box {
} flex-shrink: 0;
} overflow: hidden;
</style> width: 33.3%;
box-sizing: border-box;
}
}
</style>

View File

@ -1,160 +1,156 @@
<!-- 装修组件 - 秒杀 --> <!-- 装修组件 - 秒杀 -->
<template> <template>
<view> <view>
<!-- 样式一三列 - 上图下文 --> <!-- 样式一三列 - 上图下文 -->
<view <view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap"
v-if="layoutType === 'threeCol'" :style="[{ margin: '-' + data.space + 'rpx' }]">
class="goods-sm-box ss-flex ss-flex-wrap" <view v-for="product in productList" :key="product.id" class="goods-card-box" :style="[
:style="[{ margin: '-' + data.space + 'rpx' }]"
>
<view
v-for="product in productList"
:key="product.id"
class="goods-card-box"
:style="[
{ {
padding: data.space + 'rpx', padding: data.space + 'rpx',
}, },
]" ]">
> <s-goods-column class="goods-card" size="sm" :goodsFields="data.fields" :tagStyle="tagStyle"
<s-goods-column :data="product" :titleColor="data.fields.name?.color" :topRadius="data.borderRadiusTop"
class="goods-card" :bottomRadius="data.borderRadiusBottom" @click="
size="sm"
:goodsFields="data.fields"
:tagStyle="tagStyle"
:data="product"
:titleColor="data.fields.name?.color"
:topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom"
@click="
sheep.$router.go('/pages/goods/seckill', { sheep.$router.go('/pages/goods/seckill', {
id: props.data.activityId, id: props.data.activityId,
}) })
" "></s-goods-column>
></s-goods-column> </view>
</view> </view>
</view> <!-- 样式二一列 - 左图右文 -->
<!-- 样式二一列 - 左图右文 --> <view class="goods-box" v-if="layoutType === 'oneCol'">
<view class="goods-box" v-if="layoutType === 'oneCol'"> <view class="goods-list" v-for="(product, index) in productList" :key="index"
<view :style="[{ marginBottom: space + 'px' }]">
class="goods-list" <s-goods-column class="goods-card" size="lg" :goodsFields="data.fields" :tagStyle="tagStyle"
v-for="(product, index) in productList" :data="product" :titleColor="data.fields.name?.color"
:key="index" :subTitleColor="data.fields.introduction?.color" :topRadius="data.borderRadiusTop"
:style="[{ marginBottom: space + 'px' }]" :bottomRadius="data.borderRadiusBottom" @click="
>
<s-goods-column
class="goods-card"
size="lg"
:goodsFields="data.fields"
:tagStyle="tagStyle"
:data="product"
:titleColor="data.fields.name?.color"
:subTitleColor="data.fields.introduction?.color"
:topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom"
@click="
sheep.$router.go('/pages/goods/seckill', { sheep.$router.go('/pages/goods/seckill', {
id: props.data.activityId, id: props.data.activityId,
}) })
" ">
> <template v-slot:cart>
<template v-slot:cart> <button class="ss-reset-button cart-btn" :style="[buyStyle]">
<button class="ss-reset-button cart-btn" :style="[buyStyle]"> {{ btnBuy?.type === 'text' ? btnBuy.text : '' }}
{{ btnBuy?.type === 'text' ? btnBuy.text : '' }} </button>
</button> </template>
</template> </s-goods-column>
</s-goods-column> </view>
</view> </view>
</view> </view>
</view>
</template> </template>
<script setup> <script setup>
/** /**
* 秒杀商品列表 * 秒杀商品列表
* *
* @property {Array} list 商品列表 * @property {Array} list 商品列表
*/ */
import { computed, onMounted, ref } from 'vue'; import {
import sheep from '@/sheep'; computed,
import SeckillApi from "@/sheep/api/promotion/seckill"; onMounted,
import SpuApi from "@/sheep/api/product/spu"; ref
} from 'vue';
import sheep from '@/sheep';
import SeckillApi from "@/sheep/api/promotion/seckill";
import SpuApi from "@/sheep/api/product/spu";
// //
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
default() {}, default () {},
}, },
styles: { styles: {
type: Object, type: Object,
default() {}, default () {},
}, },
}); });
let { layoutType, tagStyle, btnBuy, space } = props.data; let {
let { marginLeft, marginRight } = props.styles; layoutType,
tagStyle,
btnBuy,
space
} = props.data;
let {
marginLeft,
marginRight
} = props.styles;
// //
const buyStyle = computed(() => { const buyStyle = computed(() => {
let btnBuy = props.data.btnBuy; let btnBuy = props.data.btnBuy;
if (btnBuy?.type === 'text') { if (btnBuy?.type === 'text') {
return { return {
background: `linear-gradient(to right, ${btnBuy.bgBeginColor}, ${btnBuy.bgEndColor})`, background: `linear-gradient(to right, ${btnBuy.bgBeginColor}, ${btnBuy.bgEndColor})`,
}; };
} }
if (btnBuy?.type === 'img') { if (btnBuy?.type === 'img') {
return { return {
width: '54rpx', width: '54rpx',
height: '54rpx', height: '54rpx',
background: `url(${sheep.$url.cdn(btnBuy.imgUrl)}) no-repeat`, background: `url(${sheep.$url.cdn(btnBuy.imgUrl)}) no-repeat`,
backgroundSize: '100% 100%', backgroundSize: '100% 100%',
}; };
} }
}); });
// //
const productList = ref([]); const productList = ref([]);
// //
onMounted(async () => { onMounted(async () => {
// todo@owen Yudao // todo@owen Yudao
const { data: activity } = await SeckillApi.getSeckillActivity(props.data.activityId); const {
const { data: spu } = await SpuApi.getSpuDetail(activity.spuId) data: activity
productList.value = [spu]; } = await SeckillApi.getSeckillActivity(props.data.activityId);
}); const {
data: spu
} = await SpuApi.getSpuDetail(activity.spuId)
//
activity.products.forEach((product) => {
spu.price = Math.min(spu.price, product.seckillPrice); // SPU
});
productList.value = [spu];
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.header-box { .header-box {
height: 100rpx; height: 100rpx;
} }
.goods-list { .goods-list {
position: relative; position: relative;
&:nth-last-child(1) {
margin-bottom: 0 !important; &:nth-last-child(1) {
} margin-bottom: 0 !important;
.cart-btn { }
position: absolute;
bottom: 10rpx; .cart-btn {
right: 20rpx; position: absolute;
z-index: 11; bottom: 10rpx;
height: 50rpx; right: 20rpx;
line-height: 50rpx; z-index: 11;
padding: 0 20rpx; height: 50rpx;
border-radius: 25rpx; line-height: 50rpx;
font-size: 24rpx; padding: 0 20rpx;
color: #fff; border-radius: 25rpx;
} font-size: 24rpx;
} color: #fff;
.goods-sm-box { }
margin: 0 auto; }
box-sizing: border-box;
.goods-card-box { .goods-sm-box {
flex-shrink: 0; margin: 0 auto;
overflow: hidden; box-sizing: border-box;
width: 33.3%;
box-sizing: border-box; .goods-card-box {
} flex-shrink: 0;
} overflow: hidden;
</style> width: 33.3%;
box-sizing: border-box;
}
}
</style>