2024-01-06 12:40:39 +00:00
|
|
|
|
<!-- 指定满减送的活动列表 -->
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<template>
|
|
|
|
|
<s-layout class="activity-wrap" :title="state.activityInfo.title">
|
2024-01-06 12:40:39 +00:00
|
|
|
|
<!-- 活动信息 -->
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<su-sticky bgColor="#fff">
|
|
|
|
|
<view class="ss-flex ss-col-top tip-box">
|
2024-01-06 12:40:39 +00:00
|
|
|
|
<view class="type-text ss-flex ss-row-center">满减:</view>
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<view class="ss-flex-1">
|
2024-01-06 12:40:39 +00:00
|
|
|
|
<view class="tip-content" v-for="item in state.activityInfo.rules" :key="item">
|
2024-09-21 06:30:27 +00:00
|
|
|
|
{{ item.description }}
|
2022-11-22 07:45:36 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<image class="activity-left-image" src="/static/activity-left.png" />
|
|
|
|
|
<image class="activity-right-image" src="/static/activity-right.png" />
|
|
|
|
|
</view>
|
|
|
|
|
</su-sticky>
|
|
|
|
|
|
2024-01-06 12:40:39 +00:00
|
|
|
|
<!-- 商品信息 -->
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<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="left-list" v-for="item in state.leftGoodsList" :key="item.id">
|
2024-09-16 10:15:13 +00:00
|
|
|
|
<s-goods-column
|
|
|
|
|
class="goods-md-box"
|
|
|
|
|
size="md"
|
|
|
|
|
:data="item"
|
|
|
|
|
@click="sheep.$router.go('/pages/goods/index', { id: item.id })"
|
|
|
|
|
@getHeight="mountMasonry($event, 'left')"
|
|
|
|
|
>
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<template v-slot:cart>
|
|
|
|
|
<button class="ss-reset-button cart-btn"> </button>
|
|
|
|
|
</template>
|
|
|
|
|
</s-goods-column>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="goods-list-box">
|
|
|
|
|
<view class="right-list" v-for="item in state.rightGoodsList" :key="item.id">
|
2024-09-16 10:15:13 +00:00
|
|
|
|
<s-goods-column
|
|
|
|
|
class="goods-md-box"
|
|
|
|
|
size="md"
|
|
|
|
|
:data="item"
|
|
|
|
|
@click="sheep.$router.go('/pages/goods/index', { id: item.id })"
|
|
|
|
|
@getHeight="mountMasonry($event, 'right')"
|
|
|
|
|
>
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<template v-slot:cart>
|
2024-01-06 12:40:39 +00:00
|
|
|
|
<button class="ss-reset-button cart-btn" />
|
2022-11-22 07:45:36 +00:00
|
|
|
|
</template>
|
|
|
|
|
</s-goods-column>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
2024-09-16 10:15:13 +00:00
|
|
|
|
<uni-load-more
|
|
|
|
|
v-if="state.pagination.total > 0"
|
|
|
|
|
:status="state.loadStatus"
|
|
|
|
|
:content-text="{
|
2022-11-22 07:45:36 +00:00
|
|
|
|
contentdown: '上拉加载更多',
|
2024-09-16 10:15:13 +00:00
|
|
|
|
}"
|
|
|
|
|
@tap="loadMore"
|
|
|
|
|
/>
|
2022-11-22 07:45:36 +00:00
|
|
|
|
</s-layout>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
2024-09-16 11:30:56 +00:00
|
|
|
|
import { reactive } from 'vue';
|
2024-09-16 10:15:13 +00:00
|
|
|
|
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
|
2022-11-22 07:45:36 +00:00
|
|
|
|
import sheep from '@/sheep';
|
2024-08-04 09:11:12 +00:00
|
|
|
|
import _ from 'lodash-es';
|
2024-01-06 12:40:39 +00:00
|
|
|
|
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
|
|
|
|
|
import SpuApi from '@/sheep/api/product/spu';
|
2024-09-16 11:30:56 +00:00
|
|
|
|
import { appendSettlementProduct } from '@/sheep/hooks/useGoods';
|
|
|
|
|
import OrderApi from '@/sheep/api/trade/order';
|
2022-11-22 07:45:36 +00:00
|
|
|
|
|
|
|
|
|
const state = reactive({
|
2024-01-06 12:40:39 +00:00
|
|
|
|
activityId: 0, // 获得编号
|
|
|
|
|
activityInfo: {}, // 获得信息
|
|
|
|
|
|
2022-11-22 07:45:36 +00:00
|
|
|
|
pagination: {
|
2024-01-06 12:40:39 +00:00
|
|
|
|
list: [],
|
2022-11-22 07:45:36 +00:00
|
|
|
|
total: 1,
|
2024-01-06 12:40:39 +00:00
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 8,
|
2022-11-22 07:45:36 +00:00
|
|
|
|
},
|
|
|
|
|
loadStatus: '',
|
|
|
|
|
leftGoodsList: [],
|
|
|
|
|
rightGoodsList: [],
|
|
|
|
|
});
|
2024-01-06 12:40:39 +00:00
|
|
|
|
|
2022-11-22 07:45:36 +00:00
|
|
|
|
// 加载瀑布流
|
|
|
|
|
let count = 0;
|
|
|
|
|
let leftHeight = 0;
|
|
|
|
|
let rightHeight = 0;
|
|
|
|
|
|
|
|
|
|
function mountMasonry(height = 0, where = 'left') {
|
2024-01-06 12:40:39 +00:00
|
|
|
|
if (!state.pagination.list[count]) return;
|
2022-11-22 07:45:36 +00:00
|
|
|
|
|
|
|
|
|
if (where === 'left') {
|
|
|
|
|
leftHeight += height;
|
|
|
|
|
} else {
|
|
|
|
|
rightHeight += height;
|
|
|
|
|
}
|
|
|
|
|
if (leftHeight <= rightHeight) {
|
2024-01-06 12:40:39 +00:00
|
|
|
|
state.leftGoodsList.push(state.pagination.list[count]);
|
2022-11-22 07:45:36 +00:00
|
|
|
|
} else {
|
2024-01-06 12:40:39 +00:00
|
|
|
|
state.rightGoodsList.push(state.pagination.list[count]);
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
count++;
|
|
|
|
|
}
|
2024-01-06 12:40:39 +00:00
|
|
|
|
|
|
|
|
|
// 加载商品信息
|
|
|
|
|
async function getList() {
|
|
|
|
|
// 处理拓展参数
|
2024-09-16 10:15:13 +00:00
|
|
|
|
const params = {};
|
2024-01-06 12:40:39 +00:00
|
|
|
|
if (state.activityInfo.productScope === 2) {
|
2024-09-16 11:30:56 +00:00
|
|
|
|
params.ids = state.activityInfo.productSpuIds.join(',');
|
2024-01-06 12:40:39 +00:00
|
|
|
|
} else if (state.activityInfo.productScope === 3) {
|
2024-09-16 11:30:56 +00:00
|
|
|
|
params.categoryIds = state.activityInfo.productSpuIds.join(',');
|
|
|
|
|
}
|
|
|
|
|
// 请求数据
|
|
|
|
|
state.loadStatus = 'loading';
|
|
|
|
|
const { code, data } = await SpuApi.getSpuPage({
|
|
|
|
|
pageNo: state.pagination.pageNo,
|
|
|
|
|
pageSize: state.pagination.pageSize,
|
|
|
|
|
...params,
|
|
|
|
|
});
|
|
|
|
|
if (code !== 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 拼接结算信息(营销)
|
|
|
|
|
await OrderApi.getSettlementProduct(data.list.map((item) => item.id).join(',')).then((res) => {
|
|
|
|
|
if (res.code !== 0) {
|
2024-09-15 09:32:29 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-09-16 11:30:56 +00:00
|
|
|
|
appendSettlementProduct(data.list, res.data);
|
|
|
|
|
});
|
|
|
|
|
state.pagination.list = _.concat(state.pagination.list, data.list);
|
|
|
|
|
state.pagination.total = data.total;
|
|
|
|
|
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
|
2024-01-06 12:40:39 +00:00
|
|
|
|
mountMasonry();
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
2024-09-15 09:32:29 +00:00
|
|
|
|
|
2024-01-06 12:40:39 +00:00
|
|
|
|
// 加载活动信息
|
2022-11-22 07:45:36 +00:00
|
|
|
|
async function getActivity(id) {
|
2024-09-16 10:15:13 +00:00
|
|
|
|
const { code, data } = await RewardActivityApi.getRewardActivity(id);
|
2024-01-06 12:40:39 +00:00
|
|
|
|
if (code === 0) {
|
2022-11-22 07:45:36 +00:00
|
|
|
|
state.activityInfo = data;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-06 12:40:39 +00:00
|
|
|
|
|
2022-11-22 07:45:36 +00:00
|
|
|
|
// 加载更多
|
2024-01-06 12:40:39 +00:00
|
|
|
|
function loadMore() {
|
|
|
|
|
if (state.loadStatus === 'noMore') {
|
|
|
|
|
return;
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
2024-01-06 12:40:39 +00:00
|
|
|
|
state.pagination.pageNo++;
|
|
|
|
|
getList();
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
2024-01-06 12:40:39 +00:00
|
|
|
|
|
2022-11-22 07:45:36 +00:00
|
|
|
|
// 上拉加载更多
|
|
|
|
|
onReachBottom(() => {
|
2024-01-06 12:40:39 +00:00
|
|
|
|
loadMore();
|
2022-11-22 07:45:36 +00:00
|
|
|
|
});
|
2024-01-06 12:40:39 +00:00
|
|
|
|
|
|
|
|
|
onLoad(async (options) => {
|
2022-11-22 07:45:36 +00:00
|
|
|
|
state.activityId = options.activityId;
|
2024-01-06 12:40:39 +00:00
|
|
|
|
await getActivity(state.activityId);
|
2024-09-16 11:30:56 +00:00
|
|
|
|
await getList(state.activityId);
|
2022-11-22 07:45:36 +00:00
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.goods-list-box {
|
|
|
|
|
width: 50%;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
.left-list {
|
|
|
|
|
margin-right: 10rpx;
|
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
.right-list {
|
|
|
|
|
margin-left: 10rpx;
|
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.tip-box {
|
|
|
|
|
background: #fff0e7;
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
width: 100%;
|
|
|
|
|
position: relative;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
.activity-left-image {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 58rpx;
|
|
|
|
|
height: 36rpx;
|
|
|
|
|
}
|
|
|
|
|
.activity-right-image {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
width: 72rpx;
|
|
|
|
|
height: 50rpx;
|
|
|
|
|
}
|
|
|
|
|
.type-text {
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
color: #ff6000;
|
|
|
|
|
line-height: 42rpx;
|
|
|
|
|
}
|
|
|
|
|
.tip-content {
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
color: #ff6000;
|
|
|
|
|
line-height: 42rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-16 10:15:13 +00:00
|
|
|
|
</style>
|