litian
2024-07-05 ea0592a7257ab7bb2036dabd8486d6a584d07704
pages/retrievalPage/index.js
@@ -11,13 +11,14 @@
   * 页面的初始数据
   */
  data: {
    loading: true,
    hidden: true,
    input: '',
    dialogKey: '',
    showWithInput: false,
    showTextAndTitleWithInput: false,
    downloadLoadin: false,
    isMore: null,
    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
    navBarHeight: '',
    barHeight: '',
    searchVal: '',
@@ -37,14 +38,14 @@
      page: 1,
      total: 0,
    },
    tabValue: ''
    tabValue: 0,
    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(app.config.appId);
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
@@ -54,17 +55,14 @@
      barHeight: systInfo.statusBarHeight,
      searchVal: options.searchVal
    })
    this.retrievalPageGet()
    this.bibliographyGet()
    let event = {
    let e = {
      detail: {
        value: "0"
      }
    }
    this.onTabsChange(event)
    this.onTabsChange(e)
  },
  /**
@@ -127,56 +125,22 @@
    this.bibliographyGet()
  },
  //标签的切换
  onTabsChange(event) {
    const value = event.detail.value
    // if (this.data.bookData <= 0 || this.data.courseData <= 0 || this.data.digitalTextbooksData <= 0 || this.data.seminarData <= 0 || this.data.biblioClassificationData <= 0 || this.data.bookFairData <= 0) {
    //   this.setData({
    //     isMore: true
    //   })
    // }
    if (value === '0') {
      this.setData({
        tabValue: value,
        isMore: false
      })
    this.setData({
      tabValue: value,
      isMore: false
    })
    } else if (value === '1') {
      console.log(value, 'tab');
      this.setData({
        tabValue: value,
        isMore: false
      })
    } else if (value === '2') {
      this.setData({
        tabValue: value,
        isMore: false
      })
    } else if (value === '3') {
      this.setData({
        tabValue: value,
        isMore: false
      })
    } else if (value === '4') {
      this.setData({
        tabValue: value,
        isMore: false
      })
    } else if (value === '5') {
      this.setData({
        tabValue: value,
        isMore: false
      })
    if (value === '4') {
      this.bibliographyGet()
    } else {
      this.retrievalPageGet()
    }
  },
  retrievalPageGet() {
    let fields = {
      liveTime: [],
      lecturer: [],
@@ -231,8 +195,6 @@
      ...searchObj,
      ...fields
    }
    let courseObj = {}
    if (this.data.searchVal) {
      courseObj = {
@@ -241,7 +203,6 @@
        '||isbn*': this.data.searchVal.trim(),
        '||seriesName*': this.data.searchVal.trim()
      }
    }
    //课程
    let queryCourse = {
@@ -424,7 +385,6 @@
      data: body
    }).then((resp) => {
      console.log(resp, 'resp');
      //图书       0
      const data1 = resp[0]
      const datas1 = handleQueryResourceListData({
@@ -434,12 +394,7 @@
      this.setData({
        bookData: datas1,
        bookTotal: data1.totalCount,
      })
      //数字课程    1
      const data2 = resp[1]
      const datas2 = handleQueryResourceListData({
@@ -450,9 +405,6 @@
        courseData: datas2,
        courseTotal: data2.totalCount
      })
      // 数字教材    2
      const data3 = resp[2]
      const datas3 = handleQueryResourceListData({
@@ -463,15 +415,12 @@
        digitalTextbooksData: datas3,
        digitalTextbooksTotal: data3.totalCount
      })
      // 专题研讨   3
      const data4 = resp[3]
      const datas4 = handleQueryResourceListData({
        datas: data4.datas,
        fields
      })
      this.setData({
        seminarData: datas4,
        seminarTotal: data4.totalCount
@@ -482,7 +431,6 @@
        datas: data5.datas,
        fields
      })
      datas5.forEach((items) => {
        items.subtitleName = items.subtitle + items.name
      })
@@ -491,15 +439,12 @@
        biblioClassificationData: datas5,
        biblioClassificationTotal: data5.totalCount
      })
      this.setData({
        loading: false,
        hidden: false,
      })
    })
    wx.stopPullDownRefresh()
  },
  bibliographyGet() {
    let bibliographyObj = {}
@@ -543,9 +488,7 @@
    wx.stopPullDownRefresh()
  },
  downloadData(event) {
    console.log(111);
    const item = event.currentTarget.dataset.item;
    // console.log(item.datas.freeFile.Value);
    const URL = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.datas.freeFile.Value
    item.determine = false
    console.log(URL, 'URL');
@@ -574,6 +517,10 @@
    });
  },
  onSearchSubmit() {
    this.setData({
      loading: true,
      hidden: true,
    })
    console.log(this.data.searchVal);
    this.retrievalPageGet()
    this.bibliographyGet()
@@ -602,6 +549,7 @@
   * 页面上拉触底事件的处理函数
   */
  onReachBottom(e) {
    console.log(this.data.tabValue);
    if (this.data.tabValue == 0) {
      console.log(0);
      if (this.data.bookData.length < this.data.bookTotal) {
@@ -714,17 +662,13 @@
            isMore: false
          })
        }, 100)
      }
    }
  },
  // 下拉函数
  onPullDownRefresh() {
    console.log(456);
    if (this.data.tabValue == 4) {
      this.setData({
        "pageCount.page": 1
@@ -750,7 +694,6 @@
    console.log(e);
    const key = e.currentTarget.dataset.key;
    const item = e.currentTarget.dataset.item;
    this.setData({
      [key]: true,
      dialogKey: key,
@@ -775,8 +718,6 @@
      this.setData({
        [dialogKey]: false
      });
      console.log(this.data.input);
      console.log(this.data.Md5);
      if (this.data.input) {
@@ -795,7 +736,6 @@
        icon: 'none',
      });
    }
  },
  // 弹窗取消
  closeDialog() {
@@ -807,6 +747,123 @@
    });
    console.log(111);
  },
  onScrollToLower() {
    if (this.data.tabValue == 0) {
      console.log(0);
      if (this.data.bookData.length < this.data.bookTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
    } else if (this.data.tabValue == 1) {
      if (this.data.courseData.length < this.data.courseTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(2);
    } else if (this.data.tabValue == 2) {
      if (this.data.digitalTextbooksData.length < this.data.digitalTextbooksTotal && this.data.digitalTextbooksData.length > 9) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(2);
    } else if (this.data.tabValue == 3) {
      if (this.data.seminarData.length < this.data.seminarTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(3);
    } else if (this.data.tabValue == 4) {
      if (this.data.bookFairData.length < this.data.bookFairTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.bibliographyGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(4);
    } else if (this.data.tabValue == 5) {
      if (this.data.biblioClassificationData.length < this.data.biblioClassificationTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
    }
  },
  onTabsClick(event) {
    console.log(`Click tab, tab-panel value is ${event.detail.value}.`);
  },
})