瀏覽代碼

书架加载

natasha 1 月之前
父節點
當前提交
7680b5b571
共有 1 個文件被更改,包括 98 次插入84 次删除
  1. 98 84
      src/views/bookShelf/index.vue

+ 98 - 84
src/views/bookShelf/index.vue

@@ -172,23 +172,7 @@ export default {
   data() {
   data() {
     //这里存放数据
     //这里存放数据
     return {
     return {
-      BookList: [
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-      ],
+      BookList: [],
       optionList: [
       optionList: [
         {
         {
           label: "全部",
           label: "全部",
@@ -261,7 +245,7 @@ export default {
       loading: false,
       loading: false,
       noMore: false,
       noMore: false,
       pageNumber: 1,
       pageNumber: 1,
-      pageSize: 30,
+      pageSize: 50,
       typeIndex: 0,
       typeIndex: 0,
       orderPeruseNumber: 0, // 精读订阅个数
       orderPeruseNumber: 0, // 精读订阅个数
       userMessage: getToken() ? JSON.parse(getToken()) : null,
       userMessage: getToken() ? JSON.parse(getToken()) : null,
@@ -287,26 +271,28 @@ export default {
       if (item.hasOwnProperty("value")) {
       if (item.hasOwnProperty("value")) {
         this.typeValue = item.value;
         this.typeValue = item.value;
         if (item.number > 0 || item.value === 3) {
         if (item.number > 0 || item.value === 3) {
-          this.BookList = [
-            {
-              skeleton: true,
-            },
-            {
-              skeleton: true,
-            },
-            {
-              skeleton: true,
-            },
-            {
-              skeleton: true,
-            },
-            {
-              skeleton: true,
-            },
-          ];
+          // this.BookList = [
+          //   {
+          //     skeleton: true,
+          //   },
+          //   {
+          //     skeleton: true,
+          //   },
+          //   {
+          //     skeleton: true,
+          //   },
+          //   {
+          //     skeleton: true,
+          //   },
+          //   {
+          //     skeleton: true,
+          //   },
+          // ];
+          this.BookList = [];
           this.stopLoad = false;
           this.stopLoad = false;
           this.getList();
           this.getList();
         } else {
         } else {
+          this.typeValue = null;
           this.BookList = [];
           this.BookList = [];
         }
         }
       } else {
       } else {
@@ -323,23 +309,24 @@ export default {
     // 搜索查询
     // 搜索查询
     getSearch() {
     getSearch() {
       this.pageNumber = 1;
       this.pageNumber = 1;
-      this.BookList = [
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-        {
-          skeleton: true,
-        },
-      ];
+      // this.BookList = [
+      //   {
+      //     skeleton: true,
+      //   },
+      //   {
+      //     skeleton: true,
+      //   },
+      //   {
+      //     skeleton: true,
+      //   },
+      //   {
+      //     skeleton: true,
+      //   },
+      //   {
+      //     skeleton: true,
+      //   },
+      // ];
+      this.BookList = [];
       $(".list").animate(
       $(".list").animate(
         {
         {
           scrollTop: 0,
           scrollTop: 0,
@@ -383,8 +370,9 @@ export default {
       this.getList();
       this.getList();
     },
     },
     // 查询列表
     // 查询列表
-    getList() {
+    async getList() {
       this.loading = true;
       this.loading = true;
+      let oldPageNumber = 1;
       let MethodName = "/ShopServer/Client/BookshelfQuery/PageQueryMyGoodsList";
       let MethodName = "/ShopServer/Client/BookshelfQuery/PageQueryMyGoodsList";
       let order_column_list = [];
       let order_column_list = [];
       if (this.sortField !== "") {
       if (this.sortField !== "") {
@@ -404,42 +392,55 @@ export default {
         cur_page: this.pageNumber,
         cur_page: this.pageNumber,
         order_column_list: order_column_list,
         order_column_list: order_column_list,
       };
       };
-      getLogin(MethodName, data)
+      await getLogin(MethodName, data)
         .then((res) => {
         .then((res) => {
+          console.log(this.typeValue + "page" + this.pageNumber);
           this.loading = false;
           this.loading = false;
           if (res.status === 1) {
           if (res.status === 1) {
-            if (this.pageNumber === 1) {
-              this.BookList = [];
-              if (this.typeValue === -1 || this.typeValue === 3) {
-                getLogin(
-                  "/ShopServer/Client/BookshelfQuery/GetMyValidPeriodList_Iread",
-                  {}
-                ).then((ress) => {
-                  if (ress.status === 1) {
-                    if (res.cur_page === 1) {
-                      this.orderPeruseNumber = ress.valid_period_list.length;
-                      ress.valid_period_list.forEach((items) => {
-                        items.type = 30;
-                      });
-                      this.BookList = ress.valid_period_list.concat(
-                        res.goods_list
-                      );
+            if (
+              this.typeValue === -1 ||
+              (this.typeValue === 10 &&
+                res.goods_list[0].type === 0 &&
+                res.goods_list.length > 0) ||
+              (this.typeValue === res.goods_list[0].type &&
+                res.goods_list.length > 0)
+            ) {
+              if (res.cur_page === 1) {
+                this.BookList = [];
+                if (this.typeValue === -1 || this.typeValue === 3) {
+                  getLogin(
+                    "/ShopServer/Client/BookshelfQuery/GetMyValidPeriodList_Iread",
+                    {}
+                  ).then((ress) => {
+                    if (ress.status === 1) {
+                      if (res.cur_page === 1) {
+                        this.orderPeruseNumber = ress.valid_period_list.length;
+                        ress.valid_period_list.forEach((items) => {
+                          items.type = 30;
+                        });
+                        this.BookList = ress.valid_period_list.concat(
+                          res.goods_list
+                        );
+                      }
+                    } else {
+                      this.BookList = res.goods_list;
                     }
                     }
-                  } else {
-                    this.BookList = res.goods_list;
-                  }
-                });
-              } else {
-                if (res.cur_page === 1) {
+                  });
+                } else {
                   this.BookList = res.goods_list;
                   this.BookList = res.goods_list;
                 }
                 }
+                this.noMore = false;
+              } else if (res.cur_page !== 1) {
+                this.BookList = this.BookList.concat(res.goods_list);
+              }
+              if (res.total_page * this.pageSize <= res.cur_page_end_index) {
+                this.noMore = true;
+              }
+              if (this.BookList.length === 0) {
+                console.log("kong" + this.typeValue + "---" + this.pageNumber);
               }
               }
-              this.noMore = false;
             } else {
             } else {
-              this.BookList = this.BookList.concat(res.goods_list);
-            }
-            if (res.total_page <= this.pageNumber) {
-              this.noMore = true;
+              this.BookList = [];
             }
             }
           }
           }
         })
         })
@@ -449,8 +450,21 @@ export default {
     },
     },
     load() {
     load() {
       if (this.userMessage) {
       if (this.userMessage) {
-        this.pageNumber++;
-        this.getList();
+        if (
+          this.pageNumber > 2 &&
+          (this.typeValue === -1 ||
+            (this.typeValue === 10 &&
+              this.BookList[0].type === 0 &&
+              this.BookList.length > 0) ||
+            (this.typeValue === this.BookList[0].type &&
+              this.BookList.length > 0))
+        ) {
+          this.pageNumber++;
+          this.getList();
+        } else {
+          this.pageNumber++;
+          this.getList();
+        }
       }
       }
     },
     },
     // 获取商品个数
     // 获取商品个数
@@ -521,7 +535,7 @@ export default {
   },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
   created() {
-    console.log("2025-05-08");
+    console.log("2025-05-08-1");
     if (this.userMessage) {
     if (this.userMessage) {
       this.getNumber();
       this.getNumber();
       this.getList();
       this.getList();