bug
闫增涛
2024-09-09 7eea32a9a7a034e951468bea279688e8db5c1c98
pages/retrievalPage/index.js
@@ -19,7 +19,6 @@
    showTextAndTitleWithInput: false,
    downloadLoadin: false,
    isMore: null,
    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
    navBarHeight: '',
    barHeight: '',
    searchVal: '',
@@ -39,14 +38,47 @@
      page: 1,
      total: 0,
    },
    tabValue: ''
    tabValue: '0',
    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
    // tab选项
    tabList: [{
        title: "图书",
        index: "0",
        bookTotal: 0
      },
      {
        title: "课程",
        index: "1",
        bookTotal: 0
      },
      {
        title: "数字教材",
        index: "2",
        bookTotal: 0
      }, {
        title: "专题",
        index: "3",
        bookTotal: 0
      },
      {
        title: "书目",
        index: "4",
        bookTotal: 0
      },
      {
        title: "书展",
        index: "5",
        bookTotal: 0
      },
    ],
    tabsId: 0, //默认选型为装备
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(app.config.appId);
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
@@ -56,19 +88,51 @@
      barHeight: systInfo.statusBarHeight,
      searchVal: options.searchVal
    })
    this.retrievalPageGet()
    this.bibliographyGet()
    let event = {
    let e = {
      detail: {
        value: "0"
      }
    }
    this.onTabsChange(event)
    this.onTabsChange(e)
    // 检查登录状态
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.getUserInfo()
        }
      })
    } else {
      this.getUserInfo()
    }
  },
  // 获取登录用户身份
  getUserInfo() {
    app.MG.identity.getCurrentAppUser().then(res => {
      // 用户信息优先级:教师认证 > 微信 > 学生(注册时默认)
      if (res) {
        //获取用户类型
        let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
        let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
        let eMailData = res.secretList.find(i => i.type == 'EMail')
        if (eMailData) {
          this.setData({
            input: eMailData.credential
          })
        } else if (teacherRole && teacherInfos) {
          this.setData({
            input: JSON.parse(teacherInfos.data).email
          })
        } else {
          this.setData({
            input: ''
          })
        }
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
@@ -129,56 +193,23 @@
    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
      })
    console.log(value);
    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: [],
@@ -197,7 +228,8 @@
        'Name*': this.data.searchVal.trim(),
        '||author*': this.data.searchVal.trim(),
        '||isbn*': this.data.searchVal.trim(),
        '||seriesName*': this.data.searchVal.trim()
        '||seriesName*': this.data.searchVal.trim(),
        '||projectLeader*': this.data.searchVal.trim()
      }
    }
@@ -233,17 +265,15 @@
      ...searchObj,
      ...fields
    }
    let courseObj = {}
    if (this.data.searchVal) {
      courseObj = {
        'Name*': this.data.searchVal.trim(),
        '||author*': this.data.searchVal.trim(),
        '||isbn*': this.data.searchVal.trim(),
        '||seriesName*': this.data.searchVal.trim()
        '||seriesName*': this.data.searchVal.trim(),
        '||projectLeader*': this.data.searchVal.trim()
      }
    }
    //课程
    let queryCourse = {
@@ -426,7 +456,6 @@
      data: body
    }).then((resp) => {
      console.log(resp, 'resp');
      //图书       0
      const data1 = resp[0]
      const datas1 = handleQueryResourceListData({
@@ -436,12 +465,9 @@
      this.setData({
        bookData: datas1,
        bookTotal: data1.totalCount,
        [`tabList[${0}].bookTotal`]: data1.totalCount
      })
      console.log(this.data.tabList, 7777)
      //数字课程    1
      const data2 = resp[1]
      const datas2 = handleQueryResourceListData({
@@ -450,11 +476,9 @@
      })
      this.setData({
        courseData: datas2,
        courseTotal: data2.totalCount
        courseTotal: data2.totalCount,
        [`tabList[${1}].bookTotal`]: data2.totalCount
      })
      // 数字教材    2
      const data3 = resp[2]
      const datas3 = handleQueryResourceListData({
@@ -463,20 +487,19 @@
      })
      this.setData({
        digitalTextbooksData: datas3,
        digitalTextbooksTotal: data3.totalCount
        digitalTextbooksTotal: data3.totalCount,
        [`tabList[${2}].bookTotal`]: data3.totalCount
      })
      // 专题研讨   3
      const data4 = resp[3]
      const datas4 = handleQueryResourceListData({
        datas: data4.datas,
        fields
      })
      this.setData({
        seminarData: datas4,
        seminarTotal: data4.totalCount
        seminarTotal: data4.totalCount,
        [`tabList[${3}].bookTotal`]: data4.totalCount
      })
      // 书展      4
      const data5 = resp[4]
@@ -484,27 +507,21 @@
        datas: data5.datas,
        fields
      })
      datas5.forEach((items) => {
        items.subtitleName = items.subtitle + items.name
      })
      // console.log(datas5, 'sadasd');
      this.setData({
        biblioClassificationData: datas5,
        biblioClassificationTotal: data5.totalCount
        biblioClassificationTotal: data5.totalCount,
        [`tabList[${5}].bookTotal`]: data5.totalCount
      })
      this.setData({
        loading: false,
        hidden: false,
      })
    })
    wx.stopPullDownRefresh()
  },
  bibliographyGet() {
    let bibliographyObj = {}
@@ -541,16 +558,15 @@
      this.setData({
        bookFairData: res.datas,
        bookFairTotal: res.total
        bookFairTotal: res.total,
        [`tabList[${4}].bookTotal`]: res.total
      })
    })
    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');
@@ -578,7 +594,38 @@
      }
    });
  },
  openBookFair(event) {
    const item = event.currentTarget.dataset.item
    if (item.fileType == "pdf") {
      wx.navigateTo({
        url: "/packageBookService/pages/components/webView/index?md5=" +
          item.freeFile +
          "&fileName=" +
          item.name +
          "&fileType=" +
          item.fileType + "&bookBuy=true"
          // "&freePage=" +
          // this.data.fileInfo.freePage +
          +
          "&bookId=" +
          item.id,
      });
    } else {
      Toast({
        context: this,
        selector: '#t-toast',
        message: '此书不能查看',
        theme: 'warning',
        direction: 'column',
      });
    }
  },
  onSearchSubmit() {
    this.setData({
      loading: true,
      hidden: true,
    })
    console.log(this.data.searchVal);
    this.retrievalPageGet()
    this.bibliographyGet()
@@ -607,6 +654,7 @@
   * 页面上拉触底事件的处理函数
   */
  onReachBottom(e) {
    console.log(this.data.tabValue);
    if (this.data.tabValue == 0) {
      console.log(0);
      if (this.data.bookData.length < this.data.bookTotal) {
@@ -754,7 +802,6 @@
    this.setData({
      [key]: true,
      dialogKey: key,
      input: '',
      Md5: item.datas.freeFile.FileList[0].Md5
    });
  },
@@ -919,5 +966,31 @@
        }, 100)
      }
    }
  }
  },
  onTabsClick(event) {
    console.log(`
                      Click tab, tab - panel value is $ {
                        event.detail.value
                      }.
                      `);
  },
  tabClick() {
    console.log(2323);
  },
  // 滑动时触发的事件
  slideOn(e) {
    // 拿到当前索引并动态改变
    this.setData({
      tabsId: e.detail.current
    })
  },
  //点击tab时触发
  tabsOn(e) {
    this.setData({
      //拿到当前索引并动态改变
      tabsId: e.currentTarget.dataset.idx
    })
  },
})