闫增涛
2025-03-31 04c7b0163caeae4ab1c5da62e301fa993101cfad
pages/study/index.js
@@ -36,22 +36,7 @@
   */
  onLoad() {
    // 检查登录状态
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.getUserInfo()
          this.getStaticsSum();
          this.getDataList(false);
        }
      })
    } else {
      this.getUserInfo()
      this.getStaticsSum();
      this.getDataList(false);
    }
  },
@@ -70,6 +55,26 @@
      this.getTabBar().setData({
        active: 2
      })
    }
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.getUserInfo()
          this.getStaticsSum();
          this.getDataList(false);
          this.getListCount()
        } else {
          wx.switchTab({
            url: '/pages/home/home',
          })
        }
      })
    } else {
      this.getUserInfo()
      this.getStaticsSum();
      this.getDataList(false);
      this.getListCount()
    }
  },
@@ -112,6 +117,61 @@
      }
    })
  },
  getListCount() {
    let that = this;
    let data = {
      Size: 9999,
      Start: 0,
      sort: {
        type: "Desc",
        field: "CreateDate",
      },
      searchList: [{
        keywords: 'jsek_mediaBook',
        field: "ProductType",
      }],
    }
    app.MG.store.getPurchasedProductList(data).then((res) => {
      that.setData({
        titleBook: "图书(" + res.totalSize + "本)",
      })
    })
    let data1 = {
      Size: 9999,
      Start: 0,
      sort: {
        type: "Desc",
        field: "CreateDate",
      },
      searchList: [{
        keywords: 'jsek_digitalCourses',
        field: "ProductType",
      }],
    }
    app.MG.store.getPurchasedProductList(data1).then((res) => {
      that.setData({
        titleCourse: "课程(" + res.totalSize + "门)",
      })
    })
    let data2 = {
      Size: 9999,
      Start: 0,
      sort: {
        type: "Desc",
        field: "CreateDate",
      },
      searchList: [{
        keywords: 'jsek_digitalTextbooks',
        field: "ProductType",
      }],
    }
    app.MG.store.getPurchasedProductList(data2).then((res) => {
      that.setData({
        titleTextBook: "数字教材(" + res.totalSize + "本)",
      })
    })
  },
  tabClick(item) {
    let that = this;
@@ -163,7 +223,6 @@
          this.setData({
            list: dataList,
            pageTotalCount: res.totalSize,
            titleBook: "图书(" + res.totalSize + "本)",
            bottomLoading: false,
            isMoreData: dataList.length > 0 ? false : true,
            skeletonLoding: false,
@@ -171,6 +230,7 @@
          })
        } else {
          this.setData({
            list: [],
            skeletonLoding: false,
            loading: false
          })
@@ -185,9 +245,23 @@
    const {
      book
    } = e.currentTarget.dataset;
    wx.navigateTo({
      url: `/packageBookService/pages/bookServices/detail/index?id=${book.product.id}&name=${book.product.name}`,
    });
    console.log(book);
    if (this.data.active == 0) {
      wx.navigateTo({
        url: `/packageBookService/pages/bookServices/detail/index?id=${book.product.id}&name=${book.product.name}`,
      });
    }
    if (this.data.active == 1) {
      wx.navigateTo({
        url: `/pages/digitalCourses/digitalCoursesDetails/index?id=${book.product.id}&path=${book.product.linkPathList[1] + '\\' + book.product.id}`,
      });
    }
    if (this.data.active == 2) {
      wx.navigateTo({
        url: `/pages/digitalTextbooks/digitalTextbooksDetails/index?id=${book.product.id}`,
      });
    }
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作