闫增涛
2024-04-02 5c236aa8ee143c1f0f23e738f92c0ebc21270549
packageBookService/pages/bookServices/detail/index.js
@@ -418,9 +418,9 @@
          selectedIds: res.datas[0].defaultSaleMethod.id,
          bookBuy: res.datas[0].purchasedSaleMethodIdList.indexOf(res.datas[0].defaultSaleMethodId) > -1
        });
        console.log(this.data.bookItemDetail, 'bookItemData.value');
        let times = new Date(res.datas[0].defaultSaleMethod.endDate).getTime()
        let startTime = new Date(res.datas[0].defaultSaleMethod.beginDate).getTime()
        if (times < new Date().getTime() || new Date().getTime() < startTime) {
          this.setData({
            expire: true
@@ -821,15 +821,7 @@
  // 图书添加购物车
  async addBookShopcCar() {
    if (!this.data.expire) {
      const token = wx.getStorageSync('jsek-token')
      if (!token) {
        return wx.getUserProfile({
          desc: '用户登录',
          success: (res) => {
            console.log(res);
          }
        })
      }
      const shoppingCartGetId = []
@@ -1007,48 +999,64 @@
    this.setData({
      applyResourceState: true
    })
    wx.showLoading({
      title: '加载中',
    })
    // let role = userStore.userInfo ? userStore.userInfo.role : null
    // if (role) {
    //   if (role == 'Teacher') {
    // 申请教学资源
    let query = {
      topicIdOrRefCode: 'productDownLoad',
      type: 'applyForDownload',
      state: 'WaitAudit',
      cmsTypeRefCode: '',
      newDataListRequest: [],
      name: this.data.bookDetail.name, // name为申请的书本名称
      content: JSON.stringify([{
        name: this.data.bookDetail.name,
        id: this.data.bookDetail.id,
        // defaultSaleMethodId: bookData.value.defaultSaleMethodId,
        icon: this.data.bookDetail.icon
      }])
    }
    app.MG.ugc.newTopicMessage(query).then(async (res) => {
      if (res) {
        wx.showToast({
          title: '申请已提交',
          duration: 2000,
    let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role
    if (role) {
      if (role == 'Teacher') {
        wx.showLoading({
          title: '加载中',
        })
        // 申请教学资源
        let query = {
          topicIdOrRefCode: 'productDownLoad',
          type: 'applyForDownload',
          state: 'WaitAudit',
          cmsTypeRefCode: '',
          newDataListRequest: [],
          name: this.data.bookDetail.name, // name为申请的书本名称
          content: JSON.stringify([{
            name: this.data.bookDetail.name,
            id: this.data.bookDetail.id,
            // defaultSaleMethodId: bookData.value.defaultSaleMethodId,
            icon: this.data.bookDetail.icon
          }])
        }
        app.MG.ugc.newTopicMessage(query).then(async (res) => {
          if (res) {
            wx.showToast({
              title: '申请已提交',
              duration: 2000,
            })
          }
          await this.getApplyInfo(this.data.bookDetail.id)
        })
      } else {
        wx.showModal({
          title: '尊敬的用户,您好!',
          content: '请先进行教师认证!',
          complete: (res) => {
            if (res.cancel) {}
            if (res.confirm) {
              wx.navigateTo({
                url: '/packageDomain/pages/teacherCertification/index',
              })
            }
          }
        })
      }
      await this.getApplyInfo(this.data.bookDetail.id)
    })
    //   } else {
    //     ElMessageBox.confirm('请先进行教师认证!', '尊敬的用户,您好!', {
    //       confirmButtonText: '去认证',
    //       cancelButtonText: '取消',
    //       type: 'warning'
    //     })
    //       .then(() => {
    //         isShow.value = true
    //       })
    //       .catch(() => { })
    //   }
    // }
    } else {
      wx.showModal({
        title: '尊敬的用户,您好!',
        content: '请先进行教师认证!',
        complete: (res) => {
          if (res.cancel) {}
          if (res.confirm) {
            wx.navigateTo({
              url: '/packageDomain/pages/teacherCertification/index',
            })
          }
        }
      })
    }
  },
  // 教学资源下载前往PC提示Diialog
  closeTeachDownload() {
@@ -1058,10 +1066,27 @@
  },
  // 下载功能
  downloadTeach(e) {
    this.setData({
      isShowTeachDownload: true
    })
    console.log('zhuan', this.data.isShowTeachDownload);
    let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role
    if (role && role == 'Teacher') {
      this.setData({
        isShowTeachDownload: true
      })
    } else {
      wx.showModal({
        title: '尊敬的用户,您好!',
        content: '请先进行教师认证!',
        complete: (res) => {
          if (res.cancel) {
          }
          if (res.confirm) {
            wx.navigateTo({
              url: '/packageDomain/pages/teacherCertification/index',
            })
          }
        }
      })
    }
    //   const data = e.detail.value
    //   // const data
    //   // let role = userStore.userInfo ? userStore.userInfo.role : null
@@ -1254,6 +1279,7 @@
      let freeIds = arr.filter((item) => {
        return item.saleMethod[0].Price == 0
      })
      debugger
      if (!freeIds.length) return wx.showToast({
        icon: "error",
        title: '暂无免费资源',
@@ -1268,7 +1294,7 @@
          })
        }
      })
      debugger
      let query = {
        remarks: '云学习',
        requests,
@@ -1516,7 +1542,7 @@
      return false;
    }
    wx.navigateTo({
      url: '/packageBookService/pages/components/webView/index?md5=' + this.data.fileInfo.md5 + '&fileName=' + this.data.fileInfo.bookName + '&fileType=' + this.data.fileInfo.fileType + '&freePage=' + this.data.fileInfo.freePage + '&bookBuy=' + this.data.bookBuy
      url: '/packageBookService/pages/components/webView/index?md5=' + this.data.fileInfo.md5 + '&fileName=' + this.data.fileInfo.bookName + '&fileType=' + this.data.fileInfo.fileType + '&freePage=' + this.data.fileInfo.freePage + '&bookBuy=' + this.data.bookBuy + '&bookId=' + this.data.bookDetail.id
    })
  },