|
@@ -15,7 +15,7 @@
|
|
|
>
|
|
|
</up-tabs>
|
|
|
<view class="list">
|
|
|
- <List :data="data" v-if="data && data.length > 0" @refresh="getList" ref="listRef"/>
|
|
|
+ <List :data="data" v-if="data && data.length > 0" @refresh="getList" ref="listRef" :total="pages.total"/>
|
|
|
<view v-else>
|
|
|
<NoneView value="您还没有相关订单" />
|
|
|
</view>
|
|
@@ -104,33 +104,40 @@ const column = computed(() => {
|
|
|
return userType === 1 ? user : admin
|
|
|
})
|
|
|
|
|
|
-async function getList() {
|
|
|
+const pages = ref({
|
|
|
+ current: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ total: 0,
|
|
|
+})
|
|
|
+async function getList(type) {
|
|
|
try {
|
|
|
- uni.showLoading({
|
|
|
- title: '数据加载中...',
|
|
|
- })
|
|
|
-
|
|
|
+
|
|
|
+ console.log(data.value.length, pages.value.total);
|
|
|
+
|
|
|
+ if(type ==='bottom' ){
|
|
|
+ if(data.value.length < pages.value.total){
|
|
|
+ listRef.value && listRef.value.handleBottom(true);
|
|
|
+ pages.value.current++;
|
|
|
+ }else {
|
|
|
+ listRef.value && listRef.value.handleBottom(false)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ uni.showLoading({
|
|
|
+ title: '数据加载中...',
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
const listApi = userType === 1 ? userMainOrderList : getVolunteerOrderList
|
|
|
const res = await listApi({
|
|
|
orderStatus: tab.value,
|
|
|
+ pageNum: pages.value.current,
|
|
|
+ pageSize: pages.value.pageSize,
|
|
|
})
|
|
|
- data.value =res.rows || res.data
|
|
|
+ data.value =[...data.value,...res.rows];
|
|
|
+ pages.value.total = res.total;
|
|
|
|
|
|
- // 判断 userType 来决定调用哪个接口
|
|
|
- // let res
|
|
|
- // if (userType === 1) {
|
|
|
- // // 如果 userType 是 1,调用 userMainOrderList 接口
|
|
|
- // // res = await getListData()
|
|
|
- // res = await userMainOrderList({
|
|
|
- // orderStatus: tab.value
|
|
|
- // })
|
|
|
- // } else if (userType === 2) {
|
|
|
- // // 如果 userType 是 2,调用 getVolunteerOrderList 接口
|
|
|
- // res = await getVolunteerOrderList({
|
|
|
- // orderStatus: tab.value,
|
|
|
- // })
|
|
|
- // }
|
|
|
- // data.value = res.data
|
|
|
+ type ==='bottom'&& listRef.value && listRef.value.handleBottom(false);
|
|
|
} catch (error) {
|
|
|
console.log('error', error)
|
|
|
uni.showToast({
|
|
@@ -138,10 +145,10 @@ async function getList() {
|
|
|
icon: 'error',
|
|
|
})
|
|
|
} finally {
|
|
|
- if(listRef.value && listRef.value.handleRefreshing){
|
|
|
+ if(listRef.value && listRef.value.handleRefreshing && type ==='top'){
|
|
|
listRef.value.handleRefreshing(false)
|
|
|
}
|
|
|
- uni.hideLoading()
|
|
|
+ type !=='bottom' && uni.hideLoading()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -173,17 +180,19 @@ function btnClick(row, type) {
|
|
|
provide('onClick', btnClick)
|
|
|
|
|
|
function onChange(tabItem) {
|
|
|
- tab.value = tabItem.value
|
|
|
+ tab.value = tabItem.value;
|
|
|
+ pages.value.current = 1;
|
|
|
+ data.value = [];
|
|
|
getList()
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- getList()
|
|
|
+ // getList()
|
|
|
})
|
|
|
|
|
|
onShow(() => {
|
|
|
const params = getApp().globalData.switchTabParams || {}
|
|
|
- tabKey.value = params.tabKey || 0
|
|
|
+ tabKey.value = params.tabKey || 1
|
|
|
onChange(column.value[tabKey.value])
|
|
|
// 使用后建议清除参数,避免重复读取
|
|
|
getApp().globalData.switchTabParams = null
|