From b471803c1a9e4c1452a98a8b3631bde66641b910 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期三, 25 九月 2024 15:01:50 +0800
Subject: [PATCH] css

---
 pages/digitalCourses/digitalCoursesDetails/index.js |  163 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 119 insertions(+), 44 deletions(-)

diff --git a/pages/digitalCourses/digitalCoursesDetails/index.js b/pages/digitalCourses/digitalCoursesDetails/index.js
index 21b05e9..aaa522c 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) {
@@ -174,10 +179,6 @@
     this.digitalCoursesDetailsGet(options.id)
     this.getPlayerList()
     this.getType()
-    this.setData({
-      userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).name,
-    })
-    console.log('1', options.id);
   },
 
   /**
@@ -247,6 +248,7 @@
       })
   },
   digitalCoursesDetailsGet(digitalTextId) {
+    let that = this;
     let query = {
       path: '*',
       queryType: '*',
@@ -333,8 +335,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)
+      }
     })
   },
   //鑾峰彇涓昏浜�
@@ -447,7 +475,8 @@
   selectChange(event) {
     const value = event.target.dataset.value
     this.setData({
-      selectActive: value
+      selectActive: value,
+      testCount: 0
     })
     this.getResource()
   },
@@ -668,6 +697,7 @@
 
   //鍦ㄧ嚎娴嬭瘯鑾峰彇鏈�鍚庝竴涓妭鐐规暟閲�
   countLeafNodes(tree) {
+
     tree.forEach(node => {
       if (!node.children || node.children.length === 0) {
         this.setData({
@@ -834,7 +864,7 @@
         Toast({
           context: this,
           selector: "#t-toast",
-          message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞",
+          message: "璇ヨ绋嬪凡鍦ㄨ喘鐗╄溅锛岃鍕块噸澶嶆坊鍔�",
           theme: "warning",
           direction: "column",
         });
@@ -938,7 +968,9 @@
         },
       )
       .exec()
-    this.drawImage()
+    setTimeout(() => {
+      this.drawImage()
+    }, 500)
     query
       .select('#textCertificate')
       .fields({
@@ -957,7 +989,9 @@
         },
       )
       .exec()
-    this.drawImage1()
+    setTimeout(() => {
+      this.drawImage1()
+    }, 500)
   },
   drawImage() {
     let that = this;
@@ -1054,7 +1088,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,
@@ -1062,11 +1096,8 @@
           })
         }
       })
-
     })
   },
-
-
 
   onCertificate() {
     if (!this.data.isBuy) {
@@ -1205,37 +1236,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: "濮撳悕涓嶈兘涓虹┖",

--
Gitblit v1.9.1