From 45b2c022e27dda53ee4e5266fbdbdf1ac3aa4c65 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 05 八月 2022 16:47:59 +0800
Subject: [PATCH] 2022.8.5

---
 pages/home/home.js |  203 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 152 insertions(+), 51 deletions(-)

diff --git a/pages/home/home.js b/pages/home/home.js
index 78907d2..1b765f9 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -1,4 +1,9 @@
 // pages/home/home.js
+const userservice = require("../../service/userservice")
+const assessmentService = require("../../service/assessmentservice")
+const lawservice = require("../../service/lawservice")
+const moment = require('../../utils/moment.min')
+const app = getApp()
 /**
  * 棣栭〉
  */
@@ -8,76 +13,172 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    notices:[{
+    notices: [{
       notice: "鏈湀瀹堟硶鎵胯鑷祴鏅鸿瘎宸插紑鍚紝璇峰強鏃惰繘琛岃瘎浠�",
       time: "2022/3/1"
-    },{
-      notice: "鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋",
-      time: "涓�澶╁墠"
-    },{
-      notice: "鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋",
-      time: "涓�澶╁墠"
-    }]
+    }],
+
+    dynamic: [{
+      title: "浼佷笟钀ヤ笟鎵х収銆侀鍝佺粡钀ヨ鍙瘉涓㈠け璇ュ浣曡ˉ棰�",
+      time: "2022骞�4鏈�5鏃�",
+      views: 2012,
+      pic: "/res/icons/temp_pic_1.png"
+    }],
+
+    nextEvaluationTime: '2022骞�6鏈�9鏃�',
+    userRealName: '',
+
+    //鍘嗗彶璇勫垎璇︽儏
+    historyPoint: {
+      time: '娴嬭瘎鍛ㄦ湡----骞�--鏈�',
+      score: '--',
+      rank: '--',
+      legalIndex: '--',
+      illegalIndex: '--'
+    },
+    period: ''
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad: function (options) {
+    wx.getStorage({
+      key: 'accessToken',
+      success: (result) => {
+        console.log(result.data);
+      },
+      fail: (res) => {},
+      complete: (res) => {},
+    })
+
+    this.getNextEvaluationTime()
+    this.getNotice()
+    this.getUserInfo()
+    this.getHistoryPoint()
+    this.getNews()
+  },
+
+  getNextEvaluationTime() {
+    let now = moment().add(1, 'months')
+    this.setData({
+      nextEvaluationTime: now.format("YYYY骞碝M鏈�10鏃�")
+    })
+  },
+
+  getUserInfo() {
+    this.setData({
+      userRealName: app.globalData.userInfo.realname
+    })
+  },
+
+  getNotice() {
     this.setData({
       notices: [{
         notice: "鏈湀瀹堟硶鎵胯鑷祴鏅鸿瘎宸插紑鍚紝璇峰強鏃惰繘琛岃瘎浠�",
-        time: "2022/3/8"
+        time: "2022/5/9"
       }]
     })
   },
 
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
-   */
-  onReady: function () {
+  getHistoryPoint() {
+    var that = this
+    assessmentService.getHistoryPoint(app.globalData.accessToken.userId, 1, {
+      success(data) {
+        let lastOne = data[0]
+        let year = lastOne.updateDate.substring(0, 4)
+        let month = lastOne.updateDate.substring(5, 7)
+        that.setData({
+          historyPoint: {
+            time: `娴嬭瘎鍛ㄦ湡${year}骞�${month}鏈坄,
+            score: lastOne.totalPoint,
+            rank: lastOne.rank,
+            legalIndex: lastOne.level,
+            illegalIndex: lastOne.level
+          }
+        })
+      }
+    })
+  },
 
+  getNews() {
+    var that = this
+    let user = app.globalData.userInfo
+    lawservice.getLawRegulations(user.guid, 1, user.extension2, {
+      success(data) {
+        let laws = []
+        data.forEach(d => {
+          laws.push({
+            title: d.lrResourcetitle,
+            time: d.lrPublishdate.substring(0, 10),
+            views: parseInt(Math.random() * 1000 + 10),
+            pic: d.lrPicurl,
+            url: d.lrBodyurl,
+            fileType: d.lrResourcefiletype,
+          })
+        });
+        that.setData({
+          dynamic: laws
+        })
+      }
+    })
   },
 
   /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+   * 椤甸潰璺宠浆
    */
-  onShow: function () {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
-   */
-  onHide: function () {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
-   */
-  onUnload: function () {
-
-  },
-
-  /**
-   * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
-   */
-  onPullDownRefresh: function () {
-
-  },
-
-  /**
-   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
-   */
-  onShareAppMessage: function () {
-
+  goto: function (e) {
+    var url = ""
+    var index = e.currentTarget.dataset.index
+    switch (index) {
+      case "0":
+        //娴嬭瘎鍘嗗彶璁板綍
+        url = ""
+        break;
+      case "1":
+        //宸ヤ綔鎻愰啋
+        url = "/pages/notice/notice"
+        break;
+      case "2":
+        //鏅鸿兘鍦ㄧ嚎鍜ㄨ
+        url = ""
+        return;
+      case "3":
+        //鍦ㄧ嚎瀹堟硶瀛︿範
+        
+        url = `/pages/learn/learn`
+        
+        break;
+      case "4":
+        //瀹堟硶鍔ㄦ��
+        // url = "/pages/text/text"
+        let bodyUrl = e.currentTarget.dataset.url
+        let fileType = e.currentTarget.dataset.filetype
+        wx.downloadFile({
+          // 绀轰緥 url锛屽苟闈炵湡瀹炲瓨鍦�
+          url: bodyUrl,
+          success: function (res) {
+            const filePath = res.tempFilePath
+            var t = filePath.split('.')[filePath.split('.').length - 1]
+            wx.openDocument({
+              filePath: filePath,
+              success: function (res) {
+                console.log('鎵撳紑鏂囨。鎴愬姛')
+              },
+              fail (error) {
+                console.log(error);
+              }
+            })
+          }
+        })
+        break;
+      case "5":
+        break;
+    }
+    if (url != "") {
+      wx.navigateTo({
+        url: url
+      })
+    }
   }
 })
\ No newline at end of file

--
Gitblit v1.9.3