11
QYF-GitLab1
2025-01-08 67a890445ceac9785ee62877b1e656fa4aeb0d5e
packageCourse/components/teaching/index.js
@@ -96,56 +96,63 @@
                cmsPath: data.productLinkPath
              })
              .then((res) => {
                const dataTeach = res.datas.cmsDatas[0]?.datas.find(
                  (item) => item.refCode == 'jsek_interaction'
                )
                app.MG.store
                  .getProductDetail({
                    path: '*',
                    queryType: '*',
                    productId: this.properties.bookId,
                    cmsPath: dataTeach.productLinkPath
                  })
                  .then((res) => {
                    let datas = res.datas.cmsDatas[0] ? res.datas.cmsDatas[0].datas : []
                    const dataRes = []
                    if (datas?.length > 0) {
                      datas.forEach(async (item) => {
                        const cmsRes = await app.MG.store
                          .getProductDetail({
                            path: '*',
                            queryType: '*',
                            productId: this.properties.bookId,
                            cmsPath: item.productLinkPath
                try {
                  const dataTeach = res.datas.cmsDatas[0]?.datas.find(
                    (item) => item.refCode == 'jsek_interaction'
                  )
                  app.MG.store
                    .getProductDetail({
                      path: '*',
                      queryType: '*',
                      productId: this.properties.bookId,
                      cmsPath: dataTeach.productLinkPath
                    })
                    .then((res) => {
                      let datas = res.datas.cmsDatas[0] ? res.datas.cmsDatas[0].datas : []
                      const dataRes = []
                      if (datas?.length > 0) {
                        datas.forEach(async (item) => {
                          const cmsRes = await app.MG.store
                            .getProductDetail({
                              path: '*',
                              queryType: '*',
                              productId: this.properties.bookId,
                              cmsPath: item.productLinkPath
                            })
                          if (
                            cmsRes.datas.cmsDatas[0].datas &&
                            cmsRes.datas.cmsDatas[0].datas.length > 0
                          ) {
                            cmsRes.datas.cmsDatas[0].datas.forEach((item, i) => {
                              item.subList = []
                              item.updateDate = '-'
                              if (this.data.dataList.length > 0) {
                                this.data.dataList.forEach((mitem) => {
                                  if (mitem.name == item.name) {
                                    item.updateDate = moment(mitem.updateDate).format(
                                      'YYYY-MM-DD HH:mm:ss'
                                    )
                                    item.subList.push(mitem)
                                  }
                                })
                              }
                              dataRes.push(item)
                            })
                          }
                          const resList = dataRes.sort((a, b) => b.subList.length - a.subList.length)
                          this.setData({
                            cmsDataList: resList,
                            loading: false
                          })
                        if (
                          cmsRes.datas.cmsDatas[0].datas &&
                          cmsRes.datas.cmsDatas[0].datas.length > 0
                        ) {
                          cmsRes.datas.cmsDatas[0].datas.forEach((item, i) => {
                            item.subList = []
                            item.updateDate = '-'
                            if (this.data.dataList.length > 0) {
                              this.data.dataList.forEach((mitem) => {
                                if (mitem.name == item.name) {
                                  item.updateDate = moment(mitem.updateDate).format(
                                    'YYYY-MM-DD HH:mm:ss'
                                  )
                                  item.subList.push(mitem)
                                }
                              })
                            }
                            dataRes.push(item)
                          })
                        }
                        const resList = dataRes.sort((a, b) => b.subList.length - a.subList.length)
                        this.setData({
                          cmsDataList: resList,
                          loading: false
                        })
                      })
                    }
                      }
                    })
                } catch (error) {
                  this.setData({
                    cmsDataList: [],
                    loading: false
                  })
                }
              })
          } catch (error) {
            this.setData({
@@ -283,6 +290,7 @@
      }
      return arr
    },
    findIndexByValue(res, type) {
      for (let i = 0; i < res.length; i++) {
        if (res[i].value == type) {