litian
2024-03-12 b125d3ea74d61fb8e4d7238c83906aeea52c6b4c
pages/bookExhibitionList/index.js
@@ -8,6 +8,8 @@
   * 页面的初始数据
   */
  data: {
    value: '',
    keyword: '',
    nameSort: null,
    total: null,
    page: {
@@ -17,7 +19,6 @@
    keynoteValue: null,
    filteredItems: [],
    newValue: null,
    value: '',
    bookExhibitionList: [],
    sorter: {
      value: 'default',
@@ -55,9 +56,55 @@
      value: [],
      options: [],
    },
    navBarHeight: '',
    barHeight: ''
  },
  /**
    * 生命周期函数--监听页面加载
    */
  onLoad(options) {
    // console.log(this.data.filteredItems, 88888);
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    this.setData({
      navBarHeight: navBarHeight,
      barHeight: systInfo.statusBarHeight,
    })
    // 单列选择器选项
    const singleSelectOptions = this.data.filteredItems.map(item => ({
      label: item.name,
      value: item.value,
      disabled: false,
    }))
    if (this.data.filteredItems = []) {
      console.log(11111);
      singleSelectOptions.push({
        label: '禁用选项',
        value: 'disabled',
        disabled: true,
      });
    }
    // singleSelectOptions.push({
    //   label: '禁用选项',
    //   value: 'disabled',
    //   disabled: true,
    // });
    // 更新数据
    this.setData({
      'multipleSelect.options': singleSelectOptions,
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
@@ -138,7 +185,10 @@
    wx.showLoading({
      title: '加载中...',
    })
    let searchObj = {
      'Name*': this.data.keyword,
      '||subtitle*': this.data.keyword
    }
    // console.log(this.data.keynoteValue);
    let sort = {
      Name: this.data.nameSort || 'Desc'
@@ -149,7 +199,8 @@
      queryType: '*',
      fields: {
        jsek_link: [],
        'bookClassification*': this.data.keynoteValue || []
        'bookClassification*': this.data.keynoteValue || [],
        ...searchObj
      },
      paging: this.data.page,
      sort: sort,
@@ -166,6 +217,7 @@
      this.setData({
        bookExhibitionList: list
      })
      //取消
      wx.hideLoading()
      // console.log(this.data.bookExhibitionList, '数据');
@@ -200,41 +252,6 @@
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // console.log(this.data.filteredItems, 88888);
    // 单列选择器选项
    const singleSelectOptions = this.data.filteredItems.map(item => ({
      label: item.name,
      value: item.value,
      disabled: false,
    }))
    if (this.data.filteredItems = []) {
      console.log(11111);
      singleSelectOptions.push({
        label: '禁用选项',
        value: 'disabled',
        disabled: true,
      });
    }
    // singleSelectOptions.push({
    //   label: '禁用选项',
    //   value: 'disabled',
    //   disabled: true,
    // });
    // 更新数据
    this.setData({
      'multipleSelect.options': singleSelectOptions,
    });
  },
  // 总分类
@@ -290,19 +307,49 @@
  },
  onSwapRight() {
    // console.log('xxxxxx');
    this.data.nameSort = 'Asc'
    // this.data.nameSort = 'Asc'
    if (!this.data.nameSort) {
      this.setData({
        nameSort: 'Desc',
      });
    } else if (this.data.nameSort == 'Desc') {
      this.setData({
        nameSort: 'Asc',
      });
    } else if (this.data.nameSort == 'Asc') {
      this.setData({
        nameSort: '',
      });
    }
    this.bookExhibitionGet()
  },
  onSwapLeft() {
    this.data.nameSort = 'Desc'
    // console.log('sssssss');
    this.bookExhibitionGet()
  },
  onBookExhibitionDetails: function (event) {
    const item = event.currentTarget.dataset.item;
    console.log(item);
    wx.navigateTo({
      url: '/pages/bookExhibitionDetails/index?id=' + item.id // 假设跳转到详情页面,并传递了id参数
      url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name // 假设跳转到详情页面,并传递了id参数
    });
  }
  },
  // 搜索框
  onSearchSubmit(e) {
    this.setData({
      keyword: e.detail.value
    })
    console.log(this.data.keyword, 'keyword');
    this.bookExhibitionGet()
  },
  goBack() {
    wx.navigateBack();
  },
})