| | |
| | | // 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() |
| | | import $f from '../../service/baserequest'; |
| | | |
| | | 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(); |
| | | /** |
| | | * 首页 |
| | | */ |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | notices: [{ |
| | | notice: "本月守法承诺自测智评已开启,请及时进行评价", |
| | | time: "2022/3/1" |
| | | }], |
| | | icon1: $f.baseIconUrl + 'res/btn_bg_1.png', |
| | | icon2: $f.baseIconUrl + 'res/btn_bg_2.png', |
| | | icon3: $f.baseIconUrl + 'res/wm_assessment.png', |
| | | |
| | | dynamic: [{ |
| | | title: "企业营业执照、食品经营许可证丢失该如何补领", |
| | | time: "2022年4月5日", |
| | | views: 2012, |
| | | pic: "/res/icons/temp_pic_1.png" |
| | | }], |
| | | notices: [], |
| | | unReadNoiceCount: 0, |
| | | |
| | | dynamic: [], |
| | | |
| | | nextEvaluationTime: '2022年6月9日', |
| | | userRealName: '', |
| | | |
| | | //历史评分详情 |
| | | assessmentCompleted: false, |
| | | historyPoint: { |
| | | time: '测评周期----年--月', |
| | | score: '--', |
| | | rank: '--', |
| | | legalIndex: '--', |
| | | illegalIndex: '--' |
| | | illegalIndex: '--', |
| | | period: '', |
| | | }, |
| | | period: '' |
| | | //台账完成情况 |
| | | ledgerCompleted: false, |
| | | monthInfo: { |
| | | //必填项总数 |
| | | totalMust: 0, |
| | | //必填项提交数 |
| | | finishedMust: 0, |
| | | }, |
| | | //承诺完成情况 |
| | | promsieInfo: { |
| | | leftDays: 0, |
| | | }, |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | 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) => { |
| | | success: result => { |
| | | console.log(result.data); |
| | | }, |
| | | fail: (res) => {}, |
| | | complete: (res) => {}, |
| | | }) |
| | | fail: res => {}, |
| | | complete: res => {}, |
| | | }); |
| | | |
| | | this.getNextEvaluationTime() |
| | | this.getNotice() |
| | | this.getUserInfo() |
| | | this.getHistoryPoint() |
| | | this.getNews() |
| | | // this.getNextEvaluationTime(); |
| | | // this.getNotice(); |
| | | // this.getUnReadNoticeCount(); |
| | | this.getUserInfo(); |
| | | // this.getHistoryPoint(); |
| | | // this.getNews(); |
| | | // this.getCommitment(); |
| | | // this.getLedgerType(); |
| | | }, |
| | | |
| | | onShow() { |
| | | if (app.globalData.isLogin) { |
| | | wx.startPullDownRefresh({ |
| | | success: res => {}, |
| | | fail: res => {}, |
| | | complete: res => {}, |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | onPullDownRefresh() { |
| | | this.getNextEvaluationTime(); |
| | | this.getNotice(); |
| | | this.getUnReadNoticeCount(); |
| | | this.getHistoryPoint(); |
| | | this.getNews(); |
| | | this.getCommitment(); |
| | | this.getLedgerType(); |
| | | }, |
| | | |
| | | getNextEvaluationTime() { |
| | | let now = moment().add(1, 'months') |
| | | let now = moment().add(1, 'months'); |
| | | this.setData({ |
| | | nextEvaluationTime: now.format("YYYY年MM月10日") |
| | | }) |
| | | nextEvaluationTime: now.format('YYYY年MM月10日'), |
| | | }); |
| | | }, |
| | | |
| | | getUserInfo() { |
| | | this.setData({ |
| | | userRealName: app.globalData.userInfo.realname |
| | | }) |
| | | userRealName: app.globalData.userInfo.realname, |
| | | }); |
| | | }, |
| | | |
| | | getNotice() { |
| | | this.setData({ |
| | | notices: [{ |
| | | notice: "本月守法承诺自测智评已开启,请及时进行评价", |
| | | time: "2022/5/9" |
| | | }] |
| | | }) |
| | | 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, |
| | | }); |
| | | }); |
| | | }, |
| | | }); |
| | | }, |
| | | |
| | | getUnReadNoticeCount() { |
| | | var that = this; |
| | | notificationservice.getUnReadNoticeCount( |
| | | app.globalData.accessToken.userId, |
| | | { |
| | | success(res) { |
| | | that.setData({ unReadNoiceCount: res }); |
| | | }, |
| | | }, |
| | | ); |
| | | }, |
| | | |
| | | getHistoryPoint() { |
| | | var that = this |
| | | 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) |
| | | if (data.length == 0) { |
| | | return; |
| | | } |
| | | 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, |
| | | illegalIndex: lastOne.level |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | illegalIndex: lastOne.level, |
| | | period: lastOne.period, |
| | | }, |
| | | }); |
| | | }, |
| | | }); |
| | | }, |
| | | |
| | | getNews() { |
| | | var that = this |
| | | let user = app.globalData.userInfo |
| | | lawservice.getLawRegulations(user.guid, 1, user.extension2, { |
| | | 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, |
| | | }); |
| | | }, |
| | | }, |
| | | ); |
| | | }, |
| | | |
| | | /** |
| | | * 获取承诺历史记录 |
| | | */ |
| | | getCommitment() { |
| | | var that = this; |
| | | promiseservice.getCommitment(app.globalData.accessToken.userId, { |
| | | 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 |
| | | }) |
| | | 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); |
| | | }, |
| | | complete() { |
| | | wx.stopPullDownRefresh({ |
| | | success: res => {}, |
| | | fail: res => {}, |
| | | complete: res => {}, |
| | | }); |
| | | }, |
| | | }, |
| | | ); |
| | | }, |
| | | |
| | | parseLedgerType(subtypes) { |
| | | 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 = |
| | | 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, |
| | | ledgerCompleted: monthInfo.percent >= 100 && monthInfo.percent2 >= 100, |
| | | // ledgerCompleted: true |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * 页面跳转 |
| | | */ |
| | | goto: function (e) { |
| | | var url = "" |
| | | var index = e.currentTarget.dataset.index |
| | | var url = ''; |
| | | var index = e.currentTarget.dataset.index; |
| | | switch (index) { |
| | | case "0": |
| | | case '0': |
| | | //测评历史记录 |
| | | url = "" |
| | | if (this.data.historyPoint.period == '') { |
| | | url = `/pages/mAssessment/grade/grade`; |
| | | } else { |
| | | url = `/pages/mAssessment/gradereport/gradereport?period=${this.data.historyPoint.period}`; |
| | | } |
| | | break; |
| | | case "1": |
| | | case '5': |
| | | wx.switchTab({ |
| | | url: '/pages/mLedger/home/index', |
| | | }); |
| | | return; |
| | | case '6': |
| | | wx.navigateTo({ |
| | | url: '/pages/mPromise/promisehome/promise', |
| | | }); |
| | | return; |
| | | case '1': |
| | | //工作提醒 |
| | | url = "/pages/notice/notice" |
| | | url = '/pages/mNotice/notice/notice'; |
| | | break; |
| | | case "2": |
| | | case '2': |
| | | //智能在线咨询 |
| | | url = "/pages/module_consult/consulthome/consulthome" |
| | | url = '/pages/mConsult/consulthome/consulthome'; |
| | | break; |
| | | case "3": |
| | | case '3': |
| | | //在线守法学习 |
| | | |
| | | url = `/pages/learn/learn` |
| | | |
| | | url = `/pages/mLearn/learn/learn`; |
| | | break; |
| | | case "4": |
| | | case '4': |
| | | //守法动态 |
| | | // url = "/pages/text/text" |
| | | let bodyUrl = e.currentTarget.dataset.url |
| | | let fileType = e.currentTarget.dataset.filetype |
| | | let bodyUrl = e.currentTarget.dataset.url; |
| | | let fileType = e.currentTarget.dataset.filetype; |
| | | wx.showLoading({ |
| | | title: ' 文件下载中', |
| | | title: ' 加载中', |
| | | mask: true, |
| | | }) |
| | | }); |
| | | wx.downloadFile({ |
| | | url: bodyUrl, |
| | | success: function (res) { |
| | | wx.hideLoading() |
| | | const filePath = res.tempFilePath |
| | | wx.hideLoading(); |
| | | const filePath = res.tempFilePath; |
| | | wx.openDocument({ |
| | | filePath: filePath, |
| | | success: function (res) { |
| | | console.log('打开文档成功') |
| | | console.log('打开文档成功'); |
| | | }, |
| | | fail (error) { |
| | | fail(error) { |
| | | console.log(error); |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | break; |
| | | case "5": |
| | | break; |
| | | }, |
| | | }); |
| | | }, |
| | | }); |
| | | return; |
| | | } |
| | | if (url != "") { |
| | | if (url != '') { |
| | | wx.navigateTo({ |
| | | url: url |
| | | }) |
| | | url: url, |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | }); |