From eb7366f400867d3f401fe60f06d848d6d1448457 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 17 十月 2022 17:41:56 +0800
Subject: [PATCH] 2022.10.17
---
pages/home/home.js | 322 ++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 268 insertions(+), 54 deletions(-)
diff --git a/pages/home/home.js b/pages/home/home.js
index 78907d2..09bf701 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -1,4 +1,12 @@
// pages/home/home.js
+const userservice = require("../../service/userservice")
+const notificationservice = require("../../service/notificationservice")
+const assessmentService = require("../../service/assessmentservice")
+const lawservice = require("../../service/lawservice")
+const promiseservice = require("../../service/promiseservice")
+const ledgerservice = require("../../service/ledgerservice")
+const moment = require('../../utils/moment.min')
+const app = getApp()
/**
* 棣栭〉
*/
@@ -8,76 +16,282 @@
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
- notices:[{
- notice: "鏈湀瀹堟硶鎵胯鑷祴鏅鸿瘎宸插紑鍚紝璇峰強鏃惰繘琛岃瘎浠�",
- time: "2022/3/1"
- },{
- notice: "鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋",
- time: "涓�澶╁墠"
- },{
- notice: "鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋鎻愰啋",
- time: "涓�澶╁墠"
- }]
+ notices: [],
+
+ 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: ''
+ },
+ //鍙拌处瀹屾垚鎯呭喌
+ ledgerInfo: {
+ //蹇呭~椤规�绘暟
+ totalMust: 0,
+ //蹇呭~椤规彁浜ゆ暟
+ finishedMust: 0,
+ },
+ //鎵胯瀹屾垚鎯呭喌
+ promsieInfo: {
+ leftDays: 0
+ }
+
},
/**
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
*/
onLoad: function (options) {
+ //鍒ゆ柇鐢ㄦ埛鏄惁涓洪娆$櫥褰曪紝鍐冲畾鏄惁寮哄埗淇敼榛樿瀵嗙爜
+ if (app.globalData.userInfo.remark == null || app.globalData.userInfo.remark == '') {
+ wx.navigateTo({
+ url: '/pages/m_user/p_changepw/p_changepw',
+ })
+ }
+
+ wx.getStorage({
+ key: 'accessToken',
+ success: (result) => {
+ console.log(result.data);
+ },
+ fail: (res) => {},
+ complete: (res) => {},
+ })
+
+ this.getNextEvaluationTime()
+ this.getNotice()
+ this.getUserInfo()
+ this.getHistoryPoint()
+ this.getNews()
+ this.getCommitment()
+ this.getLedgerType()
+ },
+
+ onShow(){
+ if (app.globalData.isLogin) {
+
+ }
+ },
+
+ onPullDownRefresh(){
+ console.log('onPullDownRefresh');
+ wx.stopPullDownRefresh({
+ success: (res) => {},
+ fail: (res) => {},
+ complete: (res) => {},
+ })
+ },
+
+ getNextEvaluationTime() {
+ let now = moment().add(1, 'months')
this.setData({
- notices: [{
- notice: "鏈湀瀹堟硶鎵胯鑷祴鏅鸿瘎宸插紑鍚紝璇峰強鏃惰繘琛岃瘎浠�",
- time: "2022/3/8"
- }]
+ nextEvaluationTime: now.format("YYYY骞碝M鏈�10鏃�")
+ })
+ },
+
+ getUserInfo() {
+ this.setData({
+ userRealName: app.globalData.userInfo.realname
+ })
+ },
+
+ getNotice() {
+ var that = this
+ notificationservice.getNotification(app.globalData.accessToken.userId, 1, {
+ success(res) {
+ let notices = []
+ res.forEach(r => {
+ notices.push({
+ notice: r.title,
+ time: moment(r.updateTime).format('YYYY/MM/DD'),
+ isRead: r.hasRead
+ })
+ that.setData({
+ notices
+ })
+ });
+ }
+ })
+ },
+
+ getHistoryPoint() {
+ var that = this
+ assessmentService.getHistoryPoint(app.globalData.accessToken.userId, 1, {
+ success(data) {
+ if (data.length == 0) {
+ return
+ }
+ 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,
+ period: lastOne.period
+ }
+ })
+ }
+ })
+ },
+
+ getNews() {
+ var that = this
+ let user = app.globalData.userInfo
+ lawservice.getLawRegulations(user.guid, 1, {
+ sceneTypeId: user.extension2,
+ fileType: 1
+ }, {
+ 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
+ })
+ }
})
},
/**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
+ * 鑾峰彇鎵胯鍘嗗彶璁板綍
*/
- onReady: function () {
+ getCommitment() {
+ var that = this
+ promiseservice.getCommitment(app.globalData.accessToken.userId, {
+ success(data) {
+ if (data.length > 0) {
+ let c = data[0]
+ let cTime = moment(c.cmCreateTime)
+ let leftDays = cTime.add(1, 'years').diff(moment(), 'days')
+ that.setData({
+ promsieInfo: {
+ leftDays: leftDays
+ }
+ })
+ }
+ }
+ })
+ },
+ getLedgerType() {
+ var that = this
+ var time = moment().format('YYYY-MM-DD')
+ ledgerservice.getLedgerSummary(app.globalData.accessToken.userId, app.globalData.userInfo.extension2, time, {
+ success(res) {
+ that.parseLedgerType(res)
+ }
+ })
+ },
+
+ parseLedgerType(subtypes) {
+ let monthInfo = {
+ totalMust: 0,
+ finishedMust: 0,
+ }
+ subtypes.forEach(s => {
+ //鏈堝害缁熻
+ if (s.needUpdate) {
+ monthInfo.totalMust++
+ if (s.upLoad) {
+ monthInfo.finishedMust++
+ }
+ }
+ });
+
+ monthInfo.percent = Math.round(monthInfo.finishedMust / monthInfo.totalMust * 100)
+
+ this.setData({monthInfo})
},
/**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+ * 椤甸潰璺宠浆
*/
- 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 = `/pages/m_assessment/gradereport/gradereport?period=${this.data.historyPoint.period}`
+ break;
+ case "5":
+ wx.switchTab({
+ url: '/pages/m_ledger/ledgerhome/ledgerhome',
+ })
+ return;
+ case "6":
+ wx.switchTab({
+ url: '/pages/m_promise/promisehome/promise',
+ })
+ break;
+ case "1":
+ //宸ヤ綔鎻愰啋
+ url = "/pages/m_notice/notice/notice"
+ break;
+ case "2":
+ //鏅鸿兘鍦ㄧ嚎鍜ㄨ
+ url = "/pages/m_consult/consulthome/consulthome"
+ break;
+ case "3":
+ //鍦ㄧ嚎瀹堟硶瀛︿範
+ url = `/pages/m_learn/learn/learn`
+ break;
+ case "4":
+ //瀹堟硶鍔ㄦ��
+ // url = "/pages/text/text"
+ let bodyUrl = e.currentTarget.dataset.url
+ let fileType = e.currentTarget.dataset.filetype
+ wx.showLoading({
+ title: ' 鏂囦欢涓嬭浇涓�',
+ mask: true,
+ })
+ wx.downloadFile({
+ url: bodyUrl,
+ success: function (res) {
+ wx.hideLoading()
+ const filePath = res.tempFilePath
+ wx.openDocument({
+ filePath: filePath,
+ success: function (res) {
+ console.log('鎵撳紑鏂囨。鎴愬姛')
+ },
+ fail(error) {
+ console.log(error);
+ }
+ })
+ }
+ })
+ break;
+ }
+ if (url != "") {
+ wx.navigateTo({
+ url: url
+ })
+ }
}
})
\ No newline at end of file
--
Gitblit v1.9.3