111
QYF-GitLab1
2024-12-18 c3d81e837e6350b431583c5cdcc1e0e09b4376c0
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,8 +244,63 @@
    })
  },
  // 重新申请
  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.updateCourse) {
      this.setData({
        submitLoading: true
      })
      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: '请填写课程名称',
@@ -291,6 +348,7 @@
          this.getData()
        }
      })
    }
  },
  // 返回顶部