Browse Source

取件单列表分页修复

Hello小健 1 week ago
parent
commit
c5b5d0f5d2
2 changed files with 33 additions and 27 deletions
  1. 31 26
      src/pages/pickup/waybillPickUpOrder.vue
  2. 2 1
      src/services/waybillPickUpOrder.ts

+ 31 - 26
src/pages/pickup/waybillPickUpOrder.vue

@@ -61,14 +61,14 @@
         </navigator>
       </view>
       <view class="loading-text">
-        <!-- {{ item.finish ? '没有更多数据了~' : '正在加载...' }} -->
+        {{ total === waybillDelivery.length ? '没有更多数据了~' : '正在加载...' }}
       </view>
     </scroll-view>
   </view>
 </template>
 
 <script setup lang="ts">
-import { ref } from 'vue'
+import { reactive, ref } from 'vue'
 import { onLoad, onNavigationBarButtonTap } from '@dcloudio/uni-app'
 import { checkPermission } from '@/utils'
 import { waybillPickUpOrders } from '@/services/waybillPickUpOrder'
@@ -82,10 +82,15 @@ const loading = ref(false)
 const loadingBtn = ref(false)
 const searchValue = ref()
 const waybillDelivery = ref([] as any)
+const total = ref()
 const messageType = ref()
 const messageText = ref()
 const messageRef = ref()
 const showRightRef = ref()
+const params = reactive({
+  page: 1,
+  limit: 10,
+})
 
 const resetForm = () => {}
 const confirmForm = () => {
@@ -310,13 +315,14 @@ const cancelFedExPickUp = (data: { id: any }) => {
 
 const getList = async () => {
   loading.value = true
-
-  const res = await waybillPickUpOrders()
+  params.page = 1
+  const res = await waybillPickUpOrders(params)
 
   loading.value = false
   console.log(res)
   if (res.code == 1) {
     waybillDelivery.value = res.data.list
+    total.value = res.data.total
   } else {
     messageType.value = 'error'
     messageText.value = res.msg
@@ -335,28 +341,21 @@ onNavigationBarButtonTap((event) => {
 
 // 滚动触底
 const onScrolltolower = async () => {
-  // // 获取当前选项
-  // const currsubTypes = subTypes.value[activeIndex.value]
-  // // 分页条件
-  // if (currsubTypes.goodsItems.page < currsubTypes.goodsItems.pages) {
-  //   // 当前页码累加
-  //   currsubTypes.goodsItems.page++
-  // } else {
-  //   // 标记已结束
-  //   currsubTypes.finish = true
-  //   // 退出并轻提示
-  //   return uni.showToast({ icon: 'none', title: '没有更多数据了~' })
-  // }
-  // // 调用API传参
-  // const res = await getHotRecommendAPI(currUrlMap!.url, {
-  //   subType: currsubTypes.id,
-  //   page: currsubTypes.goodsItems.page,
-  //   pageSize: currsubTypes.goodsItems.pageSize,
-  // })
-  // // 新的列表选项
-  // const newsubTypes = res.result.subTypes[activeIndex.value]
-  // // 数组追加
-  // currsubTypes.goodsItems.items.push(...newsubTypes.goodsItems.items)
+  // 分页条件
+  if (waybillDelivery.value.length < total.value) {
+    // 当前页码累加
+    params.page++
+  } else {
+    // 退出并轻提示
+    return uni.showToast({ icon: 'none', title: '没有更多数据了~' })
+  }
+  // 调用API传参
+  const res = await waybillPickUpOrders(params)
+  if (res.code == 1) {
+    // 数组追加
+    waybillDelivery.value.push(...res.data.list)
+    total.value = res.data.total
+  }
 }
 </script>
 
@@ -488,4 +487,10 @@ page {
     margin-right: 10rpx;
   }
 }
+.loading-text {
+  text-align: center;
+  font-size: 28rpx;
+  color: #666;
+  padding: 20rpx 0 50rpx;
+}
 </style>

+ 2 - 1
src/services/waybillPickUpOrder.ts

@@ -3,9 +3,10 @@ import { http } from '@/utils/http'
 /**
  * 获取取件单列表
  */
-export const waybillPickUpOrders = () => {
+export const waybillPickUpOrders = (params: { page: number; limit: number }) => {
   return http<any>({
     method: 'GET',
     url: '/admin/pickup.waybillPickUpOrder/index',
+    data: params,
   })
 }