| | |
| | | total: 999, |
| | | loading: false |
| | | }, |
| | | updateCourse: false, |
| | | currentCourse: null, |
| | | submitLoading: false, |
| | | // 加载参数 |
| | | bottomLoading: false, |
| | | isMoreData: false, |
| | |
| | | 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 : '-' : '-' |
| | | } |
| | | }) |
| | | //触底加载新数据并保留老数据 |
| | |
| | | }) |
| | | }, |
| | | |
| | | // 重新申请 |
| | | 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.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() |
| | | } |
| | | }) |
| | | } |
| | | 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() |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 返回顶部 |