yiming
2024-04-19 338ad19ee45b5380a0d8433cbbce2a727a576dfa
pages/bookExhibitionList/index.js
@@ -8,22 +8,6 @@
   * 页面的初始数据
   */
  data: {
    product: {
      value: 'all',
      options: [{
          value: 'all',
          label: '全部产品',
        },
        {
          value: 'new',
          label: '最新产品',
        },
        {
          value: 'hot',
          label: '最火产品',
        },
      ],
    },
    loading: true,
    hidden: true,
    totalSize: '',
@@ -45,32 +29,32 @@
    sorter: {
      value: 'default',
    },
    // product: {
    //   value: '*',
    //   options: [{
    //       value: '*',
    //       label: '总分类',
    //     },
    //     {
    //       value: 'jsek_bFHigherEducation',
    //       //重点项目
    //       price: 'jsek_higherEducation',
    //       label: '高等教育',
    //     },
    //     {
    //       value: 'jsek_bFVocationalEducation',
    //       //重点项目
    //       price: 'jsek_vocationalEducation',
    //       label: '职业教育',
    //     },
    //     {
    //       value: 'jsek_bFTeacherEducation',
    //       //重点项目
    //       price: 'jsek_teacherEducation',
    //       label: '教师教育',
    //     },
    //   ],
    // },
    product: {
      value: '*',
      options: [{
          value: '*',
          label: '总分类',
        },
        {
          value: 'jsek_bFHigherEducation',
          //重点项目
          price: 'jsek_higherEducation',
          label: '高等教育',
        },
        {
          value: 'jsek_bFVocationalEducation',
          //重点项目
          price: 'jsek_vocationalEducation',
          label: '职业教育',
        },
        {
          value: 'jsek_bFTeacherEducation',
          //重点项目
          price: 'jsek_teacherEducation',
          label: '教师教育',
        },
      ],
    },
    multipleSelect: {
      value: [],
      options: [],
@@ -107,8 +91,7 @@
   */
  onLoad(options) {
    console.log(this.data.keynoteDisabled, 'keynoteDisabled');
    // console.log(this.data.filteredItems, 88888);
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
@@ -125,7 +108,7 @@
    }))
    if (this.data.filteredItems = []) {
      console.log(11111);
      // singleSelectOptions.push({
      //   label: '暂无数据',
      //   value: 'disabled',
@@ -139,7 +122,7 @@
    console.log(this.data.bookExhibitionList.length, 'this.data.bookExhibitionList.length');
    // 更新数据
    this.setData({
      'multipleSelect.options': singleSelectOptions,
@@ -191,9 +174,7 @@
  // },
  onScrollToLower() {
    console.log(789);
    console.log(this.data.bookExhibitionList.length);
    console.log(this.data.totalSize);
    if (this.data.bookExhibitionList.length < this.data.totalSize) {
      this.setData({
        isMore: true,
@@ -208,7 +189,7 @@
        this.setData({
          isMore: false
        })
        console.log('300');
      }, 300)
    }
  },
@@ -216,10 +197,9 @@
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    // console.log(this.data.page.size);
    // console.log(this.data.total);
    if (this.data.page.size >= this.data.total) {
      console.log('已加载完所有数据');
      Toast({
        context: this,
        selector: '#t-toast',
@@ -260,7 +240,7 @@
      'Name*': this.data.keyword,
      '||subtitle*': this.data.keyword
    }
    // console.log(this.data.keynoteValue);
    let sort = {};
    const sortOptions = {
@@ -283,7 +263,7 @@
    sort = sortOptions[this.data.product.value] || {};
    console.log(sort);
    app.MG.store.getProductList({
      storeInfo: 'jsek_bookFair',
@@ -310,11 +290,11 @@
        }
        item.subtitleName = item.subtitle + item.name
      })
      console.log(res, 'item');
      this.data.total = res.total
      // list.push(res.datas)
      console.log(res.datas.length);
      if (res.datas.length == 0) {
@@ -324,18 +304,17 @@
      }
      const list = [...res.datas]
      console.log(res);
      this.setData({
        bookExhibitionList: list,
        totalSize: res.total
      })
      // 判断数据长度
      console.log(list.length, 'list.length');
      //取消
      wx.hideLoading()
      // console.log(this.data.bookExhibitionList, '数据');
      this.setData({
        loading: false,
@@ -351,7 +330,7 @@
      loading: true,
      hidden: true,
    })
    // console.log(newPrice, 'newPrice');
    let parms = {
      refCodes: ['bookClassification']
    }
@@ -362,7 +341,7 @@
          this.setData({
            filteredItems: item.child || [] // 如果存在子项则赋值,否则赋值为空数组
          });
          // console.log(this.data.filteredItems);
        }
      })
@@ -376,52 +355,57 @@
  },
  // 总分类
  // 总分类
  onChange(e) {
    console.log(e);
    this.data.page.size = 16 //更改显示的值
    const newValue = e.detail.value;
    const selectedOption = this.data.product.options.find(option => option.value === newValue);
    const newPrice = selectedOption ? selectedOption.price : null;
    // const bookExhibitionListsubsidiary = []
    // this.setData({
    //   bookExhibitionListsubsidiary: this.data.bookExhibitionList
    // })
    if (newPrice) {
      this.setData({
        keynoteDisabled: false
      })
    }
    if (!newPrice) {
      this.setData({
        keynoteDisabled: true
      })
    }
    this.setData({
      'product.value': newValue,
      'product.price': newPrice, // 将选中的 price 值保存在数据中
    });
    this.bookExhibitionGet(newValue);
    this.keyProjectsGet(newPrice);
    // 调用更新页面数据的函数,传入新的 value 和 price 值
    if (this.data.keynoteValue) {
      //如果有数据就清空并刷新页面
      this.data.keynoteValue = []
      this.bookExhibitionGet(newValue)
      this.onLoad()
    }
    // e.stopImmediatePropagation()
  },
  // 总分类
  // 总分类
  // onChange(e) {
  //   this.data.page.size = 16 //更改显示的值
  //   const newValue = e.detail.value;
  //   const selectedOption = this.data.product.options.find(option => option.value === newValue);
  //   const newPrice = selectedOption ? selectedOption.price : null;
  //   const bookExhibitionListsubsidiary = []
  //   this.setData({
  //     bookExhibitionListsubsidiary: this.data.bookExhibitionList
  //   })
  //   console.log(bookExhibitionListsubsidiary, 'bookExhibitionListsubsidiary');
  //   console.log(newValue, 'newValue');
  //   console.log(newPrice, 'newPrice');
  //   if (newPrice) {
  //     this.setData({
  //       keynoteDisabled: false
  //     })
  //   }
  //   if (!newPrice) {
  //     this.setData({
  //       keynoteDisabled: true
  //     })
  //   }
  //   console.log(newValue);
  //   this.setData({
  //     'product.value': newValue,
  //     'product.price': newPrice, // 将选中的 price 值保存在数据中
  //   });
  //   this.bookExhibitionGet(newValue);
  //   this.keyProjectsGet(newPrice);
  //   // 调用更新页面数据的函数,传入新的 value 和 price 值
  //   if (this.data.keynoteValue) {
  //     //如果有数据就清空并刷新页面
  //     this.data.keynoteValue = []
  //     this.bookExhibitionGet(newValue)
  //     this.onLoad()
  //   }
  // },
  // 重点项目
  handleMultipleSelect(e) {
@@ -430,15 +414,12 @@
    });
  },
  handleConfirm(event) {
    const {
      value
    } = event.detail;
    // 确认操作的处理逻辑
    console.log('确认操作,选中的值为:', value);
    this.data.keynoteValue = value
    this.bookExhibitionGet()
  },
@@ -470,13 +451,12 @@
  },
  onSwapLeft() {
    this.data.nameSort = 'Desc'
    // console.log('sssssss');
    this.bookExhibitionGet()
  },
  onBookExhibitionDetails: function (event) {
    console.log(456);
    const item = event.currentTarget.dataset.item;
    console.log(item);
    wx.navigateTo({
      url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name + '&subtitleName=' + item.subtitleName // 假设跳转到详情页面,并传递了id参数
    });
@@ -487,7 +467,7 @@
    this.setData({
      keyword: e.detail.value
    })
    console.log(this.data.keyword, 'keyword');
    this.bookExhibitionGet()
  },
  goBack() {
@@ -497,10 +477,10 @@
    this.setData({
      'product.value': e.detail.value,
    });
    console.log(e.detail.value, 'e.detail.value');
    this.bookExhibitionGet()
  },
  onTest() {
    console.log(7555);
  onOpend() {
  }
})