闫增涛
2025-01-22 2aaa9e8dc8bf91849110347fc772773a8bceb325
packageBookService/pages/bookServices/list/index.js
@@ -131,7 +131,7 @@
    // 获取二级分类
    this.getSecondList(`${options.assortCode}\\${options.stairCode}`);
    this.getBookList(`${options.assortCode}\\${options.stairCode}`);
    // 获取重点项目
    // 获取获奖情况
    this.getProjectList("bookClassification");
    this.getProjectList("newFormsTextbooks");
  },
@@ -200,6 +200,7 @@
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
  onShareTimeline() {},
  goBack() {
    wx.navigateBack();
  },
@@ -245,7 +246,7 @@
    });
  },
  // 获取一级分类下二级分类
  getSecondList(path) {
  async getSecondList(path) {
    const options = [];
    const query = {
      path,
@@ -260,16 +261,7 @@
        field: "LinkOrder",
      },
    };
    app.MG.store.getStoreChannelList(query).then((res) => {
      if (!res.datas.length) {
        this.setData({
          disabledSecondList: true,
        });
      } else {
        this.setData({
          disabledSecondList: false,
        });
      }
    await app.MG.store.getStoreChannelList(query).then((res) => {
      for (let index = 0; index < res.datas.length; index++) {
        const item = res.datas[index];
        options.push({
@@ -281,12 +273,13 @@
        "secondList.options": options,
      });
      const second = [this.data.secondCode];
      console.log(second);
      this.setData({
        "secondList.value": second,
      });
    });
  },
  // 获取重点项目
  // 获取获奖情况
  getProjectList(type) {
    this.setData({
      disabledProject: false,
@@ -343,7 +336,7 @@
        this.setData({
          "newTextBook.options": options,
        });
        console.log("重点项目", this.data.newTextBook);
        console.log("获奖情况", this.data.newTextBook);
      }
    });
  },
@@ -419,6 +412,7 @@
        "||author*": this.data.searchValue,
        "||isbn*": this.data.searchValue,
        "||seriesName*": this.data.searchValue,
        "||projectLeader*": this.data.searchValue
      };
    }
    const query = {
@@ -428,6 +422,9 @@
        field: "state",
      }, ],
      sort,
      coverSize: {
        width: 180
      },
      paging: {
        start: 0,
        size: this.data.pageCount.page * 8,
@@ -441,11 +438,6 @@
      },
    };
    app.MG.store.getProductList(query).then((res) => {
      if (!res.datas.length && !this.data.pathList.length) {
        this.setData({
          disabledSecondList: true
        })
      }
      this.setData({
        bookList: res.datas,
        isMore: null,
@@ -460,6 +452,18 @@
          noData: true,
        });
      }
      // 二级禁用逻辑
      // 1.一级分类未选中,二级分类禁用
      if (!this.data.stairList.value) {
        this.setData({
          disabledSecondList: true
        })
      } else if (this.data.stairList.value && !this.data.secondList.options.length) {
        // 2. 一级分类选中,无二级分类
        this.setData({
          disabledSecondList: true
        })
      }
      if (this.data.triggered) {
        this.setData({
          triggered: false,
@@ -471,7 +475,7 @@
    });
  },
  // 一级分类切换
  onChangeStair(e) {
  async onChangeStair(e) {
    const path = e.detail.value.length ?
      `${this.data.assortCheck.code}\\${e.detail.value}` :
      this.data.assortCheck.code;
@@ -482,19 +486,45 @@
      secondCode: "",
      path: path,
      "stairList.value": e.detail.value,
      disabledSecondList: false
      // disabledSecondList: false
    });
    if (e.detail.value == "") {
      this.setData({
        disabledSecondList: true,
      });
    } else {
      this.getSecondList(path);
    }
    this.getBookList(path);
    // if (e.detail.value == "") {
    //   this.setData({
    //     disabledSecondList: true,
    //   });
    // } else {
    await this.getSecondList(path);
    // }
    await this.getBookList(path);
  },
  // 二级分类切换
  onChangeSecond(e) {
  // // 二级分类切换
  // onChangeSecond(e) {
  //   const pathList = [];
  //   for (let index = 0; index < e.detail.value.length; index++) {
  //     const element = e.detail.value[index];
  //     pathList.push({
  //       Path: element,
  //       Type: "*",
  //       StoreRefCode: app.config.goodsStore,
  //     });
  //   }
  //   this.setData({
  //     backTop: "#assort-title",
  //     pathList: pathList,
  //     "secondList.value": e.detail.value,
  //   });
  // },
  // 二级分类重置
  resetSecond() {
    this.setData({
      backTop: "#assort-title",
      pathList: [],
      "secondList.value": [],
    });
    this.getBookList(this.data.path);
  },
  // 二级分类确定
  onConfirmSecond(e) {
    const pathList = [];
    for (let index = 0; index < e.detail.value.length; index++) {
      const element = e.detail.value[index];
@@ -509,12 +539,9 @@
      pathList: pathList,
      "secondList.value": e.detail.value,
    });
  },
  //
  onConfirmSecond() {
    this.getBookList(this.data.path);
  },
  // 重点项目改变
  // 获奖情况改变
  changeMajorProject(e) {
    this.setData({
      backTop: "#assort-title",
@@ -522,7 +549,7 @@
    });
    this.getBookList(this.data.path);
  },
  // 重点项目重置
  // 获奖情况重置
  resetMajorProject() {
    this.setData({
      "majorProjectList.value": [],