From 3af1a4c3f1712445a17376205b9ee3c4d7768da6 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 24 九月 2024 19:29:33 +0800 Subject: [PATCH] zs --- pages/digitalCourses/digitalCoursesDetails/index.js | 175 +++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 124 insertions(+), 51 deletions(-) diff --git a/pages/digitalCourses/digitalCoursesDetails/index.js b/pages/digitalCourses/digitalCoursesDetails/index.js index 6934b6b..57eed2f 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({ /** @@ -104,6 +106,9 @@ imageWidth: '', //鐢诲湪鐢诲竷涓婄殑鍥剧墖鐨勫搴� imageHeight: '', //鐢诲湪鐢诲竷涓婄殑鍥剧墖鐨勯珮搴� website: 'https://jsek.bnuic.com/home/#/digitalCourses', + wxShareUrl: '', + imgUrl: '', + imgUrl1: '' }, formatDate(dateString) { if (!dateString) { @@ -243,6 +248,7 @@ }) }, digitalCoursesDetailsGet(digitalTextId) { + let that = this; let query = { path: '*', queryType: '*', @@ -329,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) + } }) }, //鑾峰彇涓昏浜� @@ -1056,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, @@ -1064,29 +1096,26 @@ }) } }) - }) }, - - onCertificate() { - if (!this.data.isBuy) { - wx.showToast({ - title: "璇峰厛璐拱锛屼綋楠屽畬鏁存湇鍔�", - icon: "none", - duration: 1000, - }); - return false - } - if (!this.data.isLearn) { - wx.showToast({ - title: "鎮ㄧ殑瀛︿範浠诲姟杩樻湭瀹屾垚锛屾殏涓嶈兘鐢宠璇佷功锛屽姞娌瑰摝锛�", - icon: "none", - duration: 1000, - }); - return false - } + // if (!this.data.isBuy) { + // wx.showToast({ + // title: "璇峰厛璐拱锛屼綋楠屽畬鏁存湇鍔�", + // icon: "none", + // duration: 1000, + // }); + // return false + // } + // if (!this.data.isLearn) { + // wx.showToast({ + // title: "鎮ㄧ殑瀛︿範浠诲姟杩樻湭瀹屾垚锛屾殏涓嶈兘鐢宠璇佷功锛屽姞娌瑰摝锛�", + // icon: "none", + // duration: 1000, + // }); + // return false + // } if (this.data.isCertificate && this.data.isCertificate.state == 'WaitAudit') { wx.showToast({ title: "鎮ㄧ敵璇风殑璇佷功姝e湪瀹℃牳涓�", @@ -1207,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