From c3d81e837e6350b431583c5cdcc1e0e09b4376c0 Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期三, 18 十二月 2024 16:45:47 +0800 Subject: [PATCH] 111 --- packageCourse/pages/course/index.js | 146 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 102 insertions(+), 44 deletions(-) diff --git a/packageCourse/pages/course/index.js b/packageCourse/pages/course/index.js index 5a33ce7..65b3410 100644 --- a/packageCourse/pages/course/index.js +++ b/packageCourse/pages/course/index.js @@ -31,6 +31,8 @@ total: 999, loading: false }, + updateCourse: false, + currentCourse: null, submitLoading: false, // 鍔犺浇鍙傛暟 bottomLoading: false, @@ -117,7 +119,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 : '-' : '-' } }) //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹� @@ -242,55 +244,111 @@ }) }, - // 鏂板缓璇剧▼ - submitCourse() { - if (!this.data.courseName) { - wx.showToast({ - title: '璇峰~鍐欒绋嬪悕绉�', - duration: 1000, - icon: 'none', - }) - return false + // 閲嶆柊鐢宠 + replayCourse(e) { + const { + item + } = e.currentTarget.dataset + if (!item.linkProduct.icon) { + item.linkProduct.icon = '' } - if (!this.data.selectedBook) { - wx.showToast({ - title: '璇烽�夋嫨鍏宠仈鏁欐潗', - duration: 1000, - icon: 'none', - }) - return false + const data = { + product: item.linkProduct } this.setData({ - submitLoading: true + currentCourse: item, + courseName: item.name, + courseDesc: item.description, + selectedBook: data, + updateCourse: true, + visible: 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 + this.getTextBook() + }, + + // 鏂板缓璇剧▼ + submitCourse() { + if (this.data.updateCourse) { + this.setData({ + submitLoading: true }) - .then((res) => { - if (res) { - this.setData({ - visible: false, - selectedBook: null, - courseDesc: '', - courseName: '', - submitLoading: false - }) - this.getData() - } + app.MG.edu + .updateCourse({ + courseId: this.data.currentCourse.id, + name: this.data.currentCourse.name, + description: this.data.currentCourse.desc + }) + .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() + } + }) + } }, // 杩斿洖椤堕儴 -- Gitblit v1.9.1