diff --git a/pages/activity/groupon/order.vue b/pages/activity/groupon/order.vue index 74b34fcb..83225681 100644 --- a/pages/activity/groupon/order.vue +++ b/pages/activity/groupon/order.vue @@ -13,34 +13,26 @@ - 订单号:{{ order.my.order.order_sn }} - {{ order.status_text }} + 订单号:{{ order.no }} + + {{ formatOrderStatus(order) }} + - + @@ -49,16 +41,16 @@ @@ -69,7 +61,7 @@ :content-text="{ contentdown: '上拉加载更多', }" - @tap="loadmore" + @tap="loadMore" /> @@ -79,15 +71,17 @@ 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"; // 数据 const state = reactive({ currentTab: 0, pagination: { - data: [], - current_page: 1, + list: [], total: 1, - last_page: 1, + pageNo: 1, + pageSize: 1, }, loadStatus: '', deleteOrderId: 0, @@ -96,19 +90,18 @@ const tabMaps = [ { name: '全部', - value: 'all', }, { name: '进行中', - value: 'ing', + value: 0, }, { name: '拼团成功', - value: 'finish', + value: 1, }, { name: '拼团失败', - value: 'invalid', + value: 2, }, ]; @@ -116,9 +109,9 @@ function onTabsChange(e) { state.pagination = { data: [], - current_page: 1, + pageNo: 1, total: 1, - last_page: 1, + pageSize: 5, }; state.currentTab = e.index; getGrouponList(); @@ -149,8 +142,8 @@ async function onConfirm(orderId) { const { error, data } = await sheep.$api.order.confirm(orderId); if (error === 0) { - let index = state.pagination.data.findIndex((order) => order.id === orderId); - state.pagination.data[index] = data; + let index = state.pagination.list.findIndex((order) => order.id === orderId); + state.pagination.list[index] = data; } } @@ -158,33 +151,30 @@ async function onCancel(orderId) { const { error, data } = await sheep.$api.order.cancel(orderId); if (error === 0) { - let index = state.pagination.data.findIndex((order) => order.id === orderId); - state.pagination.data[index] = data; + let index = state.pagination.list.findIndex((order) => order.id === orderId); + state.pagination.list[index] = data; } } // 获取订单列表 - async function getGrouponList(page = 1, list_rows = 5) { + async function getGrouponList() { state.loadStatus = 'loading'; - let res = await sheep.$api.activity.myGroupon({ - type: tabMaps[state.currentTab].value, + // 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 }); - if (res.error === 0) { - if (page >= 2) { - let orderList = _.concat(state.pagination.data, res.data.data); - state.pagination = { - ...res.data, - data: orderList, - }; - } else { - state.pagination = res.data; - } - - if (state.pagination.current_page < state.pagination.last_page) { - state.loadStatus = 'more'; - } else { - state.loadStatus = 'noMore'; - } + 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'; } } @@ -196,15 +186,16 @@ }); // 加载更多 - function loadmore() { + function loadMore() { if (state.loadStatus !== 'noMore') { - getGrouponList(state.pagination.current_page + 1); + state.pagination.pageNo++; + getGrouponList(); } } // 上拉加载更多 onReachBottom(() => { - loadmore(); + loadMore(); }); //下拉刷新 onPullDownRefresh(() => {