add
parent
8f9375911c
commit
9cf068a1bb
|
|
@ -146,7 +146,8 @@
|
||||||
formatSales,
|
formatSales,
|
||||||
formatGoodsSwiper,
|
formatGoodsSwiper,
|
||||||
fen2yuan,
|
fen2yuan,
|
||||||
handList
|
handList,
|
||||||
|
handListPrice
|
||||||
} from '@/sheep/hooks/useGoods';
|
} from '@/sheep/hooks/useGoods';
|
||||||
import detailNavbar from './components/detail/detail-navbar.vue';
|
import detailNavbar from './components/detail/detail-navbar.vue';
|
||||||
import detailCellSku from './components/detail/detail-cell-sku.vue';
|
import detailCellSku from './components/detail/detail-cell-sku.vue';
|
||||||
|
|
@ -185,7 +186,14 @@
|
||||||
|
|
||||||
// 规格变更
|
// 规格变更
|
||||||
function onSkuChange(e) {
|
function onSkuChange(e) {
|
||||||
|
console.log('传来的规格改变',e)
|
||||||
|
if(e.type == 4){
|
||||||
|
settleData.value = e
|
||||||
|
setShow.value = true
|
||||||
|
}else{
|
||||||
state.selectedSku = e;
|
state.selectedSku = e;
|
||||||
|
setShow.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加购物车
|
// 添加购物车
|
||||||
|
|
@ -271,21 +279,23 @@
|
||||||
async function getSettlementByIds(ids) {
|
async function getSettlementByIds(ids) {
|
||||||
const { data } = await SpuApi.getSettlementProduct(ids);
|
const { data } = await SpuApi.getSettlementProduct(ids);
|
||||||
settleData.value = handle(data)
|
settleData.value = handle(data)
|
||||||
console.log('结算信息',data)
|
|
||||||
console.log('处理后数据',settleData.value)
|
console.log('处理后数据',settleData.value)
|
||||||
|
state.goodsInfo.skus = handListPrice(state.goodsInfo.skus,data[0].skus)
|
||||||
|
console.log('要传递的数据',state.goodsInfo)
|
||||||
}
|
}
|
||||||
//判断是否有限时折扣信息
|
//判断是否有限时折扣信息
|
||||||
function handle(array){
|
function handle(array){
|
||||||
let setList = {}
|
let setList = {}
|
||||||
array.forEach(item => {
|
array.some(item => {
|
||||||
item.skus.forEach(items => {
|
return item.skus.some(items => {
|
||||||
if(items.type == 4){
|
if (items.type === 4) {
|
||||||
setShow.value = true
|
setShow.value = true;
|
||||||
setList = items
|
setList = items;
|
||||||
return;
|
return true; // 返回true以结束some循环
|
||||||
}
|
}
|
||||||
})
|
return false; // 继续遍历
|
||||||
})
|
});
|
||||||
|
});
|
||||||
// 将库存信息加入
|
// 将库存信息加入
|
||||||
state.goodsInfo.skus.forEach(item =>{
|
state.goodsInfo.skus.forEach(item =>{
|
||||||
if(item.id == setList.skuId){
|
if(item.id == setList.skuId){
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,7 @@
|
||||||
v-if="state.orderInfo.price.discountPrice > 0"
|
v-if="state.orderInfo.price.discountPrice > 0"
|
||||||
>
|
>
|
||||||
<view class="item-title">活动优惠</view>
|
<view class="item-title">活动优惠</view>
|
||||||
<view class="ss-flex ss-col-center">
|
<view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
||||||
<!-- @tap="state.showDiscount = true" TODO 芋艿:后续要把优惠信息打进去 -->
|
|
||||||
<text class="item-value text-red">
|
<text class="item-value text-red">
|
||||||
-¥{{ fen2yuan(state.orderInfo.price.discountPrice) }}
|
-¥{{ fen2yuan(state.orderInfo.price.discountPrice) }}
|
||||||
</text>
|
</text>
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,61 @@
|
||||||
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view>
|
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view>
|
||||||
<view class="titleLi">促销</view>
|
<view class="titleLi">促销</view>
|
||||||
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
|
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
|
||||||
<view class="actBox" v-for="item in state.activityInfo" :key="item.id">
|
<view class="actBox">
|
||||||
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(item)">
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
<view class="model-content-tag ss-flex ss-row-center">{{item.typeName}}</view>
|
<view class="model-content-tag ss-flex ss-row-center">满减</view>
|
||||||
<view class="model-content-title">
|
<view class="model-content-title">
|
||||||
<view class="contBu" v-for="rule in state.activityMap[item.id]?.rules" :key="rule">
|
<view class="contBu">
|
||||||
{{ formatRewardActivityRule(state.activityMap[item.id], rule) }}
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.reduc"
|
||||||
|
:key="index">满{{fen2yuan(item.discountPrice)}}元减{{fen2yuan(item.limit)}}元;</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="ss-m-b-24 cotBu-txt">
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
{{formatDateRange(item.startTime,item.endTime)}}
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="cicon-forward" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="actBox">
|
||||||
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
|
<view class="model-content-tag ss-flex ss-row-center">包邮</view>
|
||||||
|
<view class="model-content-title">
|
||||||
|
<view class="contBu">
|
||||||
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.ship"
|
||||||
|
:key="index" v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元包邮;</text>
|
||||||
|
</view>
|
||||||
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="cicon-forward" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="actBox">
|
||||||
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
|
<view class="model-content-tag ss-flex ss-row-center">送积分</view>
|
||||||
|
<view class="model-content-title">
|
||||||
|
<view class="contBu">
|
||||||
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.scor"
|
||||||
|
:key="index" v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元送{{item.value}}积分;</text>
|
||||||
|
</view>
|
||||||
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="cicon-forward" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="actBox">
|
||||||
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
|
<view class="model-content-tag ss-flex ss-row-center">送优惠券</view>
|
||||||
|
<view class="model-content-title">
|
||||||
|
<view class="contBu">
|
||||||
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.cou"
|
||||||
|
:key="index" v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元送{{item.value}}张优惠券;</text>
|
||||||
|
</view>
|
||||||
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="cicon-forward" />
|
<text class="cicon-forward" />
|
||||||
|
|
@ -61,9 +107,9 @@
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
|
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
|
||||||
import {
|
import {
|
||||||
formatRewardActivityRule,
|
|
||||||
fen2yuan,
|
fen2yuan,
|
||||||
formatDateRange
|
formatDateRange,
|
||||||
|
handActitList
|
||||||
} from '@/sheep/hooks/useGoods';
|
} from '@/sheep/hooks/useGoods';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
|
@ -92,7 +138,8 @@
|
||||||
if (res.code !== 0) {
|
if (res.code !== 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.activityMap[activity.id] = res.data;
|
state.activityMap[activity.id] = handActitList(res.data.rules);
|
||||||
|
console.log('最终数据', state)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<su-popup
|
<su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose backgroundColor="#f2f2f2">
|
||||||
:show="show"
|
|
||||||
type="bottom"
|
|
||||||
round="20"
|
|
||||||
@close="emits('close')"
|
|
||||||
showClose
|
|
||||||
backgroundColor="#f2f2f2"
|
|
||||||
>
|
|
||||||
<view class="model-box">
|
<view class="model-box">
|
||||||
<view class="title ss-m-t-38 ss-m-l-20 ss-m-b-40">活动优惠</view>
|
<view class="title ss-m-t-38 ss-m-l-20 ss-m-b-40">活动优惠</view>
|
||||||
<scroll-view
|
<scroll-view class="model-content ss-m-l-20" scroll-y :scroll-with-animation="false"
|
||||||
class="model-content ss-m-l-20"
|
:enable-back-to-top="true">
|
||||||
scroll-y
|
<view v-for="(item, index) in state.orderInfo.promotions" :key="index">
|
||||||
:scroll-with-animation="false"
|
|
||||||
:enable-back-to-top="true"
|
|
||||||
>
|
|
||||||
<view v-for="(item, index) in state.orderInfo.promo_infos" :key="index">
|
|
||||||
<view class="ss-flex ss-m-b-40 subtitle">
|
<view class="ss-flex ss-m-b-40 subtitle">
|
||||||
<view>共{{ item.goods_ids.length }}件,</view>
|
<!-- <view>共{{ item.goods_ids.length }}件,</view>
|
||||||
<view v-if="item.activity_type === 'full_discount'">
|
<view v-if="item.activity_type === 'full_discount'">
|
||||||
满{{ item.discount_rule.full }}打{{ item.discount_rule.discount }}折,已减
|
满{{ item.discount_rule.full }}打{{ item.discount_rule.discount }}折,已减
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -25,15 +14,11 @@
|
||||||
<view v-if="item.activity_type === 'full_reduce'">
|
<view v-if="item.activity_type === 'full_reduce'">
|
||||||
满{{ item.discount_rule.full }}减{{ item.discount_rule.discount }},已减
|
满{{ item.discount_rule.full }}减{{ item.discount_rule.discount }},已减
|
||||||
</view>
|
</view>
|
||||||
<view class="price-text">¥{{ item.promo_discount_money || '0.00' }}</view>
|
<view class="price-text">¥{{ item.promo_discount_money || '0.00' }}</view> -->
|
||||||
</view>
|
<view>
|
||||||
<scroll-view class="scroll-box" scroll-x scroll-anchoring>
|
{{item.description}}
|
||||||
<view class="ss-flex">
|
|
||||||
<view v-for="i in item.goods_ids" :key="i">
|
|
||||||
<image class="content-img" :src="sheep.$url.cdn(getGoodsImg(i))" />
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -43,8 +28,14 @@
|
||||||
</su-popup>
|
</su-popup>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
reactive
|
||||||
|
} from 'vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
|
import {
|
||||||
|
fen2yuan
|
||||||
|
} from '@/sheep/hooks/useGoods';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
promoInfo: {
|
promoInfo: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|
@ -56,7 +47,7 @@
|
||||||
},
|
},
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {},
|
default () {},
|
||||||
},
|
},
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
@ -76,19 +67,23 @@
|
||||||
});
|
});
|
||||||
return goodsImg;
|
return goodsImg;
|
||||||
};
|
};
|
||||||
|
console.log('shuju', props)
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.model-box {
|
.model-box {
|
||||||
height: 60vh;
|
height: 60vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.model-content {
|
.model-content {
|
||||||
height: 54vh;
|
height: 54vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-footer {
|
.modal-footer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 120rpx;
|
height: 120rpx;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.confirm-btn {
|
.confirm-btn {
|
||||||
width: 710rpx;
|
width: 710rpx;
|
||||||
margin-left: 20rpx;
|
margin-left: 20rpx;
|
||||||
|
|
@ -97,17 +92,20 @@
|
||||||
border-radius: 40rpx;
|
border-radius: 40rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-img {
|
.content-img {
|
||||||
width: 140rpx;
|
width: 140rpx;
|
||||||
height: 140rpx;
|
height: 140rpx;
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.price-text {
|
.price-text {
|
||||||
color: #ff3000;
|
color: #ff3000;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
<view class="ss-flex">
|
<view class="ss-flex">
|
||||||
<view class="price-text">
|
<view class="price-text">
|
||||||
{{ fen2yuan( state.selectedSku.price || goodsInfo.price) }}
|
{{ fen2yuan( state.selectedSku.price || goodsInfo.price) }}
|
||||||
|
<text class="iconBox" v-if="state.selectedSku.type == 6">会员价</text>
|
||||||
|
<text class="iconBox" v-if="state.selectedSku.type == 4">限时优惠</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="stock-text ss-m-l-20">
|
<view class="stock-text ss-m-l-20">
|
||||||
|
|
@ -96,6 +98,7 @@
|
||||||
() => state.selectedSku,
|
() => state.selectedSku,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
emits('change', newVal);
|
emits('change', newVal);
|
||||||
|
console.log('选中的sku信息',state.selectedSku)
|
||||||
}, {
|
}, {
|
||||||
immediate: true, // 立即执行
|
immediate: true, // 立即执行
|
||||||
deep: true, // 深度监听
|
deep: true, // 深度监听
|
||||||
|
|
@ -403,4 +406,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.iconBox {
|
||||||
|
width: fit-content;
|
||||||
|
height: fit-content;
|
||||||
|
padding: 2rpx 10rpx;
|
||||||
|
background-color: rgb(255, 242, 241);
|
||||||
|
color: #ff2621;
|
||||||
|
font-size: 24rpx;
|
||||||
|
margin-left: 5rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
import { ref } from 'vue';
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import $url from '@/sheep/url';
|
import $url from '@/sheep/url';
|
||||||
import { formatDate } from '@/sheep/util';
|
import {
|
||||||
|
formatDate
|
||||||
|
} from '@/sheep/util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化销量
|
* 格式化销量
|
||||||
|
|
@ -80,7 +84,10 @@ export function formatGoodsSwiper(urlList) {
|
||||||
const isVideo = VIDEO_SUFFIX_LIST.some(suffix => url.includes(suffix));
|
const isVideo = VIDEO_SUFFIX_LIST.some(suffix => url.includes(suffix));
|
||||||
const type = isVideo ? 'video' : 'image'
|
const type = isVideo ? 'video' : 'image'
|
||||||
const src = $url.cdn(url);
|
const src = $url.cdn(url);
|
||||||
return { type, src }
|
return {
|
||||||
|
type,
|
||||||
|
src
|
||||||
|
}
|
||||||
}) || [];
|
}) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,9 +101,9 @@ export function formatOrderColor(order) {
|
||||||
if (order.status === 0) {
|
if (order.status === 0) {
|
||||||
return 'info-color';
|
return 'info-color';
|
||||||
}
|
}
|
||||||
if (order.status === 10
|
if (order.status === 10 ||
|
||||||
|| order.status === 20
|
order.status === 20 ||
|
||||||
|| (order.status === 30 && !order.commentStatus)) {
|
(order.status === 30 && !order.commentStatus)) {
|
||||||
return 'warning-color';
|
return 'warning-color';
|
||||||
}
|
}
|
||||||
if (order.status === 30 && order.commentStatus) {
|
if (order.status === 30 && order.commentStatus) {
|
||||||
|
|
@ -409,14 +416,14 @@ export function formatDateRange(startTimestamp, endTimestamp) {
|
||||||
//处理活动信息
|
//处理活动信息
|
||||||
export function handList(orders) {
|
export function handList(orders) {
|
||||||
const typeMap = {
|
const typeMap = {
|
||||||
'1':'秒杀活动',
|
'1': '秒杀活动',
|
||||||
'2':'砍价活动',
|
'2': '砍价活动',
|
||||||
'3':'拼团活动',
|
'3': '拼团活动',
|
||||||
'4':'限时折扣',
|
'4': '限时折扣',
|
||||||
'5':'满减送',
|
'5': '满减送',
|
||||||
'6':'会员折扣',
|
'6': '会员折扣',
|
||||||
'7':'优惠券',
|
'7': '优惠券',
|
||||||
'8':'积分'
|
'8': '积分'
|
||||||
};
|
};
|
||||||
|
|
||||||
// 给每个订单对象添加 typeName 属性
|
// 给每个订单对象添加 typeName 属性
|
||||||
|
|
@ -428,4 +435,51 @@ export function handList(orders) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return updatedOrders
|
return updatedOrders
|
||||||
|
};
|
||||||
|
//根据skuid来修改价格并添加时间
|
||||||
|
export function handListPrice(array,array2) {
|
||||||
|
// 将 array2 转换为一个以 skuId 为键的对象,以便于快速查找
|
||||||
|
const array2Map = array2.reduce((acc, item) => {
|
||||||
|
acc[item.skuId] = { price: item.price, type: item.type,endTime:item.endTime };
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
// 遍历 array 数组并更新 price 和 type
|
||||||
|
array.forEach(item => {
|
||||||
|
if (array2Map[item.id]) {
|
||||||
|
// 如果在 array2Map 中找到了对应的 skuId(即 id)
|
||||||
|
item.price = array2Map[item.id].price;
|
||||||
|
item.type = array2Map[item.id].type;
|
||||||
|
item.endTime = array2Map[item.id].endTime;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 返回更新后的 array
|
||||||
|
return array;
|
||||||
|
};
|
||||||
|
|
||||||
|
//处理活动数据
|
||||||
|
export function handActitList(rules) {
|
||||||
|
const rules2 = {
|
||||||
|
reduc: rules.map(item => ({
|
||||||
|
discountPrice: item.discountPrice,
|
||||||
|
limit: item.limit,
|
||||||
|
bull: true // 默认为 true
|
||||||
|
})),
|
||||||
|
cou: rules.map(item => ({
|
||||||
|
discountPrice: item.discountPrice,
|
||||||
|
value: item.couponCounts.reduce((acc, count) => acc + count, 0), // 计算 couponCounts 中各项之和
|
||||||
|
bull: item.givePoint // 对应 givePoint
|
||||||
|
})),
|
||||||
|
ship: rules.map(item => ({
|
||||||
|
discountPrice: item.discountPrice,
|
||||||
|
bull: item.freeDelivery // 对应 freeDelivery
|
||||||
|
})),
|
||||||
|
scor: rules.map(item => ({
|
||||||
|
discountPrice: item.discountPrice,
|
||||||
|
value: item.point, // 直接使用 point
|
||||||
|
bull: item.givePoint // 对应 givePoint
|
||||||
|
}))
|
||||||
};
|
};
|
||||||
|
return rules2
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue