From 5d8e52e398bff7bc8f83e8f5b8a387175b958c98 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 24 二月 2023 10:20:18 +0800
Subject: [PATCH] 2023.2.24

---
 pages/home/home.js |   89 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 74 insertions(+), 15 deletions(-)

diff --git a/pages/home/home.js b/pages/home/home.js
index 3211b13..652d042 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -29,6 +29,7 @@
     userRealName: '',
 
     //鍘嗗彶璇勫垎璇︽儏
+    assessmentCompleted: false,
     historyPoint: {
       time: '娴嬭瘎鍛ㄦ湡----骞�--鏈�',
       score: '--',
@@ -38,7 +39,8 @@
       period: ''
     },
     //鍙拌处瀹屾垚鎯呭喌
-    ledgerInfo: {
+    ledgerCompleted: false,
+    monthInfo: {
       //蹇呭~椤规�绘暟
       totalMust: 0,
       //蹇呭~椤规彁浜ゆ暟
@@ -55,6 +57,13 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad: function (options) {
+    //鍒ゆ柇鐢ㄦ埛鏄惁涓洪娆$櫥褰曪紝鍐冲畾鏄惁寮哄埗淇敼榛樿瀵嗙爜
+    if (app.globalData.userInfo.remark == null || app.globalData.userInfo.remark == '') {
+      wx.navigateTo({
+        url: '/pages/mUser/pChangepw/pChangepw',
+      })
+    }
+
     wx.getStorage({
       key: 'accessToken',
       success: (result) => {
@@ -67,6 +76,22 @@
     this.getNextEvaluationTime()
     this.getNotice()
     this.getUserInfo()
+    this.getHistoryPoint()
+    this.getNews()
+    this.getCommitment()
+    this.getLedgerType()
+  },
+
+  onShow() {
+    if (app.globalData.isLogin) {
+
+    }
+  },
+
+  onPullDownRefresh() {
+    console.log('onPullDownRefresh');
+    this.getNextEvaluationTime()
+    this.getNotice()
     this.getHistoryPoint()
     this.getNews()
     this.getCommitment()
@@ -115,9 +140,15 @@
         let lastOne = data[0]
         let year = lastOne.updateDate.substring(0, 4)
         let month = lastOne.updateDate.substring(5, 7)
+        const now = moment()
+        if (now.year() == year && now.month() + 1 == month) {
+          that.setData({
+            assessmentCompleted: true
+          })
+        }
         that.setData({
           historyPoint: {
-            time: `娴嬭瘎鍛ㄦ湡${year}骞�${month}鏈坄,
+            time: `鏈�鏂颁竴鏈� ${year}骞�${month}鏈坄,
             score: lastOne.totalPoint,
             rank: lastOne.rank,
             legalIndex: lastOne.level,
@@ -132,7 +163,10 @@
   getNews() {
     var that = this
     let user = app.globalData.userInfo
-    lawservice.getLawRegulations(user.guid, 1, user.extension2, {
+    lawservice.getLawRegulations(user.guid, 1, {
+      sceneTypeId: user.extension2,
+      fileType: 1
+    }, {
       success(data) {
         let laws = []
         data.forEach(d => {
@@ -164,7 +198,7 @@
           let cTime = moment(c.cmCreateTime)
           let leftDays = cTime.add(1, 'years').diff(moment(), 'days')
           that.setData({
-            promise: {
+            promsieInfo: {
               leftDays: leftDays
             }
           })
@@ -179,6 +213,13 @@
     ledgerservice.getLedgerSummary(app.globalData.accessToken.userId, app.globalData.userInfo.extension2, time, {
       success(res) {
         that.parseLedgerType(res)
+      },
+      complete() {
+        wx.stopPullDownRefresh({
+          success: (res) => {},
+          fail: (res) => {},
+          complete: (res) => {},
+        })
       }
     })
   },
@@ -187,20 +228,34 @@
     let monthInfo = {
       totalMust: 0,
       finishedMust: 0,
+      totalSelf: 0,
+      finishedSelf: 0
     }
     subtypes.forEach(s => {
       //鏈堝害缁熻
       if (s.needUpdate) {
         monthInfo.totalMust++
+        //缁熻鑷贰鏌ョ被鍨嬬殑鍙拌处锛岀被鍒负-1锛堟殏瀹氾級
+        if (s.ledgerTypeId == -1) {
+          monthInfo.totalSelf++
+        }
         if (s.upLoad) {
           monthInfo.finishedMust++
+          if (s.ledgerTypeId == -1) {
+            monthInfo.finishedSelf++
+          }
         }
       }
     });
 
-    monthInfo.percent = Math.round(monthInfo.finishedMust / monthInfo.totalMust * 100)
+    monthInfo.percent = monthInfo.totalMust == 0 ? 0 : Math.round(monthInfo.finishedMust / monthInfo.totalMust * 100)
+    monthInfo.percent2 = monthInfo.totalSelf == 0 ? 0 : Math.round(monthInfo.finishedSelf / monthInfo.totalSelf * 100)
 
-    this.setData({monthInfo})
+    this.setData({
+      monthInfo,
+      ledgerCompleted: monthInfo.percent >= 100 && monthInfo.percent2 >= 100,
+      // ledgerCompleted: true
+    })
   },
 
   /**
@@ -212,29 +267,33 @@
     switch (index) {
       case "0":
         //娴嬭瘎鍘嗗彶璁板綍
-        url = `/pages/gradereport/gradereport?period=${this.data.historyPoint.period}`
+        if (this.data.historyPoint.period == '') {
+          url = `/pages/mAssessment/grade/grade`
+        } else {
+          url = `/pages/mAssessment/gradereport/gradereport?period=${this.data.historyPoint.period}`
+        }
         break;
       case "5":
         wx.switchTab({
-          url: '/pages/module_ledger/ledgerhome/ledgerhome',
+          url: '/pages/mLedger/ledgerhome/ledgerhome',
         })
         return;
       case "6":
         wx.switchTab({
-          url: '/pages/promise/promise',
+          url: '/pages/mPromise/promisehome/promise',
         })
-        break;
+        return;
       case "1":
         //宸ヤ綔鎻愰啋
-        url = "/pages/notice/notice"
+        url = "/pages/mNotice/notice/notice"
         break;
       case "2":
         //鏅鸿兘鍦ㄧ嚎鍜ㄨ
-        url = "/pages/module_consult/consulthome/consulthome"
+        url = "/pages/mConsult/consulthome/consulthome"
         break;
       case "3":
         //鍦ㄧ嚎瀹堟硶瀛︿範
-        url = `/pages/learn/learn`
+        url = `/pages/mLearn/learn/learn`
         break;
       case "4":
         //瀹堟硶鍔ㄦ��
@@ -242,7 +301,7 @@
         let bodyUrl = e.currentTarget.dataset.url
         let fileType = e.currentTarget.dataset.filetype
         wx.showLoading({
-          title: ' 鏂囦欢涓嬭浇涓�',
+          title: ' 鍔犺浇涓�',
           mask: true,
         })
         wx.downloadFile({
@@ -261,7 +320,7 @@
             })
           }
         })
-        break;
+        return;
     }
     if (url != "") {
       wx.navigateTo({

--
Gitblit v1.9.3