rwd
litian
2024-09-27 2abf00efb6d83426ad84342f17252a36aeb5a4e1
pages/digitalCourses/digitalCoursesDetails/index.js
@@ -4,13 +4,15 @@
import FormData from '../../../utils/formdata/index.js';
import Wxml2Canvas from 'wxml2canvas';
import {
  worksDataBytool
  worksDataBytool,
  UpdateworksDataBytool
} from "../../../assets/js/toolClass.js";
import moment from 'moment'
import Toast from "tdesign-miniprogram/toast";
import {
  loginInfo
} from '../../../assets/js/login';
import wxbarcode from 'wxbarcode'
Page({
  /**
@@ -103,7 +105,10 @@
    rzzsImg: '', //认证证书base64
    imageWidth: '', //画在画布上的图片的宽度
    imageHeight: '', //画在画布上的图片的高度
    website: 'https://jsek.bnuic.com',
    website: 'https://jsek.bnuic.com/home/#/digitalCourses',
    wxShareUrl: '',
    imgUrl: '',
    imgUrl1: ''
  },
  formatDate(dateString) {
    if (!dateString) {
@@ -190,7 +195,11 @@
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (this.data.tabValue == 2 && this.data.selectActive == 'learn') {
      this.getPlayerList()
      this.getResource()
      this.getRelationBook()
    }
  },
  /**
@@ -234,6 +243,7 @@
        keys: [this.data.bookId + '']
      })
      .then((res) => {
        console.log(1, res);
        if (res.length > 0) {
          this.setData({
            playerList: JSON.parse(res[0].value)
@@ -242,6 +252,7 @@
      })
  },
  digitalCoursesDetailsGet(digitalTextId) {
    let that = this;
    let query = {
      path: '*',
      queryType: '*',
@@ -328,8 +339,34 @@
      )
      this.setData({
        digitalsData: res.datas,
        loading: false
        loading: false,
        wxShareUrl: app.config.shareUrl + '?id=' + res.datas.id + '&path=' + this.data.bookPath + '&type=course'
      })
      if (this.data.wxShareUrl) {
        wxbarcode.qrcode('qrcode', this.data.wxShareUrl, 160, 160);
        wxbarcode.qrcode('qrcode1', this.data.wxShareUrl, 160, 160);
        setTimeout(() => {
          wx.canvasToTempFilePath({
            canvasId: 'qrcode',
            success: function (res) {
              // res.tempFilePath 包含生成的图片文件路径
              that.setData({
                imgUrl: res.tempFilePath
              })
            }
          });
          wx.canvasToTempFilePath({
            canvasId: 'qrcode1',
            success: function (res) {
              // res.tempFilePath 包含生成的图片文件路径
              that.setData({
                imgUrl1: res.tempFilePath
              })
            }
          });
        }, 1000)
      }
    })
  },
  //获取主讲人
@@ -442,7 +479,8 @@
  selectChange(event) {
    const value = event.target.dataset.value
    this.setData({
      selectActive: value
      selectActive: value,
      testCount: 0
    })
    this.getResource()
  },
@@ -481,7 +519,6 @@
        res.datas.cmsDatas[0].datas.forEach((item) => {
          if (item.type == 'questionBankFolder' || item.type == 'questionBankItem') {
            test.push(item)
          } else if (item.type != "resourceItem") {
            this.data.playerList.forEach(pItem => {
              if (pItem.cmsItemId == item.id) {
@@ -493,9 +530,7 @@
          if (item.type == 'productItem') {
            learnItemList.push(item)
          }
        })
        if (this.data.selectActive === 'learn') {
          let list = []
          // 测试 6位// 正式 5位//  测试调用传20,内部7  正式调用传17 内部传6
@@ -665,6 +700,7 @@
  //在线测试获取最后一个节点数量
  countLeafNodes(tree) {
    tree.forEach(node => {
      if (!node.children || node.children.length === 0) {
        this.setData({
@@ -831,7 +867,7 @@
        Toast({
          context: this,
          selector: "#t-toast",
          message: "该书已在购物车,请勿重复添加",
          message: "该课程已在购物车,请勿重复添加",
          theme: "warning",
          direction: "column",
        });
@@ -878,6 +914,7 @@
            })
            .then((res) => {
              if (res) {
                this.digitalCoursesDetailsGet(this.data.digitalsData.id);
                wx.showToast({
                  title: "领取成功",
                  icon: "none",
@@ -934,7 +971,9 @@
        },
      )
      .exec()
    this.drawImage()
    setTimeout(() => {
      this.drawImage()
    }, 500)
    query
      .select('#textCertificate')
      .fields({
@@ -953,7 +992,9 @@
        },
      )
      .exec()
    this.drawImage1()
    setTimeout(() => {
      this.drawImage1()
    }, 500)
  },
  drawImage() {
    let that = this;
@@ -1050,7 +1091,7 @@
    app.MG.ugc.getTopicMessageList(data).then((res) => {
      res.datas.map((item) => {
        item.content = JSON.parse(item.content)
        if (item.content.id == this.data.bookId) {
        if (item.content.bookId == this.data.bookId) {
          this.setData({
            isCertificate: item,
            userName: item.content.userName,
@@ -1058,11 +1099,8 @@
          })
        }
      })
    })
  },
  onCertificate() {
    if (!this.data.isBuy) {
@@ -1201,37 +1239,81 @@
        userName: this.data.userInfo.fullName,
        userPicture: this.data.pictureMd5,
        studyTime: this.data.digitalsData.beginDate + '-' + year + '-' + month + '-' + today,
        website: this.data.website
        website: this.data.website,
        wxShareUrl: this.data.wxShareUrl
      }
      data = {
        topicIdOrRefCode: 'applyCourseCertificate',
        name: this.data.userInfo.fullName,
        content: JSON.stringify(bookInfo),
        state: 'WaitAudit',
        cmsTypeRefCode: 'jsek_courseCertificate',
        type: 'applyCourse',
        newDataListRequest: worksDataBytool(this.data.worksInfo, this.data.userInfo)
      if (this.data.isCertificate.id) {
        let dataRequests = UpdateworksDataBytool(
          this.data.worksInfo,
          [this.data.isCertificate],
          this.data.userInfo
        )
        data = {
          id: this.data.isCertificate.id,
          topicIdOrRefCode: 'applyCourseCertificate',
          name: this.data.userInfo.fullName,
          content: JSON.stringify(bookInfo),
          state: 'WaitAudit',
          cmsTypeRefCode: 'jsek_courseCertificate',
          type: 'applyCourse',
          newDataRequests: dataRequests.newData,
          updateDataRequests: dataRequests.updateData,
          delDataRequest: {
            ids: []
          }
        }
        app.MG.ugc
          .updateTopicMessage(data)
          .then((res) => {
            wx.showToast({
              title: "已提交申请",
              icon: "none",
              duration: 1000,
            });
            this.setData({
              "userInfo.fullName": "",
              dialogBox: false,
              scrollJudge: true
            })
            this.getCertificateList()
          })
          .catch(() => {
            btnLoading.value = false
          })
      } else {
        data = {
          topicIdOrRefCode: 'applyCourseCertificate',
          name: this.data.userInfo.fullName,
          content: JSON.stringify(bookInfo),
          state: 'WaitAudit',
          cmsTypeRefCode: 'jsek_courseCertificate',
          type: 'applyCourse',
          newDataListRequest: worksDataBytool(this.data.worksInfo, this.data.userInfo)
        }
        app.MG.ugc
          .newTopicMessage(data)
          .then((res) => {
            wx.showToast({
              title: "已提交申请",
              icon: "none",
              duration: 1000,
            });
            this.setData({
              "userInfo.fullName": "",
              dialogBox: false,
              scrollJudge: true
            })
            this.getCertificateList()
          })
          .catch(() => {
            this.setData({
              "userInfo.fullName": "",
            })
          })
      }
      app.MG.ugc
        .newTopicMessage(data)
        .then((res) => {
          wx.showToast({
            title: "已提交申请",
            icon: "none",
            duration: 1000,
          });
          this.setData({
            "userInfo.fullName": "",
            dialogBox: false,
            scrollJudge: true
          })
          this.getCertificateList()
        })
        .catch(() => {
          this.setData({
            "userInfo.fullName": "",
          })
        })
    } else {
      wx.showToast({
        title: "姓名不能为空",