闫增涛
2024-04-02 aef06b129be7a3a12ac097db8e372b0cb33c6c42
packageBookService/pages/bookServices/list/index.js
@@ -39,24 +39,24 @@
      options: [],
    },
    sortList: {
      value: '',
      value: 'default',
      options: [{
          value: '',
          label: '综合排序',
          value: 'default',
          label: '默认排序',
        }, {
          value: '1',
          value: 'name-asc',
          label: '名称正序'
        },
        {
          value: '2',
          value: 'name-desc',
          label: '名称倒叙'
        },
        {
          value: '3',
          value: 'time-asc',
          label: '出版时间正序'
        },
        {
          value: '3',
          value: 'time-desc',
          label: '出版时间倒叙'
        }
      ],
@@ -262,6 +262,15 @@
      },
    };
    app.MG.store.getStoreChannelList(query).then((res) => {
      if (!res.datas.length) {
        this.setData({
          disabledSecondList: true
        })
      } else {
        this.setData({
          disabledSecondList: false
        })
      }
      for (let index = 0; index < res.datas.length; index++) {
        const item = res.datas[index];
        options.push({
@@ -359,17 +368,43 @@
        queryType: '*',
      };
    }
    if (this.data.sort) {
    if (this.data.sortList.value == 'name-asc') {
      sort = {
        Name: this.data.sort,
        BaseType: '',
      };
    } else {
        Name: 'Asc',
        BaseType: ''
      }
    } else if (this.data.sortList.value == 'name-desc') {
      sort = {
        type: 'Desc',
        field: 'ViewCount',
      };
        Name: 'Desc',
        BaseType: ''
      }
    } else if (this.data.sortList.value == 'time-asc') {
      sort = {
        PublicationDate: 'Asc',
        BaseType: 'DateTime'
      }
    } else if (this.data.sortList.value == 'time-desc') {
      sort = {
        PublicationDate: 'Desc',
        BaseType: 'DateTime'
      }
    } else if (this.data.sortList.value == 'default') {
      sort = {
        field: 'order',
        type: 'Desc'
      }
    }
    // if (this.data.sort) {
    //   sort = {
    //     Name: this.data.sort,
    //     BaseType: '',
    //   };
    // } else {
    //   sort = {
    //     type: 'Desc',
    //     field: 'ViewCount',
    //   };
    // }
    // 搜索
    let searchObj = {};
    if (this.data.searchValue) {
@@ -411,16 +446,6 @@
        this.setData({
          noData: true,
        })
        if (!this.data.pathList.length) {
          // 未选择二级分类,且无图书
          this.setData({
            disabledSecondList: true
          })
        } else {
          this.setData({
            disabledSecondList: false
          })
        }
      }
      if (this.data.triggered) {
        this.setData({
@@ -438,6 +463,7 @@
      `${this.data.assortCheck.code}\\${e.detail.value}` :
      this.data.assortCheck.code;
    console.log(this.data.path);
    this.setData({
      pathList: [],
      stairCode: e.detail.value,
@@ -445,17 +471,15 @@
      path: path,
      'stairList.value': e.detail.value,
    });
    this.getBookList(path);
    this.getSecondList(path);
    if (e.detail.value == '') {
      this.setData({
        disabledSecondList: true
      })
      });
    } else {
      this.setData({
        disabledSecondList: false
      })
      this.getSecondList(path);
    }
    this.getBookList(path);
    console.log(this.data.disabledSecondList);
  },
  // 二级分类切换
@@ -497,6 +521,19 @@
    this.setData({
      'sortList.value': e.detail.value
    })
    let path;
    if (this.data.secondCode) {
      path = this.data.secondCode;
    } else if (this.data.stairCode) {
      path = `${this.data.assortCheck.code}\\${this.data.stairCode}`;
    } else {
      path = this.data.assortCheck.code;
    }
    this.setData({
      path: path,
    });
    this.getBookList(path);
  },
  changeNewText(e) {
    this.setData({
@@ -511,33 +548,33 @@
    this.getBookList(this.data.path);
  },
  // 排序按钮
  sortClick() {
    if (!this.data.sort.length) {
      this.setData({
        sort: 'Desc',
      });
    } else if (this.data.sort == 'Desc') {
      this.setData({
        sort: 'Asc',
      });
    } else if (this.data.sort == 'Asc') {
      this.setData({
        sort: '',
      });
    }
    let path;
    if (this.data.secondCode) {
      path = this.data.secondCode;
    } else if (this.data.stairCode) {
      path = `${this.data.assortCheck.code}\\${this.data.stairCode}`;
    } else {
      path = this.data.assortCheck.code;
    }
    this.setData({
      path: path,
    });
    this.getBookList(path);
  },
  // sortClick() {
  //   if (!this.data.sort.length) {
  //     this.setData({
  //       sort: 'Desc',
  //     });
  //   } else if (this.data.sort == 'Desc') {
  //     this.setData({
  //       sort: 'Asc',
  //     });
  //   } else if (this.data.sort == 'Asc') {
  //     this.setData({
  //       sort: '',
  //     });
  //   }
  //   let path;
  //   if (this.data.secondCode) {
  //     path = this.data.secondCode;
  //   } else if (this.data.stairCode) {
  //     path = `${this.data.assortCheck.code}\\${this.data.stairCode}`;
  //   } else {
  //     path = this.data.assortCheck.code;
  //   }
  //   this.setData({
  //     path: path,
  //   });
  //   this.getBookList(path);
  // },
  // 搜索图书
  searchBook(e) {
    console.log(e.detail.value);