yiming
2024-03-26 c5864be56488bee0c767d4b1cf157db4a0ec33c3
pages/bookExhibitionList/index.js
@@ -8,6 +8,9 @@
   * 页面的初始数据
   */
  data: {
    keynoteDisabled: true,
    value: '',
    keyword: '',
    nameSort: null,
    total: null,
    page: {
@@ -17,7 +20,6 @@
    keynoteValue: null,
    filteredItems: [],
    newValue: null,
    value: '',
    bookExhibitionList: [],
    sorter: {
      value: 'default',
@@ -28,7 +30,6 @@
      options: [
        {
          value: '*',
          label: '总分类',
        },
        {
@@ -55,9 +56,57 @@
      value: [],
      options: [],
    },
    navBarHeight: '',
    barHeight: '',
    windowHeight: '',
  },
  /**
    * 生命周期函数--监听页面加载
    */
  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,
      // });
    } else {
      console.log(7889);
    }
    // 更新数据
    this.setData({
      'multipleSelect.options': singleSelectOptions,
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
@@ -95,7 +144,10 @@
  onPullDownRefresh() {
  },
  onPullDownRefresh() {
    this.data.page.size = 16 //更改显示的值
    this.bookExhibitionGet(); // 调用方法加载更多数据
  },
  /**
   * 页面上拉触底事件的处理函数
   */
@@ -121,7 +173,9 @@
        'page.size': newSize
      });
      this.bookExhibitionGet(); // 调用方法加载更多数据
      console.log(1111);
    }
  },
@@ -138,7 +192,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 +206,9 @@
      queryType: '*',
      fields: {
        jsek_link: [],
        'bookClassification*': this.data.keynoteValue || []
        subtitle: [],
        'bookClassification*': this.data.keynoteValue || [],
        ...searchObj
      },
      paging: this.data.page,
      sort: sort,
@@ -157,7 +216,10 @@
      //   width: 100
      // },
    }).then(res => {
      res.datas.forEach((item) => {
        item.subtitleName = item.subtitle + item.name
      })
      console.log(res, 'item');
      this.data.total = res.total
      //  list.push(res.datas)
@@ -166,6 +228,7 @@
      this.setData({
        bookExhibitionList: list
      })
      //取消
      wx.hideLoading()
      // console.log(this.data.bookExhibitionList, '数据');
@@ -200,41 +263,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,
    });
  },
  // 总分类
@@ -245,6 +273,18 @@
    const newValue = e.detail.value;
    const selectedOption = this.data.product.options.find(option => option.value === newValue);
    const newPrice = selectedOption ? selectedOption.price : null;
    console.log(newValue, 'newValue');
    console.log(newPrice, 'newPrice');
    if (newPrice) {
      this.setData({
        keynoteDisabled: false
      })
    } else {
      this.setData({
        keynoteDisabled: true
      })
    }
    this.setData({
      'product.value': newValue,
      'product.price': newPrice, // 将选中的 price 值保存在数据中
@@ -260,10 +300,6 @@
      this.bookExhibitionGet(newValue)
      this.onLoad()
      console.log('true');
    } else {
      // this.bookExhibitionGet(newValue);
      // this.keyProjectsGet(newPrice);
      console.log('fals');
    }
  },
@@ -273,8 +309,10 @@
    this.setData({
      'multipleSelect.value': e.detail.value,
    });
  },
  handleConfirm(event) {
    const { value } = event.detail;
    // 确认操作的处理逻辑
@@ -283,6 +321,7 @@
    this.bookExhibitionGet()
  },
  handleReset() {
    // 重置操作的处理逻辑
    this.data.keynoteValue = []
    console.log('重置操作');
@@ -290,8 +329,25 @@
  },
  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'
@@ -302,7 +358,18 @@
    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 + '&subtitleName=' + item.subtitleName // 假设跳转到详情页面,并传递了id参数
    });
  }
  },
  // 搜索框
  onSearchSubmit(e) {
    this.setData({
      keyword: e.detail.value
    })
    console.log(this.data.keyword, 'keyword');
    this.bookExhibitionGet()
  },
  goBack() {
    wx.navigateBack();
  },
})