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 | 166 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 122 insertions(+), 44 deletions(-) diff --git a/pages/digitalCourses/digitalCoursesDetails/index.js b/pages/digitalCourses/digitalCoursesDetails/index.js index 21b05e9..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) { @@ -177,7 +182,6 @@ this.setData({ userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).name, }) - console.log('1', options.id); }, /** @@ -191,11 +195,11 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { - if (this.data.tabValue == 2) { + if (this.data.tabValue == 2 && this.data.selectActive == 'learn') { this.getPlayerList() this.getResource() + this.getRelationBook() } - }, /** @@ -239,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) @@ -247,6 +252,7 @@ }) }, digitalCoursesDetailsGet(digitalTextId) { + let that = this; let query = { path: '*', queryType: '*', @@ -333,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) + } }) }, //鑾峰彇涓昏浜� @@ -447,7 +479,8 @@ selectChange(event) { const value = event.target.dataset.value this.setData({ - selectActive: value + selectActive: value, + testCount: 0 }) this.getResource() }, @@ -516,7 +549,6 @@ learnList: list, openTeachids: result, }); - console.log(1, this.data.learnList, this.data.playerList) } } else { const data = test.filter( @@ -668,6 +700,7 @@ //鍦ㄧ嚎娴嬭瘯鑾峰彇鏈�鍚庝竴涓妭鐐规暟閲� countLeafNodes(tree) { + tree.forEach(node => { if (!node.children || node.children.length === 0) { this.setData({ @@ -834,7 +867,7 @@ Toast({ context: this, selector: "#t-toast", - message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞", + message: "璇ヨ绋嬪凡鍦ㄨ喘鐗╄溅锛岃鍕块噸澶嶆坊鍔�", theme: "warning", direction: "column", }); @@ -938,7 +971,9 @@ }, ) .exec() - this.drawImage() + setTimeout(() => { + this.drawImage() + }, 500) query .select('#textCertificate') .fields({ @@ -957,7 +992,9 @@ }, ) .exec() - this.drawImage1() + setTimeout(() => { + this.drawImage1() + }, 500) }, drawImage() { let that = this; @@ -1054,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, @@ -1062,11 +1099,8 @@ }) } }) - }) }, - - onCertificate() { if (!this.data.isBuy) { @@ -1205,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: "濮撳悕涓嶈兘涓虹┖", -- Gitblit v1.9.1