!82 【功能修复】修复拼团详情页的价格

Merge pull request !82 from 卢越/master
pull/83/MERGE
芋道源码 2024-08-18 05:32:29 +00:00 committed by Gitee
commit 28faf73c62
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 109 additions and 65 deletions

View File

@ -80,7 +80,7 @@
<!-- 功能卡片 --> <!-- 功能卡片 -->
<view class="detail-cell-card detail-card ss-flex-col"> <view class="detail-cell-card detail-card ss-flex-col">
<!-- 规格 --> <!-- 规格 -->
<detail-cell-sku :sku="state.selectedSkuPrice" @tap="state.showSelectSku = true" /> <detail-cell-sku :sku="state.selectedSku" @tap="state.showSelectSku = true" />
</view> </view>
<!-- 参团列表 --> <!-- 参团列表 -->
@ -90,6 +90,7 @@
<s-select-groupon-sku <s-select-groupon-sku
:show="state.showSelectSku" :show="state.showSelectSku"
:goodsInfo="state.goodsInfo" :goodsInfo="state.goodsInfo"
:selectedSku="state.selectedSku"
:grouponAction="state.grouponAction" :grouponAction="state.grouponAction"
:grouponNum="state.grouponNum" :grouponNum="state.grouponNum"
@buy="onBuy" @buy="onBuy"
@ -125,7 +126,7 @@
:disabled="state.goodsInfo.stock === 0 || state.activity.status !== 0" :disabled="state.goodsInfo.stock === 0 || state.activity.status !== 0"
> >
<view class="btn-price">{{ <view class="btn-price">{{
fen2yuan(state.activity.price || state.goodsInfo.price) fen2yuan(state.selectedSku.price * state.selectedSku.count || state.activity.price * state.selectedSku.count || state.goodsInfo.price * state.selectedSku.count || state.goodsInfo.price)
}}</view> }}</view>
<view v-if="state.activity.startTime > new Date().getTime()"></view> <view v-if="state.activity.startTime > new Date().getTime()"></view>
<view v-else-if="state.activity.endTime <= new Date().getTime()">已结束</view> <view v-else-if="state.activity.endTime <= new Date().getTime()">已结束</view>
@ -168,7 +169,7 @@
goodsInfo: {}, // goodsInfo: {}, //
goodsSwiper: [], // goodsSwiper: [], //
showSelectSku: false, // showSelectSku: false, //
selectedSkuPrice: {}, // selectedSku: {}, //
activity: {}, // activity: {}, //
grouponId: 0, // ID grouponId: 0, // ID
grouponNum: 0, // grouponNum: 0, //
@ -183,7 +184,7 @@
// //
function onSkuChange(e) { function onSkuChange(e) {
state.selectedSkuPrice = e; state.selectedSku = e;
} }
function onSkuClose() { function onSkuClose() {

View File

@ -1,37 +1,38 @@
<!-- 装修组件 - 拼团 --> <!-- 装修组件 - 拼团 -->
<template> <template>
<view> <view>
<view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap" <view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap" :style="[{ margin: '-' + data.space + 'rpx' }]">
:style="[{ margin: '-' + data.space + 'rpx' }]"> <view v-for="product in productList" class="goods-card-box" :key="product.id" :style="[{padding: data.space + 'rpx',},]">
<view v-for="product in productList" :key="product.id" class="goods-card-box" :style="[ <s-goods-column
{ class="goods-card"
padding: data.space + 'rpx', size="sm"
}, :goodsFields="goodsFields"
]"> :tagStyle="badge"
<s-goods-column class="goods-card" size="sm" :goodsFields="data.fields" :tagStyle="tagStyle" :data="product"
:data="product" :titleColor="data.fields.name?.color" :topRadius="data.borderRadiusTop" :titleColor="data.fields.name?.color"
:bottomRadius="data.borderRadiusBottom" @click=" :topRadius="data.borderRadiusTop"
sheep.$router.go('/pages/goods/groupon', { :bottomRadius="data.borderRadiusBottom"
id: props.data.activityId, @click="sheep.$router.go('/pages/goods/groupon', { 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 class="goods-list" v-for="(product, index) in productList" :key="index" :style="[{ marginBottom: space + 'px' }]">
:style="[{ marginBottom: space + 'px' }]"> <s-goods-column
<s-goods-column class="goods-card" size="lg" :goodsFields="data.fields" :tagStyle="tagStyle" class="goods-card" size="lg"
:data="product" :titleColor="data.fields.name?.color" :grouponTag="true"
:subTitleColor="data.fields.introduction?.color" :topRadius="data.borderRadiusTop" :goodsFields="goodsFields"
:bottomRadius="data.borderRadiusBottom" @click=" :tagStyle="badge"
sheep.$router.go('/pages/goods/groupon', { :data="product"
id: props.data.activityId, :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> <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>
@ -47,6 +48,7 @@
import { import {
computed, computed,
onMounted, onMounted,
reactive,
ref ref
} from 'vue'; } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
@ -55,28 +57,46 @@
// //
const props = defineProps({ const props = defineProps({
//
data: { data: {
type: Object, type: Object,
default () {}, default: () => ({}),
}, },
//
styles: { styles: {
type: Object, type: Object,
default () {}, default: () => ({}),
}, },
}); });
//
const goodsFields = reactive({
//
price: { show: true },
//
stock: { show: true },
//
name: { show: true },
//
introduction: { show: true },
//
marketPrice: { show: true },
//
salesCount: { show: true },
});
let { let {
layoutType, layoutType,
tagStyle, badge,
btnBuy, btnBuy,
space space,
} = props.data; } = props.data;
let { let {
marginLeft, marginLeft,
marginRight marginRight
} = props.styles; } = 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') {
@ -106,7 +126,7 @@
} = await SpuApi.getSpuDetail(activity.spuId) } = await SpuApi.getSpuDetail(activity.spuId)
// //
activity.products.forEach((product) => { activity.products.forEach((product) => {
spu.price = Math.min(spu.price, product.combinationPrice); // SPU spu.price = Math.min(spu.price, product.combinationPrice); // SPU
}); });
productList.value = [spu]; productList.value = [spu];
}); });
@ -127,6 +147,7 @@
border-radius: 25rpx; border-radius: 25rpx;
font-size: 24rpx; font-size: 24rpx;
color: #fff; color: #fff;
background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
} }
} }

