add
parent
8f9375911c
commit
9cf068a1bb
|
|
@ -146,7 +146,8 @@
|
|||
formatSales,
|
||||
formatGoodsSwiper,
|
||||
fen2yuan,
|
||||
handList
|
||||
handList,
|
||||
handListPrice
|
||||
} from '@/sheep/hooks/useGoods';
|
||||
import detailNavbar from './components/detail/detail-navbar.vue';
|
||||
import detailCellSku from './components/detail/detail-cell-sku.vue';
|
||||
|
|
@ -185,7 +186,14 @@
|
|||
|
||||
// 规格变更
|
||||
function onSkuChange(e) {
|
||||
console.log('传来的规格改变',e)
|
||||
if(e.type == 4){
|
||||
settleData.value = e
|
||||
setShow.value = true
|
||||
}else{
|
||||
state.selectedSku = e;
|
||||
setShow.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 添加购物车
|
||||
|
|
@ -271,21 +279,23 @@
|
|||
async function getSettlementByIds(ids) {
|
||||
const { data } = await SpuApi.getSettlementProduct(ids);
|
||||
settleData.value = handle(data)
|
||||
console.log('结算信息',data)
|
||||
console.log('处理后数据',settleData.value)
|
||||
state.goodsInfo.skus = handListPrice(state.goodsInfo.skus,data[0].skus)
|
||||
console.log('要传递的数据',state.goodsInfo)
|
||||
}
|
||||
//判断是否有限时折扣信息
|
||||
function handle(array){
|
||||
let setList = {}
|
||||
array.forEach(item => {
|
||||
item.skus.forEach(items => {
|
||||
if(items.type == 4){
|
||||
setShow.value = true
|
||||
setList = items
|
||||
return;
|
||||
array.some(item => {
|
||||
return item.skus.some(items => {
|
||||
if (items.type === 4) {
|
||||
setShow.value = true;
|
||||
setList = items;
|
||||
return true; // 返回true以结束some循环
|
||||
}
|
||||
})
|
||||
})
|
||||
return false; // 继续遍历
|
||||
});
|
||||
});
|
||||
// 将库存信息加入
|
||||
state.goodsInfo.skus.forEach(item =>{
|
||||
if(item.id == setList.skuId){
|
||||
|
|
|
|||
|
|
@ -121,8 +121,7 @@
|
|||
v-if="state.orderInfo.price.discountPrice > 0"
|
||||
>
|
||||
<view class="item-title">活动优惠</view>
|
||||
<view class="ss-flex ss-col-center">
|
||||
<!-- @tap="state.showDiscount = true" TODO 芋艿:后续要把优惠信息打进去 -->
|
||||
<view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
||||
<text class="item-value text-red">
|
||||
-¥{{ fen2yuan(state.orderInfo.price.discountPrice) }}
|
||||
</text>
|
||||
|
|
|
|||
|
|
@ -5,15 +5,61 @@
|
|||
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view>
|
||||
<view class="titleLi">促销</view>
|
||||
<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="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(item)">
|
||||
<view class="model-content-tag ss-flex ss-row-center">{{item.typeName}}</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" v-for="rule in state.activityMap[item.id]?.rules" :key="rule">
|
||||
{{ formatRewardActivityRule(state.activityMap[item.id], rule) }}
|
||||
<view class="contBu">
|
||||
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.reduc"
|
||||
:key="index">满{{fen2yuan(item.discountPrice)}}元减{{fen2yuan(item.limit)}}元;</text>
|
||||
</view>
|
||||
<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>
|
||||
<text class="cicon-forward" />
|
||||
|
|
@ -61,9 +107,9 @@
|
|||
} from 'vue';
|
||||
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
|
||||
import {
|
||||
formatRewardActivityRule,
|
||||
fen2yuan,
|
||||
formatDateRange
|
||||
formatDateRange,
|
||||
handActitList
|
||||
} from '@/sheep/hooks/useGoods';
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
|
|
@ -92,7 +138,8 @@
|
|||
if (res.code !== 0) {
|
||||
return;
|
||||
}
|
||||
state.activityMap[activity.id] = res.data;
|
||||
state.activityMap[activity.id] = handActitList(res.data.rules);
|
||||
console.log('最终数据', state)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,12 @@
|
|||
<template>
|
||||
<su-popup
|
||||
:show="show"
|
||||
type="bottom"
|
||||
round="20"
|
||||
@close="emits('close')"
|
||||
showClose
|
||||
backgroundColor="#f2f2f2"
|
||||
>
|
||||
<su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose backgroundColor="#f2f2f2">
|
||||
<view class="model-box">
|
||||
<view class="title ss-m-t-38 ss-m-l-20 ss-m-b-40">活动优惠</view>
|
||||
<scroll-view
|
||||
class="model-content ss-m-l-20"
|
||||
scroll-y
|
||||
:scroll-with-animation="false"
|
||||
:enable-back-to-top="true"
|
||||
>
|
||||
<view v-for="(item, index) in state.orderInfo.promo_infos" :key="index">
|
||||
<scroll-view class="model-content ss-m-l-20" scroll-y :scroll-with-animation="false"
|
||||
:enable-back-to-top="true">
|
||||
<view v-for="(item, index) in state.orderInfo.promotions" :key="index">
|
||||
<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'">
|
||||
满{{ item.discount_rule.full }}打{{ item.discount_rule.discount }}折,已减
|
||||
</view>
|
||||
|
|
@ -25,15 +14,11 @@
|
|||
<view v-if="item.activity_type === 'full_reduce'">
|
||||
满{{ item.discount_rule.full }}减{{ item.discount_rule.discount }},已减
|
||||
</view>
|
||||
<view class="price-text">¥{{ item.promo_discount_money || '0.00' }}</view>
|
||||
</view>
|
||||
<scroll-view class="scroll-box" scroll-x scroll-anchoring>
|
||||
<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 class="price-text">¥{{ item.promo_discount_money || '0.00' }}</view> -->
|
||||
<view>
|
||||
{{item.description}}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
|
@ -43,8 +28,14 @@
|
|||
</su-popup>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, reactive } from 'vue';
|
||||
import {
|
||||
computed,
|
||||
reactive
|
||||
} from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
import {
|
||||
fen2yuan
|
||||
} from '@/sheep/hooks/useGoods';
|
||||
const props = defineProps({
|
||||
promoInfo: {
|
||||
type: Array,
|
||||
|
|
@ -76,19 +67,23 @@
|
|||
});
|
||||
return goodsImg;
|
||||
};
|
||||
console.log('shuju', props)
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.model-box {
|
||||
height: 60vh;
|
||||
}
|
||||
|
||||
.model-content {
|
||||
height: 54vh;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
width: 100%;
|
||||
height: 120rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
width: 710rpx;
|
||||
margin-left: 20rpx;
|
||||
|
|
@ -97,17 +92,20 @@
|
|||
border-radius: 40rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.content-img {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.price-text {
|
||||
color: #ff3000;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
<view class="ss-flex">
|
||||
<view class="price-text">
|
||||
{{ 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 class="stock-text ss-m-l-20">
|
||||
|
|
@ -96,6 +98,7 @@
|
|||
() => state.selectedSku,
|
||||
(newVal) => {
|
||||
emits('change', newVal);
|
||||
console.log('选中的sku信息',state.selectedSku)
|
||||
}, {
|
||||
immediate: 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>
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
import { ref } from 'vue';
|
||||
import {
|
||||
ref
|
||||
} from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
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 type = isVideo ? 'video' : 'image'
|
||||
const src = $url.cdn(url);
|
||||
return { type, src }
|
||||
return {
|
||||
type,
|
||||
src
|
||||
}
|
||||
}) || [];
|
||||
}
|
||||
|
||||
|
|
@ -94,9 +101,9 @@ export function formatOrderColor(order) {
|
|||
if (order.status === 0) {
|
||||
return 'info-color';
|
||||
}
|
||||
if (order.status === 10
|
||||
|| order.status === 20
|
||||
|| (order.status === 30 && !order.commentStatus)) {
|
||||
if (order.status === 10 ||
|
||||
order.status === 20 ||
|
||||
(order.status === 30 && !order.commentStatus)) {
|
||||
return 'warning-color';
|
||||
}
|
||||
if (order.status === 30 && order.commentStatus) {
|
||||
|
|
@ -429,3 +436,50 @@ export function handList(orders) {
|
|||
});
|
||||
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