From 7974f3266c323e4cd4fdff7d457fe75f39b8c199 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期三, 25 九月 2024 15:59:06 +0800
Subject: [PATCH] 云学习跳转逻辑修改

---
 pages/digitalCourses/digitalCoursesDetails/index.js |  202 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 150 insertions(+), 52 deletions(-)

diff --git a/pages/digitalCourses/digitalCoursesDetails/index.js b/pages/digitalCourses/digitalCoursesDetails/index.js
index 8b78e3a..05c9f2d 100644
--- a/pages/digitalCourses/digitalCoursesDetails/index.js
+++ b/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()
+    }
   },
 
   /**
@@ -224,17 +233,17 @@
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
-  onShareAppMessage() {
-
-  },
+  onShareAppMessage() {},
+  onShareTimeline() {},
   //鑾峰彇瑙嗛瀛︿範
   getPlayerList() {
     app.MG.identity
       .getUserKey({
         domain: 'videoPlayer',
-        keys: [this.data.bookId]
+        keys: [this.data.bookId + '']
       })
       .then((res) => {
+        console.log(1, res);
         if (res.length > 0) {
           this.setData({
             playerList: JSON.parse(res[0].value)
@@ -243,6 +252,7 @@
       })
   },
   digitalCoursesDetailsGet(digitalTextId) {
+    let that = this;
     let query = {
       path: '*',
       queryType: '*',
@@ -312,6 +322,10 @@
       }
       if (res.datas.datas.speaker && res.datas.datas.speaker.length > 0) {
         this.getSpeaker(res.datas.datas.speaker)
+      } else {
+        this.setData({
+          lecturerList: []
+        })
       }
       if (this.data.bookPath) {
         this.getAboutBook(this.data.bookPath)
@@ -325,12 +339,41 @@
       )
       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)
+      }
     })
   },
   //鑾峰彇涓昏浜�
   getSpeaker(list) {
+    this.setData({
+      lecturerList: []
+    })
     let query = {
       path: 'jsek_speaker',
       fields: {
@@ -415,6 +458,9 @@
     this.setData({
       tabValue: value
     })
+    if (this.data.tabValue == 0) {
+      this.digitalCoursesDetailsGet(this.data.bookId)
+    }
     if (this.data.tabValue == 1) {
       this.saveAsImage()
     }
@@ -433,7 +479,8 @@
   selectChange(event) {
     const value = event.target.dataset.value
     this.setData({
-      selectActive: value
+      selectActive: value,
+      testCount: 0
     })
     this.getResource()
   },
@@ -472,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) {
@@ -484,9 +530,7 @@
           if (item.type == 'productItem') {
             learnItemList.push(item)
           }
-
         })
-
         if (this.data.selectActive === 'learn') {
           let list = []
           // 娴嬭瘯 6浣�// 姝e紡 5浣�//  娴嬭瘯璋冪敤浼�20锛屽唴閮�7  姝e紡璋冪敤浼�17 鍐呴儴浼�6
@@ -656,6 +700,7 @@
 
   //鍦ㄧ嚎娴嬭瘯鑾峰彇鏈�鍚庝竴涓妭鐐规暟閲�
   countLeafNodes(tree) {
+
     tree.forEach(node => {
       if (!node.children || node.children.length === 0) {
         this.setData({
@@ -734,8 +779,6 @@
 
   onCorrelationBook(e) {
     const item = e.currentTarget.dataset.item;
-    // this.digitalCoursesDetailsGet(item.id)
-    // this.getPlayerList()
     this.onLoad({
       loading: true,
       id: item.id,
@@ -824,7 +867,7 @@
         Toast({
           context: this,
           selector: "#t-toast",
-          message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞",
+          message: "璇ヨ绋嬪凡鍦ㄨ喘鐗╄溅锛岃鍕块噸澶嶆坊鍔�",
           theme: "warning",
           direction: "column",
         });
@@ -871,12 +914,13 @@
             })
             .then((res) => {
               if (res) {
+                this.digitalCoursesDetailsGet(this.data.digitalsData.id);
                 wx.showToast({
                   title: "棰嗗彇鎴愬姛",
                   icon: "none",
                   duration: 1000,
                 });
-                this.getBookInfo(this.data.bookDetail.id);
+                this.digitalCoursesDetailsGet(this.data.bookId);
               }
             });
         } else {
@@ -927,7 +971,9 @@
         },
       )
       .exec()
-    this.drawImage()
+    setTimeout(() => {
+      this.drawImage()
+    }, 500)
     query
       .select('#textCertificate')
       .fields({
@@ -946,7 +992,9 @@
         },
       )
       .exec()
-    this.drawImage1()
+    setTimeout(() => {
+      this.drawImage1()
+    }, 500)
   },
   drawImage() {
     let that = this;
@@ -1043,17 +1091,16 @@
     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
+            isCertificate: item,
+            userName: item.content.userName,
+            userPicture: app.config.requestCtx + `/file/GetPreViewImage?md5=` + item.content.userPicture
           })
         }
       })
-
     })
   },
-
-
 
   onCertificate() {
     if (!this.data.isBuy) {
@@ -1163,6 +1210,10 @@
   },
 
   confirmM() {
+    let currentDate = new Date()
+    let year = currentDate.getFullYear()
+    let month = currentDate.getMonth() + 1
+    let today = currentDate.getDate()
     if (this.data.userInfo.fullName) {
       if (this.data.pictureMd5 == '') {
         wx.showToast({
@@ -1180,42 +1231,89 @@
         name: this.data.digitalsData.name,
         ISBN: this.data.digitalsData.isbn,
         affiliatedUnit: this.data.digitalsData.affiliatedUnit,
+        publishingUnit: this.data.publishingUnit,
         publicationDate: this.data.digitalsData.publicationDate,
         classHours: this.data.digitalsData.classHours,
         lecturerList: this.data.lecturerList.length > 0 ?
           this.data.lecturerList[0].name : this.data.digitalsData.courseLeader,
+        userName: this.data.userInfo.fullName,
         userPicture: this.data.pictureMd5,
-        certificate: this.data.rzzsImg
+        studyTime: this.data.digitalsData.beginDate + '-' + year + '-' + month + '-' + today,
+        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: "濮撳悕涓嶈兘涓虹┖",

--
Gitblit v1.9.1