wj
litian
2024-10-23 abe52e53bee051e3f801d001c4de58d34a3fefd7
packageBookService/pages/bookServices/detail/index.js
@@ -50,10 +50,12 @@
    resourceClassList: [], // 资源所属分类
    applyState: "", // 教学资源申请状态
    deadline: "", // 教学资源申请有效日期,
    isShowBuyCloundBtn: false,
    isshowDrawBtn: true, // 云学习领取查看按钮是否显示
    isShowBuyCloundMenu: false, //   云学习全部购买按钮是否显示
    isCloundHaveSaleMethod: false, // 云学习是否有销售方式 
    cloundMenuIsBuy: false,
    learnTaskData: {},
    rejectCause: "", // 下载拒绝原因
    buyIdList: [],
    shoppingCartGetId: [], // 已购买id列表
@@ -206,7 +208,9 @@
    fileList: [],
    isShowUp: true,
    protocolShow: false,
    protocolTxt: ''
    protocolTxt: '',
    learnMenu: null,
    md5List: []
  },
  resetTree: function (e) {
@@ -524,8 +528,11 @@
    app.MG.store.getProductDetail(query).then((res) => {
      this.setData({
        resourceCodeList: res.datas.cmsDatas[0].datas,
        learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0]
      })
      console.log('refcode', this.data.resourceCodeList);
      if (res.datas.cmsDatas[0].datas.length) this.setData({
        learnMenu: res.datas.cmsDatas[0].datas.find(item => item.refCode == 'jsek_cloudLearning')
      })
    })
  },
  //请求子商品的文件
@@ -949,7 +956,6 @@
    let query = {
      path: '*',
      queryType: '*',
      // storeInfo: this.data.options.storeInfo,
      productId: this.data.bookDetail.id,
      cmsPath: type.productLinkPath,
      cmsType: '*',
@@ -962,10 +968,9 @@
        file: [],
        protectedFile: [],
        resourcesClassification: [],
        isDownload: [],
        // isDownload: [],
        jsek_resourceBrief: [],
        jsek_link: [],
        jsek_questionBank: []
      },
      pading: {
        start: 0,
@@ -973,7 +978,6 @@
      },
    }
    app.MG.store.getProductDetailNoChildren(query).then((res) => {
      console.log('未处理资源', res.datas.cmsDatas[0].datas);
      if (!res.datas.cmsDatas[0].datas.length) {
        return this.setData({
          noResources: true,
@@ -991,8 +995,19 @@
        cloundSaleMethod &&
        new Date().getTime() <= new Date(cloundSaleMethod.EndDate).getTime() &&
        new Date().getTime() >= new Date(cloundSaleMethod.BeginDate).getTime()
      let md5s = []
      res.datas.cmsDatas[0].datas.forEach((item) => {
        // 云学习上有销售方式,去掉云学习下所有销售方式
        if (this.data.tabValue == "jsek_teachingResources") {
          if (item.file || item.freeFile) {
            let md5 = item.file ? item.file : item.freeFile
            md5s.push(md5)
          }
          this.setData({
            md5List: md5s,
          });
        }
        if (flags) item.saleMethod = []
        item.checked = false;
        if (item.sysType == 'CmsItem') {
@@ -1041,7 +1056,9 @@
          new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime()
        ) || (flags && cloundSaleMethod.Price == 0)
        // 判断云学习全部购买按钮是否显示
        let isShowBuyCloundMenu = flags && cloundSaleMethod.Price >= 0
        let isShowBuyCloundMenu = flags && cloundSaleMethod.Price >= 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id)
        // 判断资源购买按钮是否显示
        let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(citem => citem.saleMethod.length != 0)
        // 判断购物车按钮和锁按钮是否显示
        this.handleTreeData(list).forEach(item => {
          item.isbuy = this.resourceIsBuy(item);
@@ -1051,6 +1068,7 @@
        this.setData({
          isshowDrawBtn,
          isShowBuyCloundMenu,
          isShowBuyCloundBtn,
          isCloundHaveSaleMethod: flags,
          learn: list,
          loading: false,
@@ -1836,6 +1854,32 @@
      });
    }
  },
  // 云学习全部购买
  async buyCloudLearnClass() {
    const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
    debugger
    let query = {
      remarks: '云学习',
      requests: [{
        saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id,
        count: 1
      }]
    }
    const initOrderRes = await app.MG.store.initOrder(query)
    // 检查订单号是否存在
    if (initOrderRes.orderNumber) {
      // bookService: orderNumber.value,  少传这个 ,暂时不知道有什么用
      wx.navigateTo({
        url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`,
      });
    } else {
      // 订单号不存在,显示警告消息
      wx.showToast({
        icon: "error",
        title: "请重试",
      });
    }
  },
  // 云学习字段购买
  async buyCloundMenu() {
    const cloundData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning')
@@ -2544,6 +2588,11 @@
    return childrenList
  },
  uploadFile(e) {
    const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey))
    if (userInfo.role != 'Teacher') return wx.showToast({
      icon: 'error',
      title: '请先进行教师认证',
    })
    this.setData({
      dialogBox: true,
      isShowUp: true
@@ -2773,7 +2822,7 @@
    app.MG.ugc.newTopicMessage(query).then((res) => {
      wx.showToast({
        icon: "success",
        title: "请上传资源文件",
        title: "上传成功",
      });
      this.closeDialog()
    })
@@ -2788,5 +2837,10 @@
    this.setData({
      cloundMenuIsBuy: flag
    })
  }
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
  onShareTimeline() {}
})