From c99f9976a5ef9d8974105feb8fc0580a10adf98c Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期一, 23 十二月 2024 14:58:49 +0800 Subject: [PATCH] 111 --- packageCourse/pages/course/index.js | 165 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 121 insertions(+), 44 deletions(-) diff --git a/packageCourse/pages/course/index.js b/packageCourse/pages/course/index.js index d122c10..9a0a0c8 100644 --- a/packageCourse/pages/course/index.js +++ b/packageCourse/pages/course/index.js @@ -31,6 +31,10 @@ total: 999, loading: false }, + updateCourse: false, + currentCourse: null, + submitLoading: false, + showContentOnly: false, // 鍔犺浇鍙傛暟 bottomLoading: false, isMoreData: false, @@ -47,6 +51,18 @@ this.getData() }, + showDialog() { + this.setData({ + showContentOnly: true, + }); + }, + + closeDialog() { + this.setData({ + showContentOnly: false + }); + }, + // 璇剧▼璇︽儏 todetail(e) { const { @@ -54,14 +70,15 @@ item } = e.currentTarget.dataset const refCode = item.linkProduct.refCode ? item.linkProduct.refCode : '' - if (item.applyState == 'WaitAudit' || item.applyState == 'Reject') { + if (item.applyState == 'WaitAudit') { wx.showToast({ - title: item.applyState == 'WaitAudit' ? '瀹℃牳涓�' : '鏈�氳繃', + title: '瀹℃牳涓�', duration: 1000, icon: 'none', }) return false } + if (item.applyState == 'Reject') return false wx.navigateTo({ url: '/packageCourse/pages/course/detail/index?courseId=' + courseId + "&bookRefCode=" + refCode, }) @@ -116,7 +133,7 @@ id: item.id, icon: item.icon && item.icon != 'default' ? getPublicImage(item.icon, 200) : '', introduction: item.description, - reason: item.applyReturnMsg ? JSON.parse(item.applyReturnMsg).reason : '-' + reason: item.applyReturnMsg ? JSON.parse(item.applyReturnMsg).reason ? JSON.parse(item.applyReturnMsg).reason : '-' : '-' } }) //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹� @@ -241,51 +258,111 @@ }) }, + // 閲嶆柊鐢宠 + replayCourse(e) { + const { + item + } = e.currentTarget.dataset + if (!item.linkProduct.icon) { + item.linkProduct.icon = '' + } + const data = { + product: item.linkProduct + } + this.setData({ + currentCourse: item, + courseName: item.name, + courseDesc: item.description, + selectedBook: data, + updateCourse: true, + visible: true + }) + this.getTextBook() + }, + // 鏂板缓璇剧▼ submitCourse() { - if (!this.data.courseName) { - wx.showToast({ - title: '璇峰~鍐欒绋嬪悕绉�', - duration: 1000, - icon: 'none', + if (this.data.updateCourse) { + this.setData({ + submitLoading: true }) - return false + app.MG.edu + .updateCourse({ + courseId: this.data.currentCourse.id, + name: this.data.courseName, + description: this.data.courseDesc, + }) + .then((res) => { + app.MG.edu + .updateCourseApply({ + courseId: this.data.currentCourse.id, + applyData: JSON.stringify({ + textBookId: this.data.selectedBook.product.id, + textBookName: this.data.selectedBook.product.name + }) + }) + .then((ares) => { + if (ares) { + this.setData({ + visible: false, + selectedBook: null, + courseDesc: '', + courseName: '', + submitLoading: false + }) + this.getData() + } + }) + }) + } else { + if (!this.data.courseName) { + wx.showToast({ + title: '璇峰~鍐欒绋嬪悕绉�', + duration: 1000, + icon: 'none', + }) + return false + } + if (!this.data.selectedBook) { + wx.showToast({ + title: '璇烽�夋嫨鍏宠仈鏁欐潗', + duration: 1000, + icon: 'none', + }) + return false + } + this.setData({ + submitLoading: true + }) + app.MG.edu + .applyNewCourse({ + name: this.data.courseName, + description: this.data.courseDesc, + content: '', + icon: this.data.selectedBook.product.icon, + type: 'course', + config: '', + applyData: JSON.stringify({ + textBookId: this.data.selectedBook.product.id, + textBookName: this.data.selectedBook.product.name + }), + linkProductId: this.data.selectedBook.product.id, + maxClassCount: 999, + payPrice: 0 + }) + .then((res) => { + if (res) { + this.setData({ + visible: false, + selectedBook: null, + courseDesc: '', + courseName: '', + submitLoading: false + }) + this.getData() + } + }) } - if (!this.data.selectedBook) { - wx.showToast({ - title: '璇烽�夋嫨鍏宠仈鏁欐潗', - duration: 1000, - icon: 'none', - }) - return false - } - app.MG.edu - .applyNewCourse({ - name: this.data.courseName, - description: this.data.courseDesc, - content: '', - icon: this.data.selectedBook.product.icon, - type: 'course', - config: '', - applyData: JSON.stringify({ - textBookId: this.data.selectedBook.product.id, - textBookName: this.data.selectedBook.product.name - }), - linkProductId: this.data.selectedBook.product.id, - maxClassCount: 999, - payPrice: 0 - }) - .then((res) => { - if (res) { - this.setData({ - visible: false, - selectedBook: null, - courseDesc: '', - courseName: '' - }) - this.getData() - } - }) }, // 杩斿洖椤堕儴 -- Gitblit v1.9.1