2022-11-22 07:45:36 +00:00
|
|
|
|
<!-- 页面 -->
|
|
|
|
|
<template>
|
|
|
|
|
<s-layout title="我的拼团">
|
|
|
|
|
<su-sticky bgColor="#fff">
|
|
|
|
|
<su-tabs
|
|
|
|
|
:list="tabMaps"
|
|
|
|
|
:scrollable="false"
|
|
|
|
|
@change="onTabsChange"
|
|
|
|
|
:current="state.currentTab"
|
|
|
|
|
></su-tabs>
|
|
|
|
|
</su-sticky>
|
|
|
|
|
<s-empty v-if="state.pagination.total === 0" icon="/static/goods-empty.png"> </s-empty>
|
|
|
|
|
<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"
|
2024-01-10 15:12:11 +00:00
|
|
|
|
v-for="order in state.pagination.list"
|
2022-11-22 07:45:36 +00:00
|
|
|
|
:key="order.id"
|
|
|
|
|
>
|
2023-02-07 07:48:22 +00:00
|
|
|
|
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
|
2024-01-10 15:12:11 +00:00
|
|
|
|
<view class="order-no">订单号:{{ order.no }}</view>
|
|
|
|
|
<view class="ss-font-26" :class="formatOrderColor(order)">
|
|
|
|
|
{{ formatOrderStatus(order) }}
|
|
|
|
|
</view>
|
2023-02-07 07:48:22 +00:00
|
|
|
|
</view>
|
2024-01-10 15:12:11 +00:00
|
|
|
|
<view class="border-bottom" v-for="item in order.items" :key="item.id">
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<s-goods-item
|
2024-01-10 15:12:11 +00:00
|
|
|
|
:img="item.picUrl"
|
|
|
|
|
:title="item.spuName"
|
|
|
|
|
:skuText="item.properties.map((property) => property.valueName).join(' ')"
|
|
|
|
|
:price="item.price"
|
|
|
|
|
:num="item.count"
|
2022-11-22 07:45:36 +00:00
|
|
|
|
>
|
|
|
|
|
<template #groupon>
|
|
|
|
|
<view class="ss-flex">
|
2024-01-10 15:12:11 +00:00
|
|
|
|
<view class="sales-title"> {{ item.num }}人团 </view>
|
2022-11-22 07:45:36 +00:00
|
|
|
|
<!-- <view class="num-title ss-m-l-20"> 已拼{{ order.goods.sales }}件 </view> -->
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
</s-goods-item>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="order-card-footer ss-flex ss-row-right ss-p-x-20">
|
|
|
|
|
<button
|
|
|
|
|
class="detail-btn ss-reset-button"
|
2024-01-10 15:12:11 +00:00
|
|
|
|
@tap="sheep.$router.go('/pages/order/detail', { id: order.id })"
|
2022-11-22 07:45:36 +00:00
|
|
|
|
>
|
|
|
|
|
订单详情
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
2023-02-07 07:48:22 +00:00
|
|
|
|
class="tool-btn ss-reset-button"
|
2024-01-10 15:12:11 +00:00
|
|
|
|
:class="{ 'ui-BG-Main-Gradient': order.status === 0 }"
|
2022-11-22 07:45:36 +00:00
|
|
|
|
@tap="sheep.$router.go('/pages/activity/groupon/detail', { id: order.id })"
|
|
|
|
|
>
|
2024-01-10 15:12:11 +00:00
|
|
|
|
{{ order.status === 0 ? '邀请拼团' : '拼团详情' }}
|
2022-11-22 07:45:36 +00:00
|
|
|
|
</button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<uni-load-more
|
|
|
|
|
v-if="state.pagination.total > 0"
|
|
|
|
|
:status="state.loadStatus"
|
|
|
|
|
:content-text="{
|
|
|
|
|
contentdown: '上拉加载更多',
|
|
|
|
|
}"
|
2024-01-10 15:12:11 +00:00
|
|
|
|
@tap="loadMore"
|
2022-11-22 07:45:36 +00:00
|
|
|
|
/>
|
|
|
|
|
</s-layout>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { computed, reactive } from 'vue';
|
|
|
|
|
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
|
|
|
|
|
import sheep from '@/sheep';
|
|
|
|
|
import _ from 'lodash';
|
2024-01-10 15:12:11 +00:00
|
|
|
|
import OrderApi from "@/sheep/api/trade/order";
|
|
|
|
|
import {formatOrderColor, formatOrderStatus} from "@/sheep/hooks/useGoods";
|
2022-11-22 07:45:36 +00:00
|
|
|
|
|
|
|
|
|
// 数据
|
|
|
|
|
const state = reactive({
|
|
|
|
|
currentTab: 0,
|
|
|
|
|
pagination: {
|
2024-01-10 15:12:11 +00:00
|
|
|
|
list: [],
|
2022-11-22 07:45:36 +00:00
|
|
|
|
total: 1,
|
2024-01-10 15:12:11 +00:00
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 1,
|
2022-11-22 07:45:36 +00:00
|
|
|
|
},
|
|
|
|
|
loadStatus: '',
|
|
|
|
|
deleteOrderId: 0,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const tabMaps = [
|
|
|
|
|
{
|
|
|
|
|
name: '全部',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '进行中',
|
2024-01-10 15:12:11 +00:00
|
|
|
|
value: 0,
|
2022-11-22 07:45:36 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '拼团成功',
|
2024-01-10 15:12:11 +00:00
|
|
|
|
value: 1,
|
2022-11-22 07:45:36 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '拼团失败',
|
2024-01-10 15:12:11 +00:00
|
|
|
|
value: 2,
|
2022-11-22 07:45:36 +00:00
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 切换选项卡
|
|
|
|
|
function onTabsChange(e) {
|
|
|
|
|
state.pagination = {
|
|
|
|
|
data: [],
|
2024-01-10 15:12:11 +00:00
|
|
|
|
pageNo: 1,
|
2022-11-22 07:45:36 +00:00
|
|
|
|
total: 1,
|
2024-01-10 15:12:11 +00:00
|
|
|
|
pageSize: 5,
|
2022-11-22 07:45:36 +00:00
|
|
|
|
};
|
|
|
|
|
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) {
|
2024-01-10 15:12:11 +00:00
|
|
|
|
let index = state.pagination.list.findIndex((order) => order.id === orderId);
|
|
|
|
|
state.pagination.list[index] = data;
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 取消订单
|
|
|
|
|
async function onCancel(orderId) {
|
|
|
|
|
const { error, data } = await sheep.$api.order.cancel(orderId);
|
|
|
|
|
if (error === 0) {
|
2024-01-10 15:12:11 +00:00
|
|
|
|
let index = state.pagination.list.findIndex((order) => order.id === orderId);
|
|
|
|
|
state.pagination.list[index] = data;
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取订单列表
|
2024-01-10 15:12:11 +00:00
|
|
|
|
async function getGrouponList() {
|
2022-11-22 07:45:36 +00:00
|
|
|
|
state.loadStatus = 'loading';
|
2024-01-10 15:12:11 +00:00
|
|
|
|
// todo: 缺少拼团订单接口
|
|
|
|
|
const { code, data } = await OrderApi.getOrderPage({
|
|
|
|
|
pageNo: state.pagination.pageNo,
|
|
|
|
|
pageSize: state.pagination.pageSize,
|
|
|
|
|
status: tabMaps[state.currentTab].value,
|
|
|
|
|
commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
|
2022-11-22 07:45:36 +00:00
|
|
|
|
});
|
2024-01-10 15:12:11 +00:00
|
|
|
|
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';
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onLoad((options) => {
|
|
|
|
|
if (options.type) {
|
|
|
|
|
state.currentTab = options.type;
|
|
|
|
|
}
|
|
|
|
|
getGrouponList();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 加载更多
|
2024-01-10 15:12:11 +00:00
|
|
|
|
function loadMore() {
|
2022-11-22 07:45:36 +00:00
|
|
|
|
if (state.loadStatus !== 'noMore') {
|
2024-01-10 15:12:11 +00:00
|
|
|
|
state.pagination.pageNo++;
|
|
|
|
|
getGrouponList();
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上拉加载更多
|
|
|
|
|
onReachBottom(() => {
|
2024-01-10 15:12:11 +00:00
|
|
|
|
loadMore();
|
2022-11-22 07:45:36 +00:00
|
|
|
|
});
|
|
|
|
|
//下拉刷新
|
|
|
|
|
onPullDownRefresh(() => {
|
|
|
|
|
getGrouponList();
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
|
}, 800);
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.swiper-box {
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
|
|
.swiper-item {
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.order-list-card-box {
|
|
|
|
|
.order-card-header {
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
|
|
|
|
|
.order-no {
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.order-card-footer {
|
|
|
|
|
height: 100rpx;
|
|
|
|
|
|
|
|
|
|
.detail-btn {
|
|
|
|
|
width: 210rpx;
|
|
|
|
|
height: 66rpx;
|
|
|
|
|
border: 2rpx solid #dfdfdf;
|
|
|
|
|
border-radius: 33rpx;
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: #999999;
|
|
|
|
|
margin-right: 20rpx;
|
|
|
|
|
}
|
2023-02-07 07:48:22 +00:00
|
|
|
|
.tool-btn {
|
|
|
|
|
width: 210rpx;
|
|
|
|
|
height: 66rpx;
|
|
|
|
|
border-radius: 33rpx;
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
margin-right: 20rpx;
|
|
|
|
|
background: #f6f6f6;
|
|
|
|
|
}
|
2022-11-22 07:45:36 +00:00
|
|
|
|
|
|
|
|
|
.invite-btn {
|
|
|
|
|
width: 210rpx;
|
|
|
|
|
height: 66rpx;
|
|
|
|
|
background: linear-gradient(90deg, #fe832a, #ff6600);
|
|
|
|
|
box-shadow: 0px 8rpx 6rpx 0px rgba(255, 104, 4, 0.22);
|
|
|
|
|
border-radius: 33rpx;
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sales-title {
|
|
|
|
|
height: 32rpx;
|
|
|
|
|
background: rgba(#ffe0e2, 0.29);
|
|
|
|
|
border-radius: 16rpx;
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
padding: 6rpx 20rpx;
|
|
|
|
|
color: #f7979c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.num-title {
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: #999999;
|
|
|
|
|
}
|
2023-02-07 07:48:22 +00:00
|
|
|
|
.warning-color {
|
|
|
|
|
color: #faad14;
|
|
|
|
|
}
|
|
|
|
|
.danger-color {
|
|
|
|
|
color: #ff3000;
|
|
|
|
|
}
|
|
|
|
|
.success-color {
|
|
|
|
|
color: #52c41a;
|
|
|
|
|
}
|
2022-11-22 07:45:36 +00:00
|
|
|
|
</style>
|