From a2e665c3428d0efa9cb0f428f6103bdac553583f Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 15 十月 2024 09:46:55 +0800
Subject: [PATCH] shuzhan

---
 pages/bookExhibitionDetails/index.js |  121 +++++++++++++++++++++++++++++++---------
 1 files changed, 94 insertions(+), 27 deletions(-)

diff --git a/pages/bookExhibitionDetails/index.js b/pages/bookExhibitionDetails/index.js
index 6ab4e9d..0642cf8 100644
--- a/pages/bookExhibitionDetails/index.js
+++ b/pages/bookExhibitionDetails/index.js
@@ -1,28 +1,61 @@
 // pages/bookExhibitionDetails/index.js
 const app = getApp()
+import {
+  loginInfo
+} from '../../assets/js/login';
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    bookName: null,
-    bookBeginDate: null,
-    bookCreator: null,
-    bookContent: null,
-    bookImage: null,
-    bookExhibitionList: []
+    start: 1,
+    loading: true,
+    hidden: true,
+    bookName: '',
+    bookBeginDate: '',
+    bookCreator: '',
+    bookContent: '',
+    bookImage: '',
+    bookExhibitionList: [],
+    navBarHeight: '',
+    barHeight: '',
+    totalSize: '',
+    passId: '',
+    isMore: null,
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+    const systInfo = wx.getSystemInfoSync();
+    const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
+    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
+    this.setData({
+      navBarHeight: navBarHeight,
+      barHeight: systInfo.statusBarHeight,
+    })
+    this.setData({
+      passId: options.id
+    })
+    const token = wx.getStorageSync(app.config.tokenKey)
+    if (!token) {
+      loginInfo(app, (data) => {
+        if (data) {
+          this.bookExhibitionGet(this.data.passId)
+          this.getBookExhibitionDetails()
+        } else {
+          this.bookExhibitionGet(this.data.passId)
+          this.getBookExhibitionDetails()
+        }
+      })
 
-    const passId = options.id
+    } else {
+      this.bookExhibitionGet(this.data.passId)
+      this.getBookExhibitionDetails()
+    }
 
-    this.bookExhibitionGet(passId)
-    this.getBookExhibitionDetails(passId)
   },
 
   /**
@@ -70,15 +103,14 @@
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
-  onShareAppMessage() {
-
-  },
+  onShareAppMessage() {},
+  onShareTimeline() {},
 
   bookExhibitionGet(passId) {
-    wx.showLoading({
-      title: '鍔犺浇涓�...',
+    this.setData({
+      loading: true,
+      hidden: true,
     })
-    console.log(passId, 8988989);
     app.MG.store.getProductDetail({
       storeInfo: 'jsek_bookFair', //鍟嗗搧搴�
       path: '*', //璺緞
@@ -92,24 +124,36 @@
         Creator: []
       }
     }).then(res => {
-      console.log(res.datas.datas.Creator.Name, 'res');
+      console.log(res.datas, 'res');
       this.setData({
         bookName: res.datas.name,
         bookBeginDate: res.datas.beginDate,
         bookCreator: res.datas.datas.Creator.Name,
         bookContent: res.datas.content,
-        bookImage: res.datas.icon
+        bookImage: res.datas.icon || '/static/images/bookExhibitionList/banner.png',
+        loading: false,
+        hidden: false,
       });
-      wx.hideLoading()
+      if (res.datas.subtitle == undefined) {
+        res.datas.subtitle = "";
+      }
+      let title = res.datas.subtitle + this.data.bookName
+      wx.setNavigationBarTitle({
+        title: title
+      });
     })
   },
   //涔﹀睍璇︽儏鎺ュ彛
-  getBookExhibitionDetails(passId) {
+  getBookExhibitionDetails() {
     app.MG.store.getProductList({
       path: '*',
       storeInfo: 'jsek_bookFair',
-      mainProductId: passId,
+      mainProductId: this.data.passId,
       queryType: 'Related', // 鏌ヨ绫诲瀷锛� Related锛氭煡璇㈠叧鑱斿晢鍝侊紱SubProduct: 鏌ヨ瀛愬晢鍝侊紱
+      paging: {
+        start: 0,
+        size: this.data.start * 6
+      },
       fields: {
         author: [],
         publicationDate: [],
@@ -118,19 +162,42 @@
         Creator: []
       }
     }).then(res => {
-
       this.setData({
-        bookExhibitionList: res.datas
+        bookExhibitionList: res.datas,
+        totalSize: res.total,
+        loading: false,
+        hidden: false,
       })
-      console.log(this.data.bookExhibitionList, 88888);
     })
   },
   onBookDetails(event) {
     const item = event.currentTarget.dataset.item;
     console.log(item, 'item');
-    // wx.navigateTo({
-    //   url: '/pages/bookExhibitionDetails/index?id?name=' + item.id + item.name // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟
-    // });
-  }
+    wx.navigateTo({
+      url: '/packageBookService/pages/bookServices/detail/index?id=' + item.id + '&name=' + item.name
+    });
+  },
+  goBack() {
+    wx.navigateBack();
+  },
+  // 瑙﹀簳鍑芥暟
+  onReachBottom() {
+    if (this.data.bookExhibitionList.length < this.data.totalSize) {
+      this.setData({
+        isMore: true,
+        start: this.data.start + 1
+      })
+      this.getBookExhibitionDetails()
+    } else {
+      this.setData({
+        isMore: true,
+      })
+      setTimeout(() => {
+        this.setData({
+          isMore: false
+        })
+      }, 300)
+    }
+  },
 
 })
\ No newline at end of file

--
Gitblit v1.9.1