|
|
@@ -1,6 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import { tabsList } from '../order-data'
|
|
|
import attractionsList from '@/subPack-smqjh/components/attractions-orderList/attractions-orderList.vue?async'
|
|
|
+import { createGlobalLoadingMiddleware } from '@/api/core/middleware'
|
|
|
|
|
|
const tab = ref<number>(0)
|
|
|
const { statusBarHeight, MenuButtonHeight } = storeToRefs(useSysStore())
|
|
|
@@ -14,44 +15,36 @@ const statusMap: Record<number, number> = {
|
|
|
4: 4, // 已完成
|
|
|
}
|
|
|
|
|
|
-// 使用 usePagination 调用接口
|
|
|
-const { data: orderList, isLastPage, reload, page, loading } = usePagination(
|
|
|
- (pageNum, pageSize) => Apis.attractions.orderList({
|
|
|
- data: {
|
|
|
- pageNum,
|
|
|
- pageSize,
|
|
|
- status: statusMap[tab.value],
|
|
|
- },
|
|
|
- }),
|
|
|
- {
|
|
|
- immediate: true,
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 10,
|
|
|
- initialData: [],
|
|
|
- data: res => res.data?.list,
|
|
|
- append: true,
|
|
|
- },
|
|
|
-)
|
|
|
+const { data: orderList, isLastPage, page, error, refresh, reload } = usePagination((pageNum, pageSize) => Apis.xsb.orderList({ data: {
|
|
|
+ businessType: 'JDMP',
|
|
|
+ pageNum,
|
|
|
+ pageSize,
|
|
|
+ orderStatus: statusMap[tab.value],
|
|
|
+} }), {
|
|
|
+ immediate: false,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ initialData: [],
|
|
|
+ data: res => res.data?.list,
|
|
|
+ append: true,
|
|
|
+ middleware: createGlobalLoadingMiddleware(),
|
|
|
+})
|
|
|
|
|
|
// tab切换
|
|
|
function handleClick(e: { index: number }) {
|
|
|
tab.value = e.index
|
|
|
- // 清空数据后重新加载,避免数据溢出
|
|
|
orderList.value = []
|
|
|
- reload()
|
|
|
+ refresh()
|
|
|
}
|
|
|
|
|
|
onReachBottom(() => {
|
|
|
if (!isLastPage.value) {
|
|
|
page.value++
|
|
|
+ refresh()
|
|
|
}
|
|
|
})
|
|
|
-const loadMoreState = computed(() => {
|
|
|
- if (loading.value)
|
|
|
- return 'loading'
|
|
|
- if (isLastPage.value)
|
|
|
- return 'finished'
|
|
|
- return 'loading'
|
|
|
+const state = computed(() => {
|
|
|
+ return error.value ? 'error' : !isLastPage.value ? 'loading' : 'finished'
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
@@ -67,17 +60,13 @@ const loadMoreState = computed(() => {
|
|
|
<wd-tab :title="item">
|
|
|
<view class="box-border px24rpx" style="background-color: #f6f6f6; min-height: 60vh;">
|
|
|
<view class="h-20rpx" />
|
|
|
- <StatusTip v-if="!orderList.length && !loading" tip="暂无内容" />
|
|
|
+ <StatusTip v-if="!orderList.length" tip="暂无内容" />
|
|
|
<attractionsList
|
|
|
v-for="order in orderList"
|
|
|
:key="order.orderNumber"
|
|
|
:order="order"
|
|
|
/>
|
|
|
- <wd-loadmore
|
|
|
- v-if="orderList.length > 0"
|
|
|
- :state="loadMoreState"
|
|
|
- :loading-props="{ color: '#9ED605', size: 20 }"
|
|
|
- />
|
|
|
+ <wd-loadmore :state="state" :loading-props="{ color: '#9ED605', size: 20 }" @reload="reload" />
|
|
|
<!-- 底部安全区域占位 -->
|
|
|
<view class="h-40rpx" />
|
|
|
</view>
|