yiming
2024-03-21 47462dc6c323cc4ac7b32b93051947d351799c1f
packageBookService/pages/bookServices/detail/index.js
@@ -51,7 +51,9 @@
      residue: 0, // 组卷剩余次数
      mockList: [] // 用户组卷提交信息
    },
    flag: true
    flag: true,
    applyResourceLoading: false,
    noResources: false
  },
@@ -262,7 +264,6 @@
          })
        }
      }
      console.log('组卷信息', this.data.mockData);
      this.setData({
        'bookDetail.publicationDate': this.formatDate(this.data.bookDetail.publicationDate),
        'bookDetail.class': className,
@@ -270,6 +271,7 @@
        'bookDetail.oldPrice': this.numFormat(this.data.bookDetail.oldPrice),
        'bookDetail.paperPrice': this.numFormat(this.data.bookDetail.paperPrice),
      });
      console.log('图书信息', this.data.bookDetail);
    });
  },
@@ -343,7 +345,8 @@
  },
  onTabsChange(e) {
    this.setData({
      tabValue: e.detail.value
      tabValue: e.detail.value,
      noResources: false
    })
    if (e.detail.label == '教学资源' || e.detail.label == '云学习' || e.detail.label == '云测试') {
      const checkData = this.data.cmsDatas.find(item => item.refCode == e.detail.value)
@@ -353,7 +356,10 @@
          || (e.detail.value == 'questionBank' && !this.data.test.length)) {
          this.getResourceData(checkData)
        }
      } else {
        this.setData({
          noResources: true
        })
      }
    } else if (e.detail.label == '云笔记') {
      const token = wx.getStorageSync('jsek-token')
@@ -380,7 +386,8 @@
  //  获取教学资源  云学习  云测试
  getResourceData(type) {
    this.setData({
      loading: true
      loading: true,
      noResources: false
    })
    let query = {
      path: '*',
@@ -407,6 +414,12 @@
    app.MG.store
      .getProductDetail(query)
      .then(async (res) => {
        if (!res.datas.cmsDatas[0].datas.length) {
          return this.setData({
            noResources: true,
            loading: false
          })
        }
        // 云测试,递归请求里层数据
        if (type.refCode == 'questionBank') {
          const data = res.datas.cmsDatas[0].datas.filter(
@@ -428,11 +441,10 @@
              })
              this.findChildIds(this.data.teach, this.data.openTeachids = [])
            } else if (type.refCode == 'jsek_cloudLearning') {
              // res.datas.cmsDatas[0].datas.forEach(item => {
              //   item.checked = false
              // })
              // const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
              console.log(list, 'currentlist');
              res.datas.cmsDatas[0].datas.forEach(item => {
                item.checked = false
              })
              const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
              this.setData({
                learn: list,
                loading: false
@@ -555,6 +567,17 @@
  // 图书添加购物车
  async addBookShopcCar() {
    const token = wx.getStorageSync('jsek-token')
    if (!token) {
      return wx.getUserProfile({
        desc: '用户登录',
        success: (res) => {
          console.log(res);
        }
      })
    }
    const shoppingCartGetId = []
    let query = {
@@ -706,10 +729,15 @@
        })
      }
    })
    console.log('有效日期', this.data.deadline);
    this.setData({
      applyResourceLoading: false
    })
  },
  // 申请教学资源
  applyResource() {
    this.setData({
      applyResourceLoading: true
    })
    // let role = userStore.userInfo ? userStore.userInfo.role : null
    // if (role) {
    //   if (role == 'Teacher') {
@@ -732,7 +760,9 @@
    }
    app.MG.ugc.newTopicMessage(query).then((res) => {
      if (res) {
        Message.success('申请已提交,请待审核通过后下载')
        wx.showToast({
          title: '申请已提交,请待审核通过后下载',
        })
      }
      this.getApplyInfo(this.data.bookDetail.id)
    })
@@ -1146,7 +1176,6 @@
        })
        res = await app.MG.store.initOrder(query)
      }
      if (res.orderNumber && this.data.mockData.price) {
        wx.navigateTo({
          url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`,
@@ -1197,11 +1226,16 @@
      this.buyBook()
    }
    else if (this.data.tabValue == 'jsek_cloudLearning') {
      console.log('云学习');
      const tree = this.selectComponent('#tree')
      tree.onCloudShoppingCart()
    } else if (this.data.tabValue == 'questionBank') {
      this.buyMock()
    } else {
      console.log(this.data.tabValue);
    }
  }
  },
})