差满减活动时间外

pull/100/head
岳琳红 2024-09-13 17:51:29 +08:00
parent d1eea3280c
commit 26a18e7e9a
13 changed files with 296 additions and 221 deletions

View File

@ -1,207 +1,315 @@
<!-- 指定满减送的活动列表 --> <!-- 指定满减送的活动列表 -->
<template> <template>
<s-layout class="activity-wrap" :title="state.activityInfo.title"> <s-layout class="activity-wrap" :title="state.activityInfo.title">
<!-- 活动信息 --> <!-- 活动信息 -->
<su-sticky bgColor="#fff"> <su-sticky bgColor="#fff">
<view class="ss-flex ss-col-top tip-box"> <view class="ss-flex ss-col-top tip-box">
<view class="type-text ss-flex ss-row-center">满减</view> <view class="type-text ss-flex ss-row-center">满减</view>
<view class="ss-flex-1"> <view class="ss-flex-1">
<view class="tip-content" v-for="item in state.activityInfo.rules" :key="item"> <view class="tip-content" v-for="item in state.activityInfo.rules" :key="item">
{{ formatRewardActivityRule(state.activityInfo, item) }} {{ formatRewardActivityRule(state.activityInfo, item) }}
</view> </view>
</view> </view>
<image class="activity-left-image" src="/static/activity-left.png" /> <image class="activity-left-image" src="/static/activity-left.png" />
<image class="activity-right-image" src="/static/activity-right.png" /> <image class="activity-right-image" src="/static/activity-right.png" />
</view> </view>
</su-sticky> </su-sticky>
<!-- 商品信息 --> <!-- 商品信息 -->
<view class="ss-flex ss-flex-wrap ss-p-x-20 ss-m-t-20 ss-col-top"> <view class="ss-flex ss-flex-wrap ss-p-x-20 ss-m-t-20 ss-col-top">
<view class="goods-list-box"> <view class="goods-list-box">
<view class="left-list" v-for="item in state.leftGoodsList" :key="item.id"> <view class="left-list" v-for="item in state.leftGoodsList" :key="item.id">
<s-goods-column <s-goods-column class="goods-md-box" size="md" :data="item"
class="goods-md-box" @click="sheep.$router.go('/pages/goods/index', { id: item.id })"
size="md" @getHeight="mountMasonry($event, 'left')">
:data="item" <template v-slot:cart>
@click="sheep.$router.go('/pages/goods/index', { id: item.id })" <button class="ss-reset-button cart-btn"> </button>
@getHeight="mountMasonry($event, 'left')" </template>
> </s-goods-column>
<template v-slot:cart> </view>
<button class="ss-reset-button cart-btn"> </button> </view>
</template> <view class="goods-list-box">
</s-goods-column> <view class="right-list" v-for="item in state.rightGoodsList" :key="item.id">
</view> <s-goods-column class="goods-md-box" size="md" :data="item"
</view> @click="sheep.$router.go('/pages/goods/index', { id: item.id })"
<view class="goods-list-box"> @getHeight="mountMasonry($event, 'right')">
<view class="right-list" v-for="item in state.rightGoodsList" :key="item.id"> <template v-slot:cart>
<s-goods-column <button class="ss-reset-button cart-btn" />
class="goods-md-box" </template>
size="md" </s-goods-column>
:data="item" </view>
@click="sheep.$router.go('/pages/goods/index', { id: item.id })" </view>
@getHeight="mountMasonry($event, 'right')" </view>
>
<template v-slot:cart>
<button class="ss-reset-button cart-btn" />
</template>
</s-goods-column>
</view>
</view>
</view>
<uni-load-more <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" }" @tap="loadMore" />
@tap="loadMore" </s-layout>
/>
</s-layout>
</template> </template>
<script setup> <script setup>
import { reactive } from 'vue'; import {
import { onLoad, onReachBottom } from '@dcloudio/uni-app'; reactive,
import sheep from '@/sheep'; toRaw,
import _ from 'lodash-es'; ref
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity'; } from 'vue';
import { formatRewardActivityRule } from '@/sheep/hooks/useGoods'; import {
import SpuApi from '@/sheep/api/product/spu'; onLoad,
onReachBottom
} from '@dcloudio/uni-app';
import sheep from '@/sheep';
import _ from 'lodash-es';
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
import {
formatRewardActivityRule
} from '@/sheep/hooks/useGoods';
import SpuApi from '@/sheep/api/product/spu';
const state = reactive({ const state = reactive({
activityId: 0, // activityId: 0, //
activityInfo: {}, // activityInfo: {}, //
pagination: { pagination: {
list: [], list: [],
total: 1, total: 1,
pageNo: 1, pageNo: 1,
pageSize: 8, pageSize: 8,
}, },
loadStatus: '', loadStatus: '',
leftGoodsList: [], leftGoodsList: [],
rightGoodsList: [], rightGoodsList: [],
}); });
// //
let count = 0; let count = 0;
let leftHeight = 0; let leftHeight = 0;
let rightHeight = 0; let rightHeight = 0;
function mountMasonry(height = 0, where = 'left') { function mountMasonry(height = 0, where = 'left') {
if (!state.pagination.list[count]) return; if (!state.pagination.list[count]) return;
if (where === 'left') { if (where === 'left') {
leftHeight += height; leftHeight += height;
} else { } else {
rightHeight += height; rightHeight += height;
} }
if (leftHeight <= rightHeight) { if (leftHeight <= rightHeight) {
state.leftGoodsList.push(state.pagination.list[count]); state.leftGoodsList.push(state.pagination.list[count]);
} else { } else {
state.rightGoodsList.push(state.pagination.list[count]); state.rightGoodsList.push(state.pagination.list[count]);
} }
count++; count++;
} }
// //
async function getList() { async function getList() {
// // state.loadStatus = 'loading';
const params = {}; //
if (state.activityInfo.productScope === 2) { const params = {}
params.ids = state.activityInfo.productSpuIds.join(','); if (state.activityInfo.productScope === 2) {
} else if (state.activityInfo.productScope === 3) { // const params = toRaw(state.activityInfo.productScopeValues)
params.categoryIds = state.activityInfo.productSpuIds.join(','); //
} const {
// code,
state.loadStatus = 'loading'; data
const { code, data } = await SpuApi.getSpuPage({ } = await SpuApi.getSpuListByIds(state.activityInfo.productScopeValues.join(','));
pageNo: state.pagination.pageNo, if (code !== 0) {
pageSize: state.pagination.pageSize, return;
...params, }
}); // 使 map id
if (code !== 0) { const ids = data.map(item => item.id);
return; // 使 join id
} const idsString = ids.join(',');
console.log('nibuhao ') //
state.pagination.list = _.concat(state.pagination.list, data.list); settleData.value = await getSettlementByIds(idsString)
state.pagination.total = data.total; //
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore'; const ms = enrichDataWithSkus(data, settleData.value)
mountMasonry(); state.pagination.list = ms;
} // state.pagination.total = data.total;
// state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
} else if (state.activityInfo.productScope === 3) {
params.categoryIds = state.activityInfo.productScopeValues.join(',');
state.loadStatus = 'loading';
const {
code,
data
} = await SpuApi.getSpuPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
...params,
});
if (code !== 0) {
return;
}
// 使 map id
const ids = data.list.map(item => item.id);
// 使 join id
const idsString = ids.join(',');
//
settleData.value = await getSettlementByIds(idsString)
//
const ms = enrichDataWithSkus(data.list, settleData.value)
state.pagination.list = _.concat(state.pagination.list, ms);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
} else {
state.loadStatus = 'loading';
const {
code,
data
} = await SpuApi.getSpuPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
});
if (code !== 0) {
return;
}
// 使 map id
const ids = data.list.map(item => item.id);
// 使 join id
const idsString = ids.join(',');
//
settleData.value = await getSettlementByIds(idsString)
//
const ms = enrichDataWithSkus(data.list, settleData.value)
state.pagination.list = _.concat(state.pagination.list, ms);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
mountMasonry();
}
//
const settleData = ref()
async function getSettlementByIds(ids) {
const {
data
} = await SpuApi.getSettlementProduct(ids);
return data;
}
//
function enrichDataWithSkus(data, array) {
// id data
const dataMap = new Map(data.map(item => [item.id, {
...item
}]));
// // array
async function getActivity(id) { array.forEach(item => {
const { code, data } = await RewardActivityApi.getRewardActivity(id); // discountPrice vipPrice null
if (code === 0) { let discountPrice = null;
state.activityInfo = data; let vipPrice = null;
} let foundType4 = false;
} let foundType6 = false;
// // skus type 4 6
function loadMore() { item.skus.forEach(sku => {
if (state.loadStatus === 'noMore') { if (!foundType4 && sku.type === 4) {
return; discountPrice = sku.price;
} foundType4 = true;
state.pagination.pageNo++; }
getList(); if (!foundType6 && sku.type === 6) {
} vipPrice = sku.price;
foundType6 = true;
}
// // type 4 6
onReachBottom(() => { if (foundType4 && foundType6) {
loadMore(); return;
}); }
});
onLoad(async (options) => { // dataMap
state.activityId = options.activityId; if (dataMap.has(item.id)) {
await getActivity(state.activityId); dataMap.get(item.id).discountPrice = discountPrice;
await getList(state.activityId); dataMap.get(item.id).vipPrice = vipPrice;
}); dataMap.get(item.id).reward = item.reward;
}
});
//
return Array.from(dataMap.values());
}
//
async function getActivity(id) {
const {
code,
data
} = await RewardActivityApi.getRewardActivity(id);
if (code === 0) {
state.activityInfo = data;
}
}
//
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getList();
}
//
onReachBottom(() => {
loadMore();
});
onLoad(async (options) => {
state.activityId = options.activityId;
await getActivity(state.activityId);
await getList();
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.goods-list-box { .goods-list-box {
width: 50%; width: 50%;
box-sizing: border-box; box-sizing: border-box;
.left-list {
margin-right: 10rpx; .left-list {
margin-bottom: 20rpx; margin-right: 10rpx;
} margin-bottom: 20rpx;
.right-list { }
margin-left: 10rpx;
margin-bottom: 20rpx; .right-list {
} margin-left: 10rpx;
} margin-bottom: 20rpx;
.tip-box { }
background: #fff0e7; }
padding: 20rpx;
width: 100%; .tip-box {
position: relative; background: #fff0e7;
box-sizing: border-box; padding: 20rpx;
.activity-left-image { width: 100%;
position: absolute; position: relative;
bottom: 0; box-sizing: border-box;
left: 0;
width: 58rpx; .activity-left-image {
height: 36rpx; position: absolute;
} bottom: 0;
.activity-right-image { left: 0;
position: absolute; width: 58rpx;
top: 0; height: 36rpx;
right: 0; }
width: 72rpx;
height: 50rpx; .activity-right-image {
} position: absolute;
.type-text { top: 0;
font-size: 26rpx; right: 0;
font-weight: 500; width: 72rpx;
color: #ff6000; height: 50rpx;
line-height: 42rpx; }
}
.tip-content { .type-text {
font-size: 26rpx; font-size: 26rpx;
font-weight: 500; font-weight: 500;
color: #ff6000; color: #ff6000;
line-height: 42rpx; line-height: 42rpx;
} }
}
</style> .tip-content {
font-size: 26rpx;
font-weight: 500;
color: #ff6000;
line-height: 42rpx;
}
}
</style>

View File

@ -149,7 +149,6 @@
const now = dayjs(); const now = dayjs();
const today = now.format('YYYY-MM-DD') const today = now.format('YYYY-MM-DD')
const select = ref([]) const select = ref([])
console.log('数据', data)
// //
data.forEach((config, index) => { data.forEach((config, index) => {
const startTime = dayjs(`${today} ${config.startTime}`) const startTime = dayjs(`${today} ${config.startTime}`)
@ -158,20 +157,16 @@
if (now.isBefore(startTime)) { if (now.isBefore(startTime)) {
config.status = TimeStatusEnum.WAIT_START; config.status = TimeStatusEnum.WAIT_START;
// select.value[index] = config.id; // select.value[index] = config.id;
console.log('未开始',select.value,activeTimeIndex.value)
} else if (now.isAfter(endTime)) { } else if (now.isAfter(endTime)) {
config.status = TimeStatusEnum.END; config.status = TimeStatusEnum.END;
// select.value[index] = config.id; // select.value[index] = config.id;
console.log('已结束',select.value,activeTimeIndex.value)
} else { } else {
config.status = TimeStatusEnum.STARTED; config.status = TimeStatusEnum.STARTED;
// select.value[index] = config.id; // select.value[index] = config.id;
activeTimeIndex.value = index activeTimeIndex.value = index
console.log('进行中',select.value,activeTimeIndex.value)
} }
}) })
timeConfigList.value = data timeConfigList.value = data
console.log('传递',select.value,activeTimeIndex.value)
// //
handleChangeTimeConfig(activeTimeIndex.value, select.value[activeTimeIndex.value]); handleChangeTimeConfig(activeTimeIndex.value, select.value[activeTimeIndex.value]);
// //
@ -188,7 +183,6 @@
const activeTimeIndex = ref(0) // const activeTimeIndex = ref(0) //
const activeTimeConfig = computed(() => timeConfigList.value[activeTimeIndex.value]) // const activeTimeConfig = computed(() => timeConfigList.value[activeTimeIndex.value]) //
const handleChangeTimeConfig = (index, id) => { const handleChangeTimeConfig = (index, id) => {
console.log('点击',index + '+' + id)
activeTimeIndex.value = index activeTimeIndex.value = index
// //

View File

@ -101,7 +101,6 @@
id: id id: id
}); });
bargainInfo.value = data bargainInfo.value = data
console.log('shuju', bargainInfo.value)
} }
// //
const recordPageParams = ref({ const recordPageParams = ref({
@ -119,7 +118,6 @@
bargainRecord.value = bargainRecord.value.concat(...data.list); bargainRecord.value = bargainRecord.value.concat(...data.list);
bargainRecordTotal.value = data.total; bargainRecordTotal.value = data.total;
loadStatus.value = bargainRecord.value.length < bargainRecordTotal.value ? 'more' : 'noMore'; loadStatus.value = bargainRecord.value.length < bargainRecordTotal.value ? 'more' : 'noMore';
console.log('jilu',data)
} }
// //
function loadMore() { function loadMore() {

View File

@ -76,7 +76,6 @@
} = await BargainApi.getActivitySuccess(); } = await BargainApi.getActivitySuccess();
bargainSuccessList.value = data.successList bargainSuccessList.value = data.successList
bargainTotal.value = data.successUserCount bargainTotal.value = data.successUserCount
console.log(bargainSuccessList.value)
} }
// //
const activityTotal = ref(0) // const activityTotal = ref(0) //
@ -94,7 +93,6 @@
activityList.value = activityList.value.concat(...data.list); activityList.value = activityList.value.concat(...data.list);
activityTotal.value = data.total; activityTotal.value = data.total;
loadStatus.value = activityList.value.length < activityTotal.value ? 'more' : 'noMore'; loadStatus.value = activityList.value.length < activityTotal.value ? 'more' : 'noMore';
// console.log('shuju',data)
} }
// //
function loadMore() { function loadMore() {

View File

@ -186,7 +186,6 @@
// //
function onSkuChange(e) { function onSkuChange(e) {
console.log('传来的规格改变',e)
if(e.type == 4){ if(e.type == 4){
settleData.value = e settleData.value = e
setShow.value = true setShow.value = true
@ -270,7 +269,6 @@
} = await CouponApi.getCouponTemplateList(state.goodsId, 2, 10); } = await CouponApi.getCouponTemplateList(state.goodsId, 2, 10);
if (code === 0) { if (code === 0) {
state.couponInfo = data; state.couponInfo = data;
console.log('优惠券',state)
} }
} }
// //
@ -279,9 +277,7 @@
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('处理后数据',settleData.value)
state.goodsInfo.skus = handListPrice(state.goodsInfo.skus,data[0].skus) state.goodsInfo.skus = handListPrice(state.goodsInfo.skus,data[0].skus)
console.log('要传递的数据',state.goodsInfo)
} }
// //
function handle(array){ function handle(array){
@ -322,7 +318,6 @@
// //
state.skeletonLoading = false; state.skeletonLoading = false;
state.goodsInfo = res.data; state.goodsInfo = res.data;
console.log('sku',res.data)
// //
if (isLogin.value) { if (isLogin.value) {
FavoriteApi.isFavoriteExists(state.goodsId, 'goods').then((res) => { FavoriteApi.isFavoriteExists(state.goodsId, 'goods').then((res) => {

View File

@ -277,7 +277,6 @@
if (code !== 0) { if (code !== 0) {
return; return;
} }
console.log('数据流',data)
// 使 map id // 使 map id
const ids = data.list.map(item => item.id); const ids = data.list.map(item => item.id);
// 使 join id // 使 join id
@ -304,7 +303,6 @@
const settleData = ref() const settleData = ref()
async function getSettlementByIds(ids) { async function getSettlementByIds(ids) {
const { data } = await SpuApi.getSettlementProduct(ids); const { data } = await SpuApi.getSettlementProduct(ids);
// console.log('',data)
return data; return data;
} }

View File

@ -212,7 +212,6 @@
} = await SeckillApi.getSeckillActivity(id); } = await SeckillApi.getSeckillActivity(id);
activity.value = data; activity.value = data;
timeStatusEnum.value = getTimeStatusEnum(activity.value.startTime, activity.value.endTime); timeStatusEnum.value = getTimeStatusEnum(activity.value.startTime, activity.value.endTime);
console.log('处理后',timeStatusEnum.value)
state.percent = 100 - data.stock / data.totalStock * 100; state.percent = 100 - data.stock / data.totalStock * 100;
// //
await getSpu(data.spuId); await getSpu(data.spuId);
@ -255,7 +254,6 @@
}); });
state.skeletonLoading = false; state.skeletonLoading = false;
console.log('shuju', state)
}; };
onLoad((options) => { onLoad((options) => {

View File

@ -307,7 +307,6 @@
state.orderPayload = JSON.parse(options.data); state.orderPayload = JSON.parse(options.data);
await getOrderInfo(); await getOrderInfo();
await getCoupons(); await getCoupons();
console.log('数据', state)
}); });
</script> </script>

