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

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,62 +1,34 @@
<!-- 装修组件 - 拼团 --> <!-- 装修组件 - 拼团 -->
<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 <view class="goods-list" v-for="(product, index) in productList" :key="index"
class="goods-list" :style="[{ marginBottom: space + 'px' }]">
v-for="(product, index) in productList" <s-goods-column class="goods-card" size="lg" :goodsFields="data.fields" :tagStyle="tagStyle"
:key="index" :data="product" :titleColor="data.fields.name?.color"
:style="[{ marginBottom: space + 'px' }]" :subTitleColor="data.fields.introduction?.color" :topRadius="data.borderRadiusTop"
> :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 : '' }}
@ -72,7 +44,11 @@
/** /**
* 拼团 * 拼团
*/ */
import { computed, onMounted, ref } from 'vue'; import {
computed,
onMounted,
ref
} from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import SpuApi from "@/sheep/api/product/spu"; import SpuApi from "@/sheep/api/product/spu";
import CombinationApi from "@/sheep/api/promotion/combination"; import CombinationApi from "@/sheep/api/promotion/combination";
@ -81,16 +57,24 @@
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(() => {
@ -114,8 +98,16 @@
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
} = 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]; productList.value = [spu];
}); });
</script> </script>
@ -123,6 +115,7 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.goods-list { .goods-list {
position: relative; position: relative;
.cart-btn { .cart-btn {
position: absolute; position: absolute;
bottom: 10rpx; bottom: 10rpx;
@ -136,14 +129,17 @@
color: #fff; color: #fff;
} }
} }
.goods-list { .goods-list {
&:nth-last-of-type(1) { &:nth-last-of-type(1) {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
} }
.goods-sm-box { .goods-sm-box {
margin: 0 auto; margin: 0 auto;
box-sizing: border-box; box-sizing: border-box;
.goods-card-box { .goods-card-box {
flex-shrink: 0; flex-shrink: 0;
overflow: hidden; overflow: hidden;

View File

@ -2,62 +2,34 @@
<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 <view class="goods-list" v-for="(product, index) in productList" :key="index"
class="goods-list" :style="[{ marginBottom: space + 'px' }]">
v-for="(product, index) in productList" <s-goods-column class="goods-card" size="lg" :goodsFields="data.fields" :tagStyle="tagStyle"
:key="index" :data="product" :titleColor="data.fields.name?.color"
:style="[{ marginBottom: space + 'px' }]" :subTitleColor="data.fields.introduction?.color" :topRadius="data.borderRadiusTop"
> :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 : '' }}
@ -75,7 +47,11 @@
* *
* @property {Array} list 商品列表 * @property {Array} list 商品列表
*/ */
import { computed, onMounted, ref } from 'vue'; import {
computed,
onMounted,
ref
} from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
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";
@ -84,16 +60,24 @@
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(() => {
@ -118,8 +102,16 @@
// //
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
} = 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]; productList.value = [spu];
}); });
</script> </script>
@ -131,9 +123,11 @@
.goods-list { .goods-list {
position: relative; position: relative;
&:nth-last-child(1) { &:nth-last-child(1) {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
.cart-btn { .cart-btn {
position: absolute; position: absolute;
bottom: 10rpx; bottom: 10rpx;
@ -147,9 +141,11 @@
color: #fff; color: #fff;
} }
} }
.goods-sm-box { .goods-sm-box {
margin: 0 auto; margin: 0 auto;
box-sizing: border-box; box-sizing: border-box;
.goods-card-box { .goods-card-box {
flex-shrink: 0; flex-shrink: 0;
overflow: hidden; overflow: hidden;