From f8f448ee269d99595abe9c1a3de1a0987843f731 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期日, 29 九月 2024 10:10:23 +0800
Subject: [PATCH] rwd

---
 packageBookService/pages/bookServices/detail/components/learnTask/index.js |  229 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 178 insertions(+), 51 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/learnTask/index.js b/packageBookService/pages/bookServices/detail/components/learnTask/index.js
index 71b76f3..db81061 100644
--- a/packageBookService/pages/bookServices/detail/components/learnTask/index.js
+++ b/packageBookService/pages/bookServices/detail/components/learnTask/index.js
@@ -15,7 +15,7 @@
     name: '',
     school: '',
     class: '',
-    learnTime: '2',
+    learnTime: '0灏忔椂',
     taskShow: false,
     dataList: [], //浠诲姟鍗�
     tasksListData: [], //宸插~鍐欎换鍔″崟messsge
@@ -24,7 +24,7 @@
     userId: 0,
     userName: '',
     isUpdate: false,
-    taskId: 0, //榛樿閫変腑鐩綍id
+    taskId: '', //榛樿閫変腑鐩綍id
     autosize: {
       maxHeight: 120,
       minHeight: 80,
@@ -32,6 +32,23 @@
     disabled: false,
     dialogVisible: false,
     invitee: "",
+    teacherEvaluated: false,
+    evaluated: false,
+    rowCol: [{
+        width: '50%',
+      },
+      {
+        width: '100%'
+      },
+      {
+        width: '80%'
+      },
+      {
+        width: '100%'
+      }, {
+        width: '100%'
+      },
+    ],
   },
   onShow() {
     var that = this;
@@ -52,16 +69,16 @@
       this.setData({
         bookId: options.bookId,
         cmsPath: options.cmsPath,
-        taskId: options.bookId,
+        taskId: options.taskId,
         consumer: options.consumer,
         userId: options.userId,
-        userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).name
+        userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).nickName
       });
       if (options.consumer) {
         this.setData({
           cmsPath: options.cmsPath,
           bookId: options.bookId,
-          taskId: options.bookId,
+          taskId: options.taskId,
           consumer: options.consumer,
           userId: options.userId,
           disabled: true
@@ -73,12 +90,42 @@
         });
       }
       this.getResourceData()
+      this.getLearnTime()
     }
 
   },
 
+  getLearnTime() {
+    app.MG.identity
+      .getUserKey({
+        domain: 'cloudLearningTime',
+        keys: [this.data.bookId]
+      })
+      .then((res) => {
+        if (res.length > 0 && JSON.parse(res[0].value) && JSON.parse(res[0].value).length > 0) {
+          let time = JSON.parse(res[0].value)[0].learnTime
+          let minutes = Number(time) / (1000 * 60)
+          let hours = Number(time) / (1000 * 60 * 60)
+          if (minutes > 0 && minutes < 60) {
+            this.setData({
+              learnTime: Math.round(minutes) + '鍒嗛挓',
+            });
+          } else if (minutes > 60) {
+            this.setData({
+              learnTime: Math.round(hours) + '灏忔椂',
+            });
+          } else {
+            this.setData({
+              learnTime: '0灏忔椂',
+            });
+          }
+        }
+      })
+  },
+
   getResourceData() {
     this.setData({
+      menuList: [],
       loading: true,
     });
     let query = {
@@ -124,10 +171,12 @@
           }
           dataList.push(item)
         })
-        this.setData({
-          menuList: dataList,
-          loading: false,
-        });
+        setTimeout(() => {
+          this.setData({
+            menuList: dataList,
+            loading: false,
+          });
+        }, 500)
         if (this.data.taskId) {
           setTimeout(() => {
             this.data.menuList.forEach((item) => {
@@ -160,8 +209,14 @@
           }, 500)
         }
       }
-      this.getTasksList()
+      setTimeout(() => {
+        this.getTasksList()
+      }, 500)
     })
+  },
+  getTask(e) {
+    let item = e.currentTarget.dataset.item
+    this.taskSelect(item)
   },
 
   onVisibleChange(e) {
@@ -191,7 +246,7 @@
       this.setData({
         tasksListData: res.datas,
       });
-      if (this.data.taskInfo) {
+      if (this.data.taskInfo.name) {
         this.taskSelect(this.data.taskInfo)
       }
     })
@@ -214,33 +269,35 @@
                 school: content.school,
                 class: content.class,
                 learnTime: content.learnTime,
-                taskShow: true,
               });
-              this.getChildTasksList()
-              if (content.evaluate.length > 0) {
-                content.evaluate.forEach((element) => {
-                  if (this.data.consumer == 'classmate') {
-                    element.mateEvaluation = ''
-                  }
-                  if (this.data.consumer == 'teacher') {
-                    element.teacherEvaluation = ''
-                  }
-                })
+              if (this.data.name && this.data.school && this.data.class) {
                 this.setData({
-                  dataList: content.evaluate,
-                });
-
+                  taskShow: true,
+                })
+                this.getChildTasksList()
+                if (content.evaluate.length > 0) {
+                  this.setData({
+                    dataList: content.evaluate,
+                  });
+                }
+              } else {
+                wx.showToast({
+                  title: "璇峰厛濉啓涓汉淇℃伅",
+                  icon: 'none',
+                  duration: 1000
+                })
               }
             }
           } else {
-            this.goDetail(item)
+            return false
           }
         })
-
-      } else {
+      }
+      if (this.data.dataList.length == 0) {
         this.goDetail(item)
       }
     }
