You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
198 lines
6.2 KiB
198 lines
6.2 KiB
// pages/home/home.js
|
|
import { getPatrolRecord,getAdvisoryNotices } from "../../utils/getApiUrl";
|
|
import { Request } from "../../common";
|
|
const moment = require("../../utils/moment");
|
|
|
|
Page({
|
|
jumpToSubSystem (options) {
|
|
const key = options.currentTarget.dataset.key;
|
|
wx.navigateTo({
|
|
url: `/package/subSystem/subSystem?key=${key}`,
|
|
})
|
|
},
|
|
jumpToRiskCalendar () {
|
|
wx.navigateTo({
|
|
url: `/package/riskManagement/riskCalendar/riskCalendar`,
|
|
})
|
|
},
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
sevenDaysCount:0,//过去七天的巡检次数
|
|
sevenDaysQuestionCount:0,//过去七天发现问题个数
|
|
sevenDaysHandleCount:0,//过去七天问题解决个数
|
|
allCount:0,//总的巡检次数
|
|
allQuestionCount:0,//总的发现问题个数
|
|
allHandleCount:0,//总的问题解决个数
|
|
todayRecord: [], // 今日巡检记录
|
|
markers: [],
|
|
pageHeight:0,//屏幕高度
|
|
isShowCallout: false,
|
|
advisoryNoticeList:[],//咨询公告
|
|
time:'',//最新公告时间
|
|
itemList:[
|
|
{
|
|
picPath:'/images/gas.png',
|
|
itemName:'燃气仓'
|
|
},
|
|
{
|
|
picPath:'/images/waterSupply.png',
|
|
itemName:'给水仓'
|
|
},
|
|
{
|
|
picPath:'/images/electricalStorageRoom.png',
|
|
itemName:'电气仓'
|
|
},
|
|
{
|
|
picPath:'/images/highTension.png',
|
|
itemName:'高压电力仓'
|
|
},
|
|
{
|
|
picPath:'/images/pipeGallery.png',
|
|
itemName:'管廊本体'
|
|
},
|
|
{
|
|
picPath:'/images/conduct.png',
|
|
itemName:'指挥中心'
|
|
},
|
|
{
|
|
picPath:'/images/power.png',
|
|
itemName:'供配电系统'
|
|
},
|
|
{
|
|
picPath:'/images/elevator.png',
|
|
itemName:'电梯系统'
|
|
},
|
|
{
|
|
picPath:'/images/security.png',
|
|
itemName:'安防系统'
|
|
},
|
|
{
|
|
picPath:'/images/lightningProtection.png',
|
|
itemName:'防雷与接地'
|
|
}
|
|
],
|
|
},
|
|
//跳转资讯公告页
|
|
toDetail(){
|
|
wx.navigateTo({
|
|
url: '/package/advisoryNotice/advisoryNotice',
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad (options) {
|
|
const userInfo=wx.getStorageSync('userInfo');
|
|
const {windowHeight}=wx.getSystemInfoSync()
|
|
const pageHeight=windowHeight - 48
|
|
const promiseArr = [];
|
|
const that = this;
|
|
var data = {
|
|
datas: [
|
|
{
|
|
"id": 1,
|
|
"imgurl": "/images/banner1.png"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"imgurl": "/images/banner2.png"
|
|
}
|
|
]
|
|
};
|
|
wx.showLoading({ title: '加载中' })
|
|
const date1 = new Date('1970-01-01 00:00:00');
|
|
promiseArr.push(Request.get(getPatrolRecord('all', moment(date1).format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null',{home:true})));
|
|
promiseArr.push(Request.get(getAdvisoryNotices({home:true})))
|
|
Promise.all(promiseArr).then(res => {
|
|
wx.hideLoading()
|
|
//与自己相关的所有巡检记录
|
|
let list=res[0]
|
|
if(userInfo.username!=='SuperAdmin'){
|
|
list=res[0]?.filter(item=> userInfo.structure.find((x) => x === item.projectId))||[]
|
|
}
|
|
//过去七天的所有巡检记录
|
|
const sevenDaysList=list?.filter(item=>
|
|
{
|
|
const recordDate = moment(item?.inspectionTime, 'YYYY-MM-DD'); // 解析日期
|
|
const daysDifference = moment().diff(recordDate, 'days'); // 计算日期差
|
|
// 返回近七天内的记录
|
|
return daysDifference >= 0 && daysDifference < 7;
|
|
}
|
|
)||[]
|
|
that.setData({
|
|
advisoryNoticeList:res[1].rows,
|
|
time:moment(res[1].rows[0].publishTime).format('YYYY年MM月DD日'),
|
|
allCount:list.length || 0,
|
|
allQuestionCount:list?.filter(i=>i.patrolRecordIssueHandles.length>0)?.length || 0,
|
|
allHandleCount:list?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0,
|
|
sevenDaysCount:sevenDaysList?.length||0,
|
|
sevenDaysQuestionCount:sevenDaysList?.filter(i=>i.patrolRecordIssueHandles.length>0)?.length || 0,
|
|
sevenDaysHandleCount:sevenDaysList?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0,
|
|
pageHeight:pageHeight+'px',
|
|
swiperData:data.datas
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow () {
|
|
const userInfo = wx.getStorageSync('userInfo');
|
|
if (!userInfo || !userInfo.id) {
|
|
wx.reLaunch({
|
|
url: '/pages/login/login'
|
|
});
|
|
} else {
|
|
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
|
this.getTabBar().setData({
|
|
selected: 0
|
|
})
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage () {
|
|
|
|
}
|
|
})
|