View File

@ -131,7 +131,6 @@
activityMap: {}, activityMap: {},
couponInfo: computed(() => props.modelValue.couponInfo) couponInfo: computed(() => props.modelValue.couponInfo)
}); });
console.log('shuju', state)
watch( watch(
() => props.show, () => props.show,
() => { () => {
@ -143,7 +142,6 @@
return; return;
} }
state.activityMap[activity.id] = handActitList(res.data.rules); state.activityMap[activity.id] = handActitList(res.data.rules);
console.log('最终数据', state)
}) })
}); });
} }

View File

@ -67,7 +67,6 @@
}); });
return goodsImg; return goodsImg;
}; };
console.log('shuju', props)
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.model-box { .model-box {

View File

@ -202,8 +202,6 @@
*/ */
function calculateGoodsColumn(height = 0, where = 'left') { function calculateGoodsColumn(height = 0, where = 'left') {
// //
console.log('用来处理的数据',state.goodsList)
console.log(11111)
if (!state.goodsList[count]) return; if (!state.goodsList[count]) return;
// //
if (where === 'left') leftHeight += height; if (where === 'left') leftHeight += height;
@ -226,14 +224,12 @@
*/ */
async function getGoodsListByIds(ids) { async function getGoodsListByIds(ids) {
const { data } = await SpuApi.getSpuListByIds(ids); const { data } = await SpuApi.getSpuListByIds(ids);
// console.log('',data)
return data; return data;
} }
// //
const settleData = ref() const settleData = ref()
async function getSettlementByIds(ids) { async function getSettlementByIds(ids) {
const { data } = await SpuApi.getSettlementProduct(ids); const { data } = await SpuApi.getSettlementProduct(ids);
// console.log('',data)
return data; return data;
} }
@ -284,11 +280,9 @@
const ms = await getGoodsListByIds(spuIds.join(',')); const ms = await getGoodsListByIds(spuIds.join(','));
settleData.value = await getSettlementByIds(spuIds.join(',')) settleData.value = await getSettlementByIds(spuIds.join(','))
state.goodsList = await enrichDataWithSkus(ms,settleData.value) state.goodsList = await enrichDataWithSkus(ms,settleData.value)
// console.log('',state.goodsList)
// //
if (layoutType === LayoutTypeEnum.TWO_COL){ if (layoutType === LayoutTypeEnum.TWO_COL){
// //
console.log('用来分流的数据',state.goodsList)
calculateGoodsColumn(); calculateGoodsColumn();
} }
}); });

View File

@ -397,7 +397,6 @@
const iconShow = handle() const iconShow = handle()
function handle() { function handle() {
console.log('传来的数据',props.data)
if (props.data.discountPrice === null && props.data.vipPrice === null) { if (props.data.discountPrice === null && props.data.vipPrice === null) {
// null // null
return ''; return '';

View File

@ -94,7 +94,6 @@
}); });
const propertyList = convertProductPropertyList(props.goodsInfo.skus); const propertyList = convertProductPropertyList(props.goodsInfo.skus);
console.log('传递来的sku信息', props.goodsInfo.skus)
// SKU // SKU
const skuList = computed(() => { const skuList = computed(() => {
let skuPrices = props.goodsInfo.skus; let skuPrices = props.goodsInfo.skus;
@ -108,7 +107,6 @@
() => 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, //
@ -124,7 +122,6 @@
// //
function onAddCart() { function onAddCart() {
console.log('购物车',state.selectedSku)
if (state.selectedSku.id <= 0) { if (state.selectedSku.id <= 0) {
sheep.$helper.toast('请选择规格'); sheep.$helper.toast('请选择规格');
return; return;