+
   },
   goDetail(item) {
     this.setData({
@@ -272,9 +329,18 @@
           item.teacherEvaluation = ''
         })
       }
-      this.setData({
-        dataList: res.datas.cmsDatas[0].datas,
-      });
+      if (this.data.name && this.data.school && this.data.class) {
+        this.setData({
+          dataList: res.datas.cmsDatas[0].datas,
+          taskShow: true,
+        })
+      } else {
+        wx.showToast({
+          title: "璇峰厛濉啓涓汉淇℃伅",
+          icon: 'none',
+          duration: 1000
+        })
+      }
     })
   },
   getChildTasksList() {
@@ -293,19 +359,49 @@
       if (res.datas.length > 0) {
         let list = []
         this.data.dataList.forEach((item) => {
+          item.teacherEvaluation = []
+          item.mateEvaluation = []
           res.datas.forEach((item1) => {
             let content = JSON.parse(item1.content)
-            if (content.teacherComment) {
+            if (content.teacherComment.length > 0) {
               content.teacherComment.forEach((item2) => {
                 if (item.id == item2.childTaskId) {
-                  item.teacherEvaluation.push(item2)
+                  item.teacherEvaluation = [item2]
+                  if (this.data.consumer == 'teacher') {
+                    this.setData({
+                      evaluated: true
+                    });
+                  }
                 }
               })
             }
-            if (content.mateComment) {
+            if (item.teacherEvaluation && item.teacherEvaluation.length > 0) {
+              this.setData({
+                teacherEvaluated: true
+              });
+            }
+            if (content.mateComment.length > 0) {
               content.mateComment.forEach((item3) => {
                 if (item.id == item3.childTaskId) {
-                  item.mateEvaluation.push(item3)
+                  item.mateEvaluation = [...item.mateEvaluation, item3]
+                  if (this.data.consumer == 'classmate') {
+                    if (item.mateEvaluation && item.mateEvaluation.length > 0) {
+                      let data = item.mateEvaluation.find(
+                        (item) => item.userId == this.data.userId
+                      )
+                      if (data) {
+                        this.setData({
+                          evaluated: true
+                        });
+                        item.mateEvaluation = [data]
+                      } else {
+                        this.setData({
+                          evaluated: false
+                        });
+                        item.mateEvaluation = ''
+                      }
+                    }
+                  }
                 }
               })
             }
@@ -316,6 +412,23 @@
           dataList: list
         });
       }
+    })
+  },
+
+  // 涓汉淇℃伅濉啓
+  bindTnputBlur(e) {
+    this.setData({
+      name: e.detail.value
+    })
+  },
+  onSchoolInput(e) {
+    this.setData({
+      school: e.detail.value
+    })
+  },
+  bindClassBlur(e) {
+    this.setData({
+      class: e.detail.value
     })
   },
 
@@ -482,42 +595,56 @@
       withShareTicket: true
     });
   },
+  confirmBtn1() {
+    wx.showToast({
+      title: "鏁欏笀宸茬粡璇勪环锛屼笉鑳藉啀閭�璇锋暀甯堣瘎浠凤紒",
+      icon: 'none',
+      duration: 1000
+    })
+  },
   submitComment() {
     let mateEvaluationList = []
     let teacherEvaluationList = []
     this.data.dataList.forEach((item) => {
       if (this.data.consumer == 'classmate') {
-        if (item.mateEvaluation == '') {
-          wx.showToast({
-            title: "璇峰厛濉瘎浠�",
-            icon: 'none',
-            duration: 1000
-          })
-        } else {
+        if (item.mateEvaluation && item.mateEvaluation != '') {
           mateEvaluationList.push({
             childTaskId: item.id,
+            userId: this.data.userId,
             userName: this.data.userName,
             evaluation: item.mateEvaluation
           })
         }
       }
-
       if (this.data.consumer == 'teacher') {
-        if (item.teacherEvaluation == '') {
-          wx.showToast({
-            title: "璇峰厛濉瘎浠�",
-            icon: 'none',
-            duration: 1000
-          })
-        } else {
+        if (item.teacherEvaluation && item.teacherEvaluation != '') {
           teacherEvaluationList.push({
             childTaskId: item.id,
+            userId: this.data.userId,
             userName: this.data.userName,
             evaluation: item.teacherEvaluation
           })
         }
       }
     })
+    if (this.data.consumer == 'classmate') {
+      if (mateEvaluationList.length < this.data.dataList.length) {
+        wx.showToast({
+          title: "璇峰厛濉啓璇勪环",
+          icon: 'none',
+          duration: 1000
+        })
+      }
+    }
+    if (this.data.consumer == 'teacher') {
+      if (teacherEvaluationList.length < this.data.dataList.length) {
+        wx.showToast({
+          title: "璇峰厛濉啓璇勪环",
+          icon: 'none',
+          duration: 1000
+        })
+      }
+    }
     let content = {
       id: this.data.taskInfo.id,
       taskName: this.data.taskInfo.name,
@@ -565,7 +692,7 @@
   onShareAppMessage() {
     return {
       title: '璇勪环瀛︿範浠诲姟鍗�',
-      path: `packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.data.bookId}&consumer=${this.data.invitee}&taskId=${this.data.taskInfo.id}&userId=${this.data.userId}`,
+      path: `packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.data.bookId}&consumer=${this.data.invitee}&taskId=${this.data.taskInfo.id}&userId=${this.data.userId}&cmsPath=${this.data.cmsPath}`,
       imgUrl: 'https://jsek.bnuic.com/home/image/click-icon.png',
     }
   }

--
Gitblit v1.9.1