View File

@ -2,37 +2,39 @@
<template> <template>
<view> <view>
<!-- 样式一三列 - 上图下文 --> <!-- 样式一三列 - 上图下文 -->
<view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap" <view v-if="layoutType === 'threeCol'" class="goods-sm-box ss-flex ss-flex-wrap" :style="[{ margin: '-' + data.space + 'rpx' }]">
:style="[{ margin: '-' + data.space + 'rpx' }]"> <view v-for="product in productList" :key="product.id" class="goods-card-box" :style="[{padding: data.space + 'rpx',},]">
<view v-for="product in productList" :key="product.id" class="goods-card-box" :style="[ <s-goods-column
{ class="goods-card" size="sm"
padding: data.space + 'rpx', :goodsFields="goodsFields"
}, :tagStyle="badge"
]"> :data="product"
<s-goods-column class="goods-card" size="sm" :goodsFields="data.fields" :tagStyle="tagStyle" :titleColor="data.fields.name?.color"
:data="product" :titleColor="data.fields.name?.color" :topRadius="data.borderRadiusTop" :topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom" @click=" :bottomRadius="data.borderRadiusBottom"
sheep.$router.go('/pages/goods/seckill', { @click="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 class="goods-list" v-for="(product, index) in productList" :key="index"
:style="[{ marginBottom: space + 'px' }]"> :style="[{ marginBottom: space + 'px' }]">
<s-goods-column class="goods-card" size="lg" :goodsFields="data.fields" :tagStyle="tagStyle" <s-goods-column
:data="product" :titleColor="data.fields.name?.color" class="goods-card"
:subTitleColor="data.fields.introduction?.color" :topRadius="data.borderRadiusTop" size="lg"
:bottomRadius="data.borderRadiusBottom" @click=" :goodsFields="goodsFields"
sheep.$router.go('/pages/goods/seckill', { :seckillTag="true"
id: props.data.activityId, :tagStyle="badge"
}) :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> <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>
@ -50,6 +52,7 @@
import { import {
computed, computed,
onMounted, onMounted,
reactive,
ref ref
} from 'vue'; } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
@ -58,21 +61,39 @@
// //
const props = defineProps({ const props = defineProps({
//
data: { data: {
type: Object, type: Object,
default () {}, default: () => ({}),
}, },
//
styles: { styles: {
type: Object, type: Object,
default () {}, default: () => ({}),
}, },
}); });
//
const goodsFields = reactive({
//
price: { show: true },
//
stock: { show: true },
//
name: { show: true },
//
introduction: { show: true },
//
marketPrice: { show: true },
//
salesCount: { show: true },
});
let { let {
layoutType, layoutType,
tagStyle, badge,
btnBuy, btnBuy,
space space,
} = props.data; } = props.data;
let { let {
marginLeft, marginLeft,
@ -139,6 +160,7 @@
border-radius: 25rpx; border-radius: 25rpx;
font-size: 24rpx; font-size: 24rpx;
color: #fff; color: #fff;
background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
} }
} }

View File

@ -22,7 +22,7 @@
</view> </view>
</view> </view>
<view class="header-right-bottom ss-flex ss-col-center ss-row-between"> <view class="header-right-bottom ss-flex ss-col-center ss-row-between">
<view class="price-text"> {{ fen2yuan(goodsInfo.price) }}</view> <view class="price-text"> {{ fen2yuan(state.selectedSku.price || goodsInfo.price || state.selectedSku.marketPrice) }}</view>
<view class="stock-text ss-m-l-20"> <view class="stock-text ss-m-l-20">
库存{{ state.selectedSku.stock || goodsInfo.stock }} 库存{{ state.selectedSku.stock || goodsInfo.stock }}
@ -63,7 +63,7 @@
<view class="btn-title">{{ grouponNum + '人团' }}</view> <view class="btn-title">{{ grouponNum + '人团' }}</view>
</button> </button>
<button class="ss-reset-button btn-tox ss-flex-col" @tap="onBuy"> <button class="ss-reset-button btn-tox ss-flex-col" @tap="onBuy">
<view class="btn-price">{{ fen2yuan(goodsInfo.price) }}</view> <view class="btn-price">{{ fen2yuan(state.selectedSku.price * state.selectedSku.count || goodsInfo.price * state.selectedSku.count || state.selectedSku.marketPrice * state.selectedSku.count || goodsInfo.price) }}</view>
<view v-if="grouponAction === 'create'"></view> <view v-if="grouponAction === 'create'"></view>
<view v-else-if="grouponAction === 'join'">参与拼团</view> <view v-else-if="grouponAction === 'join'">参与拼团</view>
</button> </button>