// pages/home/home.js import { getPatrolRecord } 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}`, }) }, /** * 页面的初始数据 */ data: { sevenDaysCount:0,//过去七天的巡检次数 sevenDaysQuestionCount:0,//过去七天发现问题个数 sevenDaysHandleCount:0,//过去七天问题解决个数 allCount:0,//总的巡检次数 allQuestionCount:0,//总的发现问题个数 allHandleCount:0,//总的问题解决个数 todayRecord: [], // 今日巡检记录 markers: [], isShowCallout: false, itemList:[{ picPath:'/images/conduct.png', itemName:'指挥中心' }, { picPath:'/images/waterSupply.png', itemName:'给水仓' }, { picPath:'/images/pipeGallery.png', itemName:'管廊本体' }, { picPath:'/images/elevator.png', itemName:'电梯系统' }, { picPath:'/images/power.png', itemName:'供配电系统' }, { picPath:'/images/gas.png', itemName:'燃气仓' }, { picPath:'/images/security.png', itemName:'安防系统' }, { picPath:'/images/highTension.png', itemName:'高压电力仓' }, { picPath:'/images/electricalStorageRoom.png', itemName:'电气仓' }, { picPath:'/images/lightningProtection.png', itemName:'防雷与接地' } ], }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { const userInfo=wx.getStorageSync('userInfo'); const {windowHeight}=wx.getSystemInfoSync() const pageHeight=windowHeight - 48 console.log('todayRecord1',this.todayRecord) const promiseArr = []; const that = this; wx.showLoading({ title: '加载中' }) promiseArr.push(Request.get(getPatrolRecord('all', moment('1970-1-1').format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null'))); Promise.all(promiseArr).then(res => { console.log('xxxaxax',userInfo) console.log('xxxaxax',res[0]?.filter(item=>item?.points?.user.id===userInfo.id)) wx.hideLoading() that.setData({ allCount:res[0]?.filter(item=>item?.points?.user.id===userInfo.id)?.length || 0, todayRecord: res[0], pageHeight:pageHeight+'px' }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ 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 () { } })