拼团:拼团订单列表

This commit is contained in:
YunaiV
2024-01-13 19:08:55 +08:00
parent c3bb0a2ddc
commit 93c721a526
4 changed files with 137 additions and 169 deletions
+30 -80
View File
@@ -1,4 +1,4 @@
<!-- 页面 -->
<!-- 我的拼团订单列表 -->
<template>
<s-layout title="我的拼团">
<su-sticky bgColor="#fff">
@@ -9,31 +9,28 @@
:current="state.currentTab"
></su-tabs>
</su-sticky>
<s-empty v-if="state.pagination.total === 0" icon="/static/goods-empty.png"> </s-empty>
<s-empty v-if="state.pagination.total === 0" icon="/static/goods-empty.png" />
<view v-if="state.pagination.total > 0">
<view
class="order-list-card-box bg-white ss-r-10 ss-m-t-14 ss-m-20"
v-for="order in state.pagination.list"
:key="order.id"
v-for="record in state.pagination.list"
:key="record.id"
>
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
<view class="order-no">订单{{ order.no }}</view>
<view class="ss-font-26" :class="formatOrderColor(order)">
{{ formatOrderStatus(order) }}
<view class="order-no">拼团编{{ record.id }}</view>
<view class="ss-font-26" :class="formatOrderColor(record)">
{{ tabMaps.find((item) => item.value === record.status).name }}
</view>
</view>
<view class="border-bottom" v-for="item in order.items" :key="item.id">
<view class="border-bottom">
<s-goods-item
:img="item.picUrl"
:title="item.spuName"
:skuText="item.properties.map((property) => property.valueName).join(' ')"
:price="item.price"
:num="item.count"
:img="record.picUrl"
:title="record.spuName"
:price="record.combinationPrice"
>
<template #groupon>
<view class="ss-flex">
<view class="sales-title"> {{ item.num }}人团 </view>
<!-- <view class="num-title ss-m-l-20"> 已拼{{ order.goods.sales }} </view> -->
<view class="sales-title"> {{ record.userSize }} 人团 </view>
</view>
</template>
</s-goods-item>
@@ -41,16 +38,16 @@
<view class="order-card-footer ss-flex ss-row-right ss-p-x-20">
<button
class="detail-btn ss-reset-button"
@tap="sheep.$router.go('/pages/order/detail', { id: order.id })"
@tap="sheep.$router.go('/pages/order/detail', { id: record.id })"
>
订单详情
</button>
<button
class="tool-btn ss-reset-button"
:class="{ 'ui-BG-Main-Gradient': order.status === 0 }"
@tap="sheep.$router.go('/pages/activity/groupon/detail', { id: order.id })"
:class="{ 'ui-BG-Main-Gradient': record.status === 0 }"
@tap="sheep.$router.go('/pages/activity/groupon/detail', { id: record.id })"
>
{{ order.status === 0 ? '邀请拼团' : '拼团详情' }}
{{ record.status === 0 ? '邀请拼团' : '拼团详情' }}
</button>
</view>
</view>
@@ -67,21 +64,22 @@
</template>
<script setup>
import { computed, reactive } from 'vue';
import { reactive } from 'vue';
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import _ from 'lodash';
import OrderApi from "@/sheep/api/trade/order";
import {formatOrderColor, formatOrderStatus} from "@/sheep/hooks/useGoods";
import {formatOrderColor} from "@/sheep/hooks/useGoods";
import { resetPagination } from '@/sheep/util';
import CombinationApi from '@/sheep/api/promotion/combination';
// 数据
const state = reactive({
currentTab: 0,
pagination: {
list: [],
total: 1,
total: 0,
pageNo: 1,
pageSize: 1,
pageSize: 5,
},
loadStatus: '',
deleteOrderId: 0,
@@ -107,75 +105,25 @@
// 切换选项卡
function onTabsChange(e) {
state.pagination = {
data: [],
pageNo: 1,
total: 1,
pageSize: 5,
};
resetPagination(state.pagination);
state.currentTab = e.index;
getGrouponList();
}
// 订单详情
function onDetail(orderSN) {
sheep.$router.go('/pages/order/detail', {
orderSN,
});
}
// 继续支付
function onPay(orderSN) {
sheep.$router.go('/pages/pay/index', {
orderSN,
});
}
// 评价
function onComment(orderSN) {
sheep.$router.go('/pages/order/comment/add', {
orderSN,
});
}
// 确认收货
async function onConfirm(orderId) {
const { error, data } = await sheep.$api.order.confirm(orderId);
if (error === 0) {
let index = state.pagination.list.findIndex((order) => order.id === orderId);
state.pagination.list[index] = data;
}
}
// 取消订单
async function onCancel(orderId) {
const { error, data } = await sheep.$api.order.cancel(orderId);
if (error === 0) {
let index = state.pagination.list.findIndex((order) => order.id === orderId);
state.pagination.list[index] = data;
}
}
// 获取订单列表
async function getGrouponList() {
state.loadStatus = 'loading';
// todo: 缺少拼团订单接口
const { code, data } = await OrderApi.getOrderPage({
const { code, data } = await CombinationApi.getCombinationRecordPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
status: tabMaps[state.currentTab].value,
commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list)
state.pagination.total = data.total;
if (state.pagination.list.length < state.pagination.total) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
onLoad((options) => {
@@ -187,16 +135,18 @@
// 加载更多
function loadMore() {
if (state.loadStatus !== 'noMore') {
state.pagination.pageNo++;
getGrouponList();
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getGrouponList();
}
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
//下拉刷新
onPullDownRefresh(() => {
getGrouponList();