闫增涛
2024-04-26 960c49a8b3ac11dff27cad71137f986f90f00923
packageDomain/pages/sampleBookList/index.js
@@ -152,14 +152,17 @@
          // 获取申请次数
          that.getSelectPaperBookCount()
          that.getSelectBookCount()
        }
      })
    } else {
      that.setData({
        userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
      })
      const paperBookList = wx.getStorageSync('paperBookList') ? JSON.parse(wx.getStorageSync('paperBookList')).length : 0
      const electronicBookList = wx.getStorageSync('electronicBookList') ? JSON.parse(wx.getStorageSync('electronicBookList')).length : 0
      this.setData({
        num: paperBookList + electronicBookList
      })
    }
  },
@@ -422,6 +425,8 @@
        author: [],
        isbn: [],
        publicationDate: [],
        pdf: [],
        protectedEpub: [],
        isApplyBook: [],
        'isApplyBook>': ['1'],
        ...searchObj,
@@ -493,14 +498,10 @@
            bottomLoading: false,
            isMoreData: list.length > 0 ? false : true,
            skeletonLoding: false,
            loading: false
          })
        } else {
          that.setData({
            bookList: [],
            pageTotalCount: 0,
            skeletonLoding: false,
            loading: false
          })
        }
      } catch (error) {
@@ -511,11 +512,14 @@
  //高级分类选择
  onChangeIcon(e) {
    this.setData({
      skeletonLoding: true,
      bookList: [],
      'assortCheck.code': e.detail.value,
      stairCode: '',
      secondCode: '',
      path: `${e.detail.value}`,
      'iconList.value': e.detail.value,
    });
    this.getBookList(false);
    this.getStairList(this.data.assortCheck.code);
@@ -527,17 +531,20 @@
      `${this.data.assortCheck.code}\\${e.detail.value}` :
      this.data.assortCheck.code;
    this.setData({
      skeletonLoding: true,
      bookList: [],
      pathList: [],
      stairCode: e.detail.value,
      secondCode: '',
      path: path,
      'stairList.value': e.detail.value,
      'secondList.value': ""
    });
    this.getBookList(false);
    this.getSecondList(path);
  },
  // 二级分类切换
  onChangeSecond(e) {
  // 二级分类切换
  onConfirmSecond(e) {
    const pathList = [];
    for (let index = 0; index < e.detail.value.length; index++) {
      const element = e.detail.value[index];
@@ -548,13 +555,10 @@
      });
    }
    this.setData({
      skeletonLoding: true,
      pathList: pathList,
      'secondList.value': e.detail.value,
    });
  },
  //
  onConfirmSecond() {
    this.getBookList(false);
  },
  onResetSecond() {
@@ -783,7 +787,7 @@
  },
  //选择电子样书
  onChangeElectron(e) {
  async onChangeElectron(e) {
    const item = e.currentTarget.dataset.book;
    const index = this.data.bookList.findIndex(citem => citem.id == item.id)
    let role = this.data.userInfo != null ? this.data.userInfo.role : null
@@ -791,6 +795,44 @@
      // 是教师
      if (e.detail.checked) {
        // 点击选中
        //商品有无电子书
        const obj = {
          path: '*',
          queryType: 'SubProduct',
          sort: {
            type: 'Desc',
            field: 'CreateDate'
          },
          paging: {
            start: 0,
            size: 1
          },
          mainProductId: item.id,
          fields: {
            bookshelf_pdf: [],
            bookshelf_protectedEpub: [],
          }
        }
        const res = await app.MG.store.getProductList(obj)
        if (res.datas.length > 0) {
          if (!res.datas[0].bookshelf_pdf && !res.datas[0].bookshelf_protectedEpub) {
            wx.showToast({
              title: "暂无电子书文件,请联系管理员!",
              icon: 'none',
              duration: 1000,
            })
            return false;
          }
        } else {
          if (!item.pdf && !item.protectedEpub) {
            wx.showToast({
              title: "暂无电子书文件,请联系管理员!",
              icon: 'none',
              duration: 1000,
            })
            return false;
          }
        }
        if (this.data.ebookCount == 0) {
          wx.showToast({
            title: "您的电子样书申请次数已用尽,若要继续,请联系管理员!",