From bd459420ad636263be458374319c20d3eeb6f61a Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期四, 19 九月 2024 21:09:04 +0800
Subject: [PATCH] detail

---
 packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml |    1 
 packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js   |   13 ++-
 packageBookService/pages/bookServices/detail/components/learnTask/index.js               |  114 +++++++++++++++++++------------------
 packageBookService/pages/bookServices/detail/index.wxml                                  |    1 
 packageBookService/pages/bookServices/detail/index.js                                    |    3 
 assets/js/middleGround/tool.js                                                           |    4 
 6 files changed, 72 insertions(+), 64 deletions(-)

diff --git a/assets/js/middleGround/tool.js b/assets/js/middleGround/tool.js
index 890f81b..ecbcd87 100644
--- a/assets/js/middleGround/tool.js
+++ b/assets/js/middleGround/tool.js
@@ -260,9 +260,9 @@
         if (subItem.productLinkInfo && subItem.productLinkInfo.length) {
           let itemProductLinkInfo = subItem.productLinkInfo.find(citem => citem.Name == item.datas.Name)
           subItem.productLinkPath =
-            itemProductLinkInfo.LinkPath +
+            itemProductLinkInfo?.LinkPath +
             "\\" +
-            itemProductLinkInfo.CmsItemId;
+            itemProductLinkInfo?.CmsItemId;
         }
         if (subItem.linkInfo && subItem.linkInfo.length)
           subItem.linkPath =
diff --git a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js
index 5df1b31..8c64c1b 100644
--- a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js
+++ b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js
@@ -23,10 +23,13 @@
       type: Boolean,
       default: false
     },
-    isShowBuyCloundBtn:{
-      type:Boolean,
-      default:true
-    }
+    isShowBuyCloundBtn: {
+      type: Boolean,
+      default: true
+    },
+    learnTaskData: {
+      type: Object,
+    },
   },
 
   /**
@@ -74,7 +77,7 @@
     },
     goLearnTask() {
       wx.navigateTo({
-        url: `/packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.properties.bookId}`,
+        url: `/packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.properties.bookId}&cmsPath=${this.properties.learnTaskData?.productLinkPath}`,
       })
     },
     buyCloudLearnClass() {
diff --git a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml
index 889658b..2918849 100644
--- a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml
+++ b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml
@@ -48,6 +48,7 @@
     theme="primary"
     style="height: 72rpx; font-size: 28rpx; margin: 0 20rpx"
     bind:tap="goLearnTask"
+    wx:if="{{learnTaskData.name}}"
   >
     <view slot="content" class="btn-content">
       <image src="/static/images/bookService/detail/renwudan锛廼con.png" />
diff --git a/packageBookService/pages/bookServices/detail/components/learnTask/index.js b/packageBookService/pages/bookServices/detail/components/learnTask/index.js
index 37f6086..71b76f3 100644
--- a/packageBookService/pages/bookServices/detail/components/learnTask/index.js
+++ b/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,
@@ -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({
@@ -315,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) {
@@ -338,7 +343,6 @@
     this.setData({
       [data]: e.detail.value
     });
-    console.log(this.data.dataList)
   },
   //鍚屼即璇勪环
   onMateInput(e) {
@@ -461,7 +465,6 @@
     })
   },
   onInviteeChange(e) {
-    console.log(e)
     this.setData({
       invitee: e.detail.value
     });
@@ -478,7 +481,6 @@
     wx.showShareMenu({
       withShareTicket: true
     });
-    console.log(888)
   },
   submitComment() {
     let mateEvaluationList = []
diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js
index 2815779..61d49e7 100644
--- a/packageBookService/pages/bookServices/detail/index.js
+++ b/packageBookService/pages/bookServices/detail/index.js
@@ -55,6 +55,7 @@
     isShowBuyCloundMenu: false, //   浜戝涔犲叏閮ㄨ喘涔版寜閽槸鍚︽樉绀�
     isCloundHaveSaleMethod: false, // 浜戝涔犳槸鍚︽湁閿�鍞柟寮� 
     cloundMenuIsBuy: false,
+    learnTaskData: {},
     rejectCause: "", // 涓嬭浇鎷掔粷鍘熷洜
     buyIdList: [],
     shoppingCartGetId: [], // 宸茶喘涔癷d鍒楄〃
@@ -525,8 +526,8 @@
     app.MG.store.getProductDetail(query).then((res) => {
       this.setData({
         resourceCodeList: res.datas.cmsDatas[0].datas,
+        learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0]
       })
-      console.log('refcode', this.data.resourceCodeList);
     })
   },
   //璇锋眰瀛愬晢鍝佺殑鏂囦欢
diff --git a/packageBookService/pages/bookServices/detail/index.wxml b/packageBookService/pages/bookServices/detail/index.wxml
index 75e12b4..27016f9 100644
--- a/packageBookService/pages/bookServices/detail/index.wxml
+++ b/packageBookService/pages/bookServices/detail/index.wxml
@@ -259,6 +259,7 @@
                 isShowBuyCloundMenu="{{isShowBuyCloundMenu}}"
                 isShowBuyCloundBtn="{{isShowBuyCloundBtn}}"
                 bind:buyCloudLearnClass="buyCloudLearnClass"
+                learnTaskData="{{learnTaskData}}"
               ></learn-resource>
 
               <tree

--
Gitblit v1.9.1