From 366de5b4636679392a1e3d2984fc23bd5eaa5ac3 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 27 八月 2024 17:48:03 +0800
Subject: [PATCH] wenti

---
 packagePersonal/pages/publishBooks/index.js |  143 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 137 insertions(+), 6 deletions(-)

diff --git a/packagePersonal/pages/publishBooks/index.js b/packagePersonal/pages/publishBooks/index.js
index 6057736..f5d2c07 100644
--- a/packagePersonal/pages/publishBooks/index.js
+++ b/packagePersonal/pages/publishBooks/index.js
@@ -1,11 +1,28 @@
-// pages/personalCenter/publishBooks/index.js
+import moment from 'moment'
+const app = getApp();
+import {
+  getTopicMsgCmsItemFile
+} from '../../../assets/js/middleGround/tool.js'
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-
+    list: [],
+    //鍒嗛〉
+    page: 1,
+    limit: 10,
+    pageTotalCount: 0,
+    bottomLoading: false,
+    isMoreData: false,
+    // 杩斿洖椤堕儴
+    isBackTop: false,
+    setScrollValue: 0,
+    skeletonLoding: true,
+    worksInfo: [],
+    info: {},
+    visible: false
   },
 
   /**
@@ -13,8 +30,79 @@
    */
   onLoad(options) {
     console.log(options);
+    this.getType()
   },
-
+  getType() {
+    const data = {
+      refCodes: ['jsek_publicationApplication']
+    }
+    app.MG.resource.getCmsTypeByRefCode(data).then((res) => {
+      this.setData({
+        worksInfo: res[0].cmsTypeLinks[0].children,
+      })
+      this.getDataList(false)
+    })
+  },
+  getDataList(isReachBottom) {
+    app.MG.ugc.getTopicMessageList({
+        appRefCode: app.config.appRefCode,
+        topicIdOrRefCode: 'bookApplication',
+        start: this.data.page * this.data.limit - this.data.limit,
+        size: this.data.limit,
+        sort: {
+          type: "Desc",
+          field: "CreateDate"
+        }
+      })
+      .then(res => {
+        try {
+          if (res.datas.length > 0) {
+            res.datas.forEach((item) => {
+              item.createDate = moment(item.createDate).format("YYYY-MM-DD");
+              let info = getTopicMsgCmsItemFile(this.data.worksInfo, item.cmsItemDataList)
+              if (info) {
+                item.info = info
+              }
+            });
+            let dataList = res.datas;
+            //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹�
+            if (isReachBottom) {
+              dataList = [...this.data.list, ...dataList] //灏嗘柊鏁版嵁鍔犲叆鑰佹暟鎹腑
+            }
+            this.setData({
+              list: dataList,
+              pageTotalCount: res.totalSize,
+              bottomLoading: false,
+              isMoreData: dataList.length > 0 ? false : true,
+              skeletonLoding: false,
+            })
+          } else {
+            this.setData({
+              skeletonLoding: false,
+            })
+          }
+        } catch (error) {
+          console.log(error)
+        }
+      })
+  },
+  toList(itemData) {
+    let info = itemData.currentTarget.dataset.info;
+    this.setData({
+      info: info.info,
+      visible: true
+    })
+  },
+  onVisibleChange(e) {
+    this.setData({
+      visible: e.detail.visible,
+    });
+  },
+  onClose() {
+    this.setData({
+      visible: false,
+    });
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
@@ -47,16 +135,59 @@
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
   onPullDownRefresh() {
-
+    if (this._freshing) return
+    this.setData({
+      page: 1,
+      limit: 10,
+      pageTotalCount: 0,
+      bottomLoading: false,
+      isMoreData: false
+    })
+    this._freshing = true;
+    this.setData({
+      triggered: false,
+    })
+    this.getDataList(false);
+    this._freshing = false
   },
 
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
   onReachBottom() {
-
+    this.setData({
+      bottomLoading: true,
+      isMoreData: false
+    })
+    let bool = false;
+    if (this.data.pageTotalCount > this.data.list.length) {
+      bool = true;
+      this.setData({
+        page: this.data.page + 1,
+      })
+    } else {
+      setTimeout(() => {
+        this.setData({
+          bottomLoading: false,
+          isMoreData: true
+        })
+      }, 100)
+      return false;
+    }
+    this.getDataList(bool);
   },
-
+  // 鐩戝惉婊氬姩璺濈
+  onPageScroll(e) {
+    if (e && e.scrollTop >= 1000) {
+      this.setData({
+        isBackTop: true
+      })
+    } else {
+      this.setData({
+        isBackTop: false
+      })
+    }
+  },
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */

--
Gitblit v1.9.1