packageBookService/pages/bookServices/list/index.js
@@ -32,10 +32,34 @@
    secondList: {
      value: [],
      options: [],
      disabled: false,
    },
    majorProjectList: {
      value: [],
      options: [],
    },
    sortList: {
      value: '',
      options: [{
          value: '',
          label: '综合排序',
        }, {
          value: '1',
          label: '名称正序'
        },
        {
          value: '2',
          label: '名称倒叙'
        },
        {
          value: '3',
          label: '出版时间正序'
        },
        {
          value: '3',
          label: '出版时间倒叙'
        }
      ],
    },
    newTextBook: {
      value: [],
@@ -49,13 +73,19 @@
      size: '50rpx'
    },
    loading: false,
    noData: false
    noData: false,
    showDropdown: false,
    isRequesting: false,
    disabledStair: false,
    disabledSecondList: false,
    disabledProject: false,
    disabledNewForms: false,
    triggered: false,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options)
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
@@ -132,7 +162,13 @@
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
    console.log('下拉');
    this.setData({
      triggered: true
    })
    this.setData({
      'pageCount.page': 1
    })
    this.getBookList(this.data.path);
  },
  /**
@@ -141,11 +177,13 @@
  onReachBottom(e) {
    const flag = this.data.bookList.length < this.data.pageCount.total
    if (flag) {
      this.setData({
        isMore: true,
        "pageCount.page": this.data.pageCount.page + 1
      })
      this.getBookList(this.data.path)
      if (!this.data.isRequesting) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.getBookList(this.data.path)
      }
    } else {
      this.setData({
        isMore: true,
@@ -168,6 +206,9 @@
  },
  // 获取一级列表
  getStairList(path) {
    this.setData({
      disabledStair: false
    })
    const query = {
      path,
      filterList: [],
@@ -197,6 +238,11 @@
        'stairList.options': options,
        'stairList.value': this.data.stairCode,
      });
      if (!options.length) {
        this.setData({
          disabledStair: true
        })
      }
    });
  },
  // 获取一级分类下二级分类
@@ -234,6 +280,10 @@
  },
  // 获取重点项目
  getProjectList(type) {
    this.setData({
      disabledProject: false,
      disabledNewForms: false
    })
    const options = [];
    const arr = [];
    let array = [];
@@ -241,7 +291,7 @@
      refCodes: [type],
    };
    app.MG.store.getProductTypeField(query).then((res) => {
      array = JSON.parse(res[0].config).option;
      array = JSON.parse(res[0].config).option.filter(item => item.value == this.data.assortCheck.code);
      for (let index = 0; index < array.length; index++) {
        const element = array[index];
        if (element.child) {
@@ -259,6 +309,11 @@
            label: element.name,
          });
        }
        if (!options.length) {
          this.setData({
            disabledProject: true
          })
        }
        this.setData({
          'majorProjectList.options': options,
        });
@@ -270,6 +325,11 @@
            label: element.name,
          });
        }
        if (!options.length) {
          this.setData({
            disabledNewForms: true
          })
        }
        this.setData({
          'newTextBook.options': options,
        });
@@ -279,9 +339,13 @@
  },
  // 获取图书列表
  getBookList(path) {
    if (this.data.isRequesting) {
      return false;
    }
    this.setData({
      loading: true,
      noData: false
      noData: false,
      isRequesting: true
    })
    let sort;
    let pathObj = {};
@@ -340,12 +404,30 @@
        bookList: res.datas,
        enable: false,
        "pageCount.total": res.total,
        loading: false
        loading: false,
        isRequesting: false
      });
      console.log('图书列表', res.datas);
      if (!res.datas.length) {
        this.setData({
          noData: true
          noData: true,
        })
        if (!this.data.pathList.length) {
          // 未选择二级分类,且无图书
          this.setData({
            disabledSecondList: true
          })
        } else {
          this.setData({
            disabledSecondList: false
          })
        }
      }
      if (this.data.triggered) {
        this.setData({
          triggered: false
        })
        wx.showToast({
          title: '刷新成功',
        })
      }
    });
@@ -355,6 +437,7 @@
    const path = e.detail.value.length ?
      `${this.data.assortCheck.code}\\${e.detail.value}` :
      this.data.assortCheck.code;
    console.log(this.data.path);
    this.setData({
      pathList: [],
      stairCode: e.detail.value,
@@ -364,6 +447,16 @@
    });
    this.getBookList(path);
    this.getSecondList(path);
    if (e.detail.value == '') {
      this.setData({
        disabledSecondList: true
      })
    } else {
      this.setData({
        disabledSecondList: false
      })
    }
    console.log(this.data.disabledSecondList);
  },
  // 二级分类切换
  onChangeSecond(e) {
@@ -398,6 +491,12 @@
      'majorProjectList.value': [],
    });
    this.getBookList(this.data.path);
  },
  // 排序切换
  onSortChange(e) {
    this.setData({
      'sortList.value': e.detail.value
    })
  },
  changeNewText(e) {
    this.setData({
@@ -462,4 +561,16 @@
    });
    this.getBookList(this.data.path)
  },
  openDropdown() {
    console.log('展开哦', );
    this.setData({
      showDropdown: true
    })
  },
  closeDropdown() {
    console.log('关闭');
    this.setData({
      showDropdown: false
    })
  }
});