litian
2024-09-19 bd459420ad636263be458374319c20d3eeb6f61a
packageBookService/pages/bookServices/detail/components/learnTask/index.js
@@ -7,6 +7,7 @@
  data: {
    height: '', //屏幕高度
    bookId: '',
    cmsPath: '',
    consumer: '',
    bookInfo: {},
    menuList: [],
@@ -48,9 +49,9 @@
   */
  onLoad(options) {
    if (options) {
      console.log(options, 666)
      this.setData({
        bookId: options.bookId,
        cmsPath: options.cmsPath,
        taskId: options.bookId,
        consumer: options.consumer,
        userId: options.userId,
@@ -58,6 +59,7 @@
      });
      if (options.consumer) {
        this.setData({
          cmsPath: options.cmsPath,
          bookId: options.bookId,
          taskId: options.bookId,
          consumer: options.consumer,
@@ -66,7 +68,7 @@
        });
      } else {
        this.setData({
          userId: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).id,
          userId: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).userId,
          disabled: false
        });
      }
@@ -83,7 +85,7 @@
      path: '*',
      queryType: '*',
      productId: this.data.bookId,
      cmsPath: 'jsek_learningTasks',
      cmsPath: this.data.cmsPath,
      // cmsType: '*',
      itemFields: {
        SysType: 'CmsFolder'
@@ -99,60 +101,69 @@
      });
      if (res.datas.cmsDatas[0].datas) {
        let list = res.datas.cmsDatas[0].datas
        let dataList = []
        list.forEach((item) => {
          if (item.childrenFolderCount > 0) {
            let query = {
              path: '*',
              queryType: '*',
              productId: this.data.bookId,
              cmsPath: item.productLinkPath,
              // cmsType: '*',
              itemFields: {
                SysType: 'CmsFolder'
              },
              pading: {
                start: 0,
                size: 99
              }
            }
            app.MG.store.getProductDetail(query).then((res) => {
              item.children = res.datas.cmsDatas[0].datas
            })
          }
          dataList.push(item)
        })
        this.setData({
          menuList: list,
          menuList: dataList,
          loading: false,
        });
        if (this.data.taskId) {
          this.data.menuList.forEach((item) => {
            if (item.id == this.data.taskId) {
          setTimeout(() => {
            this.data.menuList.forEach((item) => {
              if (item.id == this.data.taskId) {
                this.setData({
                  taskInfo: item,
                });
              } else if (item.children) {
                item.children.forEach((item1) => {
                  if (item1.id == this.data.taskId) {
                    this.setData({
                      taskInfo: item1,
                    });
                  }
                })
              }
            })
          }, 500)
        } else {
          setTimeout(() => {
            if (this.data.menuList[0].children) {
              this.setData({
                taskInfo: item,
                taskInfo: this.data.menuList[0].children[0],
              });
            } else {
              this.setData({
                taskInfo: this.data.menuList[0],
              });
            }
          })
        } else {
          this.setData({
            taskInfo: this.data.menuList[0],
          });
          }, 500)
        }
      }
      this.getTasksList()
    })
  },
  getTask(e) {
    console.log(e, 123)
    let data = e.currentTarget.dataset.item
    if (data.childrenFolderCount > 0) {
      let query = {
        path: '*',
        queryType: '*',
        productId: this.data.bookId,
        cmsPath: data.productLinkPath,
        // cmsType: '*',
        itemFields: {
          SysType: 'CmsFolder'
        },
        pading: {
          start: 0,
          size: 99
        }
      }
      app.MG.store.getProductDetail(query).then((res1) => {
        this.data.menuList.forEach((item) => {
          if (item.id == data.id) {
            item.children = res1.datas.cmsDatas[0].datas
          }
        })
      })
    } else {
      this.setData({
        taskShow: true,
      });
    }
    this.taskSelect(data)
  },
  onVisibleChange(e) {
    this.setData({
      taskShow: e.detail.visible,
@@ -180,7 +191,9 @@
      this.setData({
        tasksListData: res.datas,
      });
      this.taskSelect(this.data.taskInfo)
      if (this.data.taskInfo) {
        this.taskSelect(this.data.taskInfo)
      }
    })
  },
  taskSelect(item) {
@@ -192,12 +205,6 @@
      if (this.data.tasksListData.length > 0) {
        this.data.tasksListData.forEach((item1) => {
          let content = JSON.parse(item1.content)
          this.setData({
            name: content.userName,
            school: content.school,
            class: content.class,
            learnTime: content.learnTime,
          });
          if (content.id == this.data.taskInfo.id) {
            if (content.userId == this.data.userId) {
              this.setData({
@@ -308,7 +315,6 @@
        this.setData({
          dataList: list
        });
        console.log(this.data.dataList, 777)
      }
    })
  },
@@ -316,13 +322,11 @@
  //任务填写
  //反思
  onIntrospectionInput(e) {
    console.log(e)
    let index = e.target.dataset.index
    let data = 'dataList[' + index + '].introspection'
    this.setData({
      [data]: e.detail.value
    });
    console.log(this.data.dataList)
  },
  //完成情况
  onCompletionInput(e) {
@@ -339,7 +343,6 @@
    this.setData({
      [data]: e.detail.value
    });
    console.log(this.data.dataList)
  },
  //同伴评价
  onMateInput(e) {
@@ -462,7 +465,6 @@
    })
  },
  onInviteeChange(e) {
    console.log(e)
    this.setData({
      invitee: e.detail.value
    });
@@ -479,7 +481,6 @@
    wx.showShareMenu({
      withShareTicket: true
    });
    console.log(888)
  },
  submitComment() {
    let mateEvaluationList = []