yiming
2024-04-25 103db27cd0ca6b3305e95170dc297380f97fcc70
pages/bookExhibitionDetails/index.js
@@ -6,12 +6,21 @@
   * 页面的初始数据
   */
  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: '',
    subtitleName: '',
    totalSize: '',
    passId: '',
    isMore: null,
  },
  /**
@@ -19,10 +28,31 @@
   */
  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,
    })
    console.log();
    this.setData({
      bookName: options.bookName,
      subtitleName: options.subtitleName,
      passId: options.id
    })
    const passId = options.id
    this.bookExhibitionGet(passId)
    this.getBookExhibitionDetails(passId)
    this.getBookExhibitionDetails()
    wx.setNavigationBarTitle({
      title: this.data.subtitleName
    });
  },
  /**
@@ -75,6 +105,10 @@
  },
  bookExhibitionGet(passId) {
    this.setData({
      loading: true,
      hidden: true,
    })
    wx.showLoading({
      title: '加载中...',
    })
@@ -101,15 +135,24 @@
        bookImage: res.datas.icon
      });
      wx.hideLoading()
      this.setData({
        loading: false,
        hidden: false,
      })
    })
  },
  //书展详情接口
  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: [],
@@ -120,17 +163,48 @@
    }).then(res => {
      this.setData({
        bookExhibitionList: res.datas
        bookExhibitionList: res.datas,
        totalSize: res.total
      })
      console.log(this.data.bookExhibitionList, 88888);
      this.setData({
        loading: false,
        hidden: false,
      })
    })
  },
  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() {
    console.log(this.data.bookExhibitionList.length);
    console.log(this.data.totalSize);
    if (this.data.bookExhibitionList.length < this.data.totalSize) {
      console.log(11111);
      this.setData({
        isMore: true,
        start: this.data.start + 1
      })
      this.getBookExhibitionDetails()
    } else {
      this.setData({
        isMore: true,
      })
      setTimeout(() => {
        this.setData({
          isMore: false
        })
        console.log('300');
      }, 300)
    }
  },
})