From 2fa47cd11be40c881b3129ffc606a9eb9a341396 Mon Sep 17 00:00:00 2001 From: CODE <1650192445@qq.com> Date: Fri, 27 Oct 2023 18:14:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BF=E5=91=BD=E9=A2=84=E8=AD=A6=E6=A8=AA?= =?UTF-8?q?=E8=BD=B4=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lifeWarning/lifeWarning.js | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/weapp/package/deviceBigdataGraph/lifeWarning/lifeWarning.js b/weapp/package/deviceBigdataGraph/lifeWarning/lifeWarning.js index 4bdd874..72d03d4 100644 --- a/weapp/package/deviceBigdataGraph/lifeWarning/lifeWarning.js +++ b/weapp/package/deviceBigdataGraph/lifeWarning/lifeWarning.js @@ -2,14 +2,14 @@ import * as echarts from '../../components/ec-canvas/echarts'; import { getAllPatrol, - getDevices,getProjectList + getDevices, getProjectList } from "../../../utils/getApiUrl"; import { Request } from "../../../common"; const moment = require("../../../utils/moment"); -function setOption(chart, seriesData, xData) { +function setOption (chart, seriesData, xData) { const option = { grid: { top: '5%', @@ -20,7 +20,10 @@ function setOption(chart, seriesData, xData) { }, xAxis: { type: 'category', - data: xData + data: xData, + // axisLabel: { + // formatter: '{value}' + // } }, yAxis: { type: 'value', @@ -28,7 +31,7 @@ function setOption(chart, seriesData, xData) { series: [{ data: seriesData, type: 'line' - }, ] + },] }; chart.setOption(option); } @@ -73,9 +76,9 @@ Page({ /** * 生命周期函数--监听页面加载 */ - onLoad(options) { - const projectList=decodeURIComponent(options.arrayData) - const complexArray = JSON.parse(projectList); + onLoad (options) { + const projectList = decodeURIComponent(options.arrayData) + const complexArray = JSON.parse(projectList); const { windowHeight } = wx.getSystemInfoSync() @@ -117,9 +120,9 @@ Page({ // 查找匹配项目 const project = complexArray.find((project) => project.id === point.projectId); if (project) { - device.project = project; + device.project = project; } - }); + }); expiringDevices.push(device); } // 检查设备的 dateGuarantee 是否在日期范围内 @@ -140,10 +143,28 @@ Page({ // const label = `${year}-${month}`; // xAxisLabels.push(label); const nextMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + i, 1); - const month = nextMonth.toLocaleDateString('en-US', { - month: 'short' - }); // 获取月份的缩写 - xAxisLabels.push(month); + const month = nextMonth + .getMonth() + // .toLocaleDateString('en-US', { + // month: 'short' + // }); // 获取月份的缩写 + + const month_ = { + "0": "Jan", + "1": "Feb", + "2": "Mar", + "3": "Apr", + "4": "May", + "5": "Jun", + "6": "Jul", + "7": "Aug", + "8": "Sep", + "9": "Oct", + "10": "Nov", + "11": "Dec" + }[month] + console.log('月', month_); + xAxisLabels.push(month_); } //过期的 const guaranteedRate = res.filter(item => moment(item.dateGuarantee).isBefore(moment()))?.length || 0 @@ -153,7 +174,7 @@ Page({ count: res.length, guaranteedRate: guaranteedRate, warrantyPeriod: warrantyPeriod, - next30days:expiringDevices + next30days: expiringDevices }) setTimeout(() => { this.initChart(monthlyCounts, xAxisLabels) @@ -168,49 +189,49 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady() { + onReady () { }, /** * 生命周期函数--监听页面显示 */ - onShow() { + onShow () { }, /** * 生命周期函数--监听页面隐藏 */ - onHide() { + onHide () { }, /** * 生命周期函数--监听页面卸载 */ - onUnload() { + onUnload () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh() { + onPullDownRefresh () { }, /** * 页面上拉触底事件的处理函数 */ - onReachBottom() { + onReachBottom () { }, /** * 用户点击右上角分享 */ - onShareAppMessage() { + onShareAppMessage () { } }) \ No newline at end of file