panhui 2 anni fa
parent
commit
aad6541b22
2 ha cambiato i file con 25 aggiunte e 11 eliminazioni
  1. 6 6
      src/plugins/list.js
  2. 19 5
      src/views/ProductListPage.vue

+ 6 - 6
src/plugins/list.js

@@ -16,14 +16,14 @@ function useList(url, beforeData = null, httpType) {
     const size = ref(20)
     const list = ref([])
 
-    const getData = (isRefresh = false, isFinished = false) => {
+    const getData = (isRefresh = false) => {
         if (isRefresh) {
             page.value = 0
             list.value = []
         }
-        loading.value = true
         finished.value = false
         empty.value = false
+        loading.value = true
 
         let data = { page: page.value, size: size.value, sort: 'createdAt,desc' }
         if (beforeData) {
@@ -42,12 +42,12 @@ function useList(url, beforeData = null, httpType) {
                     }
                     list.value = [...list.value, ...res.content]
                     empty.value = res.empty
-                    loading.value = false
-                    finished.value = isFinished || res.last
+                    finished.value = res.last
                     if (!finished.value) {
                         page.value = page.value + 1
                     }
                     totalElements.value = Number(res.totalElements)
+                    loading.value = false
                 })
                 .catch(e => {
                     console.log(e)
@@ -61,12 +61,12 @@ function useList(url, beforeData = null, httpType) {
                     }
                     list.value = [...list.value, ...res.content]
                     empty.value = res.empty
-                    loading.value = false
-                    finished.value = isFinished || res.last
+                    finished.value = res.last
                     if (!finished.value) {
                         page.value = page.value + 1
                     }
                     totalElements.value = Number(res.totalElements)
+                    loading.value = false
                 })
                 .catch(e => {
                     console.log(e)

+ 19 - 5
src/views/ProductListPage.vue

@@ -28,7 +28,7 @@
                 <span><van-count-down :time="status" /> {{ $t('product.start') }}</span>
             </div> -->
         </ion-header>
-        <ion-content>
+        <ion-content :scrollEvents="true" @ionScrollEnd="handleScrollEnd()">
             <ion-refresher slot="fixed" @ionRefresh="handleRefresh($event)">
                 <ion-refresher-content></ion-refresher-content>
             </ion-refresher>
@@ -45,6 +45,8 @@
                 :finished-text="$t('common.loadFinish')"
                 @load="getData"
                 :immediate-check="false"
+                ref="listRef"
+                :disabled="disScroll"
             >
                 <template v-if="listType === 'list'">
                     <div class="product-list" v-for="item in list" :key="item.id">
@@ -91,7 +93,7 @@ const { empty, size, loading, finished, list, getData } = useList('/product/list
     }
 })
 const handleRefresh = event => {
-    getData(true, true).then(() => {
+    getData(true).then(() => {
         event.target.complete()
     })
 }
@@ -135,11 +137,23 @@ const changeType = type => {
 //     return ''
 // })
 
+const disScroll = ref(true)
 onMounted(() => {
-    size.value = 10
-    getData(true, true)
+    if (batchId === 11548 || batchId === '11548') {
+        size.value = 20
+        disScroll.value = false
+    } else {
+        size.value = 10
+        disScroll.value = true
+    }
+    getData(true)
     getBatch()
 })
+
+const listRef = ref(null)
+function handleScrollEnd() {
+    listRef.value.check()
+}
 </script>
 
 <style lang="less" scoped>
@@ -160,7 +174,7 @@ ion-button {
     margin-right: 12px;
 }
 .list {
-    padding: 8px;
+    padding: 8px 8px 8px;
     .product {
         margin: 8px;
         background: var(--ion-color-step-50);