【功能修复】修复商品拼团和秒杀价格的显示
							parent
							
								
									283449fc3d
								
							
						
					
					
						commit
						f4adfde90b
					
				| 
						 | 
				
			
			@ -1,62 +1,34 @@
 | 
			
		|||
<!-- 装修组件 - 拼团 -->
 | 
			
		||||
<template>
 | 
			
		||||
	<view>
 | 
			
		||||
    <view
 | 
			
		||||
      v-if="layoutType === 'threeCol'"
 | 
			
		||||
      class="goods-sm-box ss-flex ss-flex-wrap"
 | 
			
		||||
      :style="[{ margin: '-' + data.space + 'rpx' }]"
 | 
			
		||||
    >
 | 
			
		||||
      <view
 | 
			
		||||
        v-for="product in productList"
 | 
			
		||||
        :key="product.id"
 | 
			
		||||
        class="goods-card-box"
 | 
			
		||||
        :style="[
 | 
			
		||||
		<view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap"
 | 
			
		||||
			:style="[{ margin: '-' + data.space + 'rpx' }]">
 | 
			
		||||
			<view v-for="product in productList" :key="product.id" class="goods-card-box" :style="[
 | 
			
		||||
          {
 | 
			
		||||
            padding: data.space + 'rpx',
 | 
			
		||||
          },
 | 
			
		||||
        ]"
 | 
			
		||||
      >
 | 
			
		||||
        <s-goods-column
 | 
			
		||||
          class="goods-card"
 | 
			
		||||
          size="sm"
 | 
			
		||||
          :goodsFields="data.fields"
 | 
			
		||||
          :tagStyle="tagStyle"
 | 
			
		||||
          :data="product"
 | 
			
		||||
          :titleColor="data.fields.name?.color"
 | 
			
		||||
          :topRadius="data.borderRadiusTop"
 | 
			
		||||
          :bottomRadius="data.borderRadiusBottom"
 | 
			
		||||
          @click="
 | 
			
		||||
        ]">
 | 
			
		||||
				<s-goods-column class="goods-card" 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', {
 | 
			
		||||
              id: props.data.activityId,
 | 
			
		||||
            })
 | 
			
		||||
          "
 | 
			
		||||
        ></s-goods-column>
 | 
			
		||||
          "></s-goods-column>
 | 
			
		||||
			</view>
 | 
			
		||||
		</view>
 | 
			
		||||
		<!-- 样式2 一行一个 图片左 文案右 -->
 | 
			
		||||
		<view class="goods-box" v-if="layoutType === 'oneCol'">
 | 
			
		||||
      <view
 | 
			
		||||
        class="goods-list"
 | 
			
		||||
        v-for="(product, index) in productList"
 | 
			
		||||
        :key="index"
 | 
			
		||||
        :style="[{ marginBottom: space + 'px' }]"
 | 
			
		||||
      >
 | 
			
		||||
        <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="
 | 
			
		||||
			<view class="goods-list" v-for="(product, index) in productList" :key="index"
 | 
			
		||||
				:style="[{ marginBottom: space + 'px' }]">
 | 
			
		||||
				<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', {
 | 
			
		||||
              id: props.data.activityId,
 | 
			
		||||
            })
 | 
			
		||||
          "
 | 
			
		||||
        >
 | 
			
		||||
          ">
 | 
			
		||||
					<template v-slot:cart>
 | 
			
		||||
						<button class="ss-reset-button cart-btn" :style="[buyStyle]">
 | 
			
		||||
							{{ 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 SpuApi from "@/sheep/api/product/spu";
 | 
			
		||||
	import CombinationApi from "@/sheep/api/promotion/combination";
 | 
			
		||||
| 
						 | 
				
			
			@ -89,8 +65,16 @@
 | 
			
		|||
		},
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
  let { layoutType, tagStyle, btnBuy, space } = props.data;
 | 
			
		||||
  let { marginLeft, marginRight } = props.styles;
 | 
			
		||||
	let {
 | 
			
		||||
		layoutType,
 | 
			
		||||
		tagStyle,
 | 
			
		||||
		btnBuy,
 | 
			
		||||
		space
 | 
			
		||||
	} = props.data;
 | 
			
		||||
	let {
 | 
			
		||||
		marginLeft,
 | 
			
		||||
		marginRight
 | 
			
		||||
	} = props.styles;
 | 
			
		||||
 | 
			
		||||
	// 购买按钮样式
 | 
			
		||||
	const buyStyle = computed(() => {
 | 
			
		||||
| 
						 | 
				
			
			@ -114,8 +98,16 @@
 | 
			
		|||
	const productList = ref([]);
 | 
			
		||||
	onMounted(async () => {
 | 
			
		||||
		// todo:@owen 与Yudao结构不一致,待重构
 | 
			
		||||
    const { data: activity } = await CombinationApi.getCombinationActivity(props.data.activityId);
 | 
			
		||||
    const { data: spu } = await SpuApi.getSpuDetail(activity.spuId)
 | 
			
		||||
		const {
 | 
			
		||||
			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];
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -123,6 +115,7 @@
 | 
			
		|||
<style lang="scss" scoped>
 | 
			
		||||
	.goods-list {
 | 
			
		||||
		position: relative;
 | 
			
		||||
 | 
			
		||||
		.cart-btn {
 | 
			
		||||
			position: absolute;
 | 
			
		||||
			bottom: 10rpx;
 | 
			
		||||
| 
						 | 
				
			
			@ -136,14 +129,17 @@
 | 
			
		|||
			color: #fff;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	.goods-list {
 | 
			
		||||
		&:nth-last-of-type(1) {
 | 
			
		||||
			margin-bottom: 0 !important;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	.goods-sm-box {
 | 
			
		||||
		margin: 0 auto;
 | 
			
		||||
		box-sizing: border-box;
 | 
			
		||||
 | 
			
		||||
		.goods-card-box {
 | 
			
		||||
			flex-shrink: 0;
 | 
			
		||||
			overflow: hidden;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,62 +2,34 @@
 | 
			
		|||
<template>
 | 
			
		||||
	<view>
 | 
			
		||||
		<!-- 样式一:三列 - 上图下文 -->
 | 
			
		||||
    <view
 | 
			
		||||
      v-if="layoutType === 'threeCol'"
 | 
			
		||||
      class="goods-sm-box ss-flex ss-flex-wrap"
 | 
			
		||||
      :style="[{ margin: '-' + data.space + 'rpx' }]"
 | 
			
		||||
    >
 | 
			
		||||
      <view
 | 
			
		||||
        v-for="product in productList"
 | 
			
		||||
        :key="product.id"
 | 
			
		||||
        class="goods-card-box"
 | 
			
		||||
        :style="[
 | 
			
		||||
		<view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap"
 | 
			
		||||
			:style="[{ margin: '-' + data.space + 'rpx' }]">
 | 
			
		||||
			<view v-for="product in productList" :key="product.id" class="goods-card-box" :style="[
 | 
			
		||||
          {
 | 
			
		||||
            padding: data.space + 'rpx',
 | 
			
		||||
          },
 | 
			
		||||
        ]"
 | 
			
		||||
      >
 | 
			
		||||
        <s-goods-column
 | 
			
		||||
          class="goods-card"
 | 
			
		||||
          size="sm"
 | 
			
		||||
          :goodsFields="data.fields"
 | 
			
		||||
          :tagStyle="tagStyle"
 | 
			
		||||
          :data="product"
 | 
			
		||||
          :titleColor="data.fields.name?.color"
 | 
			
		||||
          :topRadius="data.borderRadiusTop"
 | 
			
		||||
          :bottomRadius="data.borderRadiusBottom"
 | 
			
		||||
          @click="
 | 
			
		||||
        ]">
 | 
			
		||||
				<s-goods-column class="goods-card" 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', {
 | 
			
		||||
              id: props.data.activityId,
 | 
			
		||||
            })
 | 
			
		||||
          "
 | 
			
		||||
        ></s-goods-column>
 | 
			
		||||
          "></s-goods-column>
 | 
			
		||||
			</view>
 | 
			
		||||
		</view>
 | 
			
		||||
		<!-- 样式二:一列 - 左图右文 -->
 | 
			
		||||
		<view class="goods-box" v-if="layoutType === 'oneCol'">
 | 
			
		||||
      <view
 | 
			
		||||
        class="goods-list"
 | 
			
		||||
        v-for="(product, index) in productList"
 | 
			
		||||
        :key="index"
 | 
			
		||||
        :style="[{ marginBottom: space + 'px' }]"
 | 
			
		||||
      >
 | 
			
		||||
        <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="
 | 
			
		||||
			<view class="goods-list" v-for="(product, index) in productList" :key="index"
 | 
			
		||||
				:style="[{ marginBottom: space + 'px' }]">
 | 
			
		||||
				<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', {
 | 
			
		||||
              id: props.data.activityId,
 | 
			
		||||
            })
 | 
			
		||||
          "
 | 
			
		||||
        >
 | 
			
		||||
          ">
 | 
			
		||||
					<template v-slot:cart>
 | 
			
		||||
						<button class="ss-reset-button cart-btn" :style="[buyStyle]">
 | 
			
		||||
							{{ btnBuy?.type === 'text' ? btnBuy.text : '' }}
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +47,11 @@
 | 
			
		|||
	 *
 | 
			
		||||
	 * @property {Array} list 商品列表
 | 
			
		||||
	 */
 | 
			
		||||
  import { computed, onMounted, ref } from 'vue';
 | 
			
		||||
	import {
 | 
			
		||||
		computed,
 | 
			
		||||
		onMounted,
 | 
			
		||||
		ref
 | 
			
		||||
	} from 'vue';
 | 
			
		||||
	import sheep from '@/sheep';
 | 
			
		||||
	import SeckillApi from "@/sheep/api/promotion/seckill";
 | 
			
		||||
	import SpuApi from "@/sheep/api/product/spu";
 | 
			
		||||
| 
						 | 
				
			
			@ -92,8 +68,16 @@
 | 
			
		|||
		},
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
  let { layoutType, tagStyle, btnBuy, space } = props.data;
 | 
			
		||||
  let { marginLeft, marginRight } = props.styles;
 | 
			
		||||
	let {
 | 
			
		||||
		layoutType,
 | 
			
		||||
		tagStyle,
 | 
			
		||||
		btnBuy,
 | 
			
		||||
		space
 | 
			
		||||
	} = props.data;
 | 
			
		||||
	let {
 | 
			
		||||
		marginLeft,
 | 
			
		||||
		marginRight
 | 
			
		||||
	} = props.styles;
 | 
			
		||||
 | 
			
		||||
	// 购买按钮样式
 | 
			
		||||
	const buyStyle = computed(() => {
 | 
			
		||||
| 
						 | 
				
			
			@ -118,8 +102,16 @@
 | 
			
		|||
	// 查询秒杀活动商品
 | 
			
		||||
	onMounted(async () => {
 | 
			
		||||
		// todo:@owen 与Yudao结构不一致,待重构
 | 
			
		||||
    const { data: activity } = await SeckillApi.getSeckillActivity(props.data.activityId);
 | 
			
		||||
    const { data: spu } = await SpuApi.getSpuDetail(activity.spuId)
 | 
			
		||||
		const {
 | 
			
		||||
			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];
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -131,9 +123,11 @@
 | 
			
		|||
 | 
			
		||||
	.goods-list {
 | 
			
		||||
		position: relative;
 | 
			
		||||
 | 
			
		||||
		&:nth-last-child(1) {
 | 
			
		||||
			margin-bottom: 0 !important;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		.cart-btn {
 | 
			
		||||
			position: absolute;
 | 
			
		||||
			bottom: 10rpx;
 | 
			
		||||
| 
						 | 
				
			
			@ -147,9 +141,11 @@
 | 
			
		|||
			color: #fff;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	.goods-sm-box {
 | 
			
		||||
		margin: 0 auto;
 | 
			
		||||
		box-sizing: border-box;
 | 
			
		||||
 | 
			
		||||
		.goods-card-box {
 | 
			
		||||
			flex-shrink: 0;
 | 
			
		||||
			overflow: hidden;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue