| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859 |
- // pages/privacy/index.js
- import * as echarts from '../../ec-canvas/echarts';
- // import * as liquidFill from '../../ec-canvas/echarts-liquidfill.min';
- const api = require('../../api/index.js');
- const {timestamp,getYesterday} = require('../../utils/util.js');
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- // 状态栏高度
- statusBarHeight: '',
- // 导航栏高度
- navBarHeight: '',
- // 导航栏和状态栏高度
- navStatusBarHeight: '',
- // 胶囊
- menu: '',
- ec: {
- lazyLoad: true
- },
- workorder: [],
- index: '',
- objectArray: [],
- powerdata: [],
- ech: {
- lazyLoad: true
- },
- ymdlist: [],
- chargeTotal: [],
- currentUnit: 'day', // 当前选中单位:day=日,month=月,year=年
- currentDate: '', // 动态格式显示日期
- actualDate: '', // 底层存储完整日期(YYYY-MM-DD)
- minDate: '2025-9-01', // 最小可选日期(可外部设置)
- maxDate: '', // 最大可选日期(可外部设置,默认当前日期)
- visible: false, // 日历选择器显隐
- // 禁用状态标识
- isMin: false, // 当前单位下是否已到最小边界
- isMax: false, // 当前单位下是否已到最大边界
- isUpperMin: false, // 上级单位下是否已到最小边界
- isUpperMax: false, // 上级单位下是否已到最大边界
- mintimeDate: '',
- maxtimeDate: '',
- currentTime: '',
- activeBarIndex: 0,
- activeBardata: [],
- choicedaydata: ['晟运电站', '南山电站', '晟运电站', '南山电站', '晟运电站', '南山电站']
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 日期字符串转时间戳
-
- const currentTimestamp = Date.now();
-
- // 初始化最大日期为当前日期,可通过options接收外部传入的日期范围
- const today = this.formatDate(new Date(), 'day');
-
- // 支持通过页面参数设置最小/最大日期(如从其他页面跳转时传入)
- const minDate = options.minDate || this.data.minDate;
- const maxDate = options.maxDate || today;
-
- // 确保实际日期在有效范围内
- let initialDate = today;
- if (new Date(initialDate) < new Date(minDate)) {
- initialDate = minDate;
- } else if (new Date(initialDate) > new Date(maxDate)) {
- initialDate = maxDate;
- }
- const mintimeDate = this.convertTimestamp(minDate);
- const maxtimeDate = this.convertTimestamp(maxDate);
- console.log(initialDate);
- this.setData({
- minDate,
- maxDate,
- mintimeDate,
- maxtimeDate,
- actualDate: initialDate,
- actualDate: initialDate,
- currentDate: this.formatDate(new Date(initialDate), 'day'),
- // currentDate: getYesterday(),
- currentTime: currentTimestamp,
- }, () => {
- this.updateDisableStatus();
- });
-
- if (wx.getStorageSync('powerstationId') == '') {
- wx.setStorage({
- key: 'powerstationId', // 存储的key值
- data: ''
- });
-
- }
- this.getShowScreenHeight()
- this.setData({
- statusBarHeight: wx.getStorageSync('statusBarHeight'),
- navBarHeight: wx.getStorageSync('navBarHeight'),
- navStatusBarHeight: wx.getStorageSync('navStatusBarHeight'),
- menu: wx.getStorageSync('menu')
- })
- this.ecline2 = this.selectComponent('#mychart_line2');
- this.ecline = this.selectComponent('#mychart_line');
- this.getpowestation()
-
- // 电站数据
-
-
- },
- getShowScreenHeight() {
- //系统信息
- const systemInfo = wx.getWindowInfo()
- //胶囊位置
- const capsuleInfo = wx.getMenuButtonBoundingClientRect()
- //计算导航栏高度
- let navHeight = systemInfo.statusBarHeight + capsuleInfo.height + (capsuleInfo.top - systemInfo.statusBarHeight) * 2
- //计算tabbar高度
- let tabHeight = systemInfo.safeArea.bottom - systemInfo.safeArea.height
- //计算可现实内容高度(中间区域)
- // let screenHeight = systemInfo.screenHeight-navHeight-tabHeight-30
-
-
- const menu = wx.getMenuButtonBoundingClientRect()
- wx.setStorageSync('menu', menu)
- // 手机系统状态栏高度
- wx.setStorageSync('statusBarHeight', tabHeight)
- // 导航栏高度
- wx.setStorageSync('navBarHeight', menu.height + (menu.top - systemInfo.statusBarHeight) * 2)
-
- // 状态栏加导航栏
-
- wx.setStorageSync('navStatusBarHeight', navHeight)
-
- },
- rolelocate(e) {
- wx.navigateTo({
- url: '/pages/statistics/index',
- })
-
- },
- // 工单统计
- getworkoder() {
- let data = {
- workorderType: ''
- }
- api.request(`/workoder/statistics`, 'POST', data)
- .then((res) => {
- console.log(res);
- this.setData({
- workorder: res.data
- })
- })
- .catch((err) => {
- console.error('请求失败:', err);
- // 在这里处理请求失败的情况
- });
- },
- gitpower() {
- let data = {
- day: this.data.currentDate
- }
- api.request(`/syspowerstation/selectpowerstattiondata`, 'POST', data)
- .then((res) => {
- console.log(res.data);
- this.setData({
- powerdata: res.data
- })
- if (this.data.index == 0 || this.data.index == '') {
- this.setData({
- activeBardata: res.data.sysPowerstationdatalist[this.data.activeBarIndex],
- ymdlist: res.data.sysPowerstationdatalist.map(item => item.powerstationName),
- chargeTotal: res.data.sysPowerstationdatalist.map(item => item.dailydischarge * 1),
- })
- console.log(this.data.ymdlist);
- console.log(this.data.chargeTotal);
- this.initChart_right();
- } else {
- this.initChartright()
-
- }
- })
- .catch((err) => {
- console.error('请求失败:', err);
-
- // 在这里处理请求失败的情况
- });
- },
- // 电容量
- initChartright: function () {
- let _this = this;
-
- // 初始化图表
- this.ecline.init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr
- });
- // 初始数据
- let initialData = {
- accumulatedchargetime: this.data.powerdata.dayfaultlossrate || 0,
- accumulateddischargetime: this.data.powerdata.monthlycumulativelossrate || 0
- };
- // 设置初始选项
- let option = _this.getChartOption(initialData);
- chart.setOption(option);
- // _this.chartInstance2 = chart;
-
-
-
- return chart;
- });
- },
- // 辅助函数,用于生成图表选项
- getChartOption: function (data) {
- let _this = this;
- return {
- backgroundColor: "#ffffff",
- legend: [{
- left: '0',
- bottom: 20,
- itemHeight: 8,
- itemWidth: 8,
- icon: "circle",
- textStyle: {
- color: '#999999', // 设置文字颜色为灰色
- fontSize: 10 // 设置字号为20px
- },
- formatter: function (name) {
- return name + ` ${(data.accumulatedchargetime * 1).toFixed(2)} %`;
- },
- rich: {
- a: {
- color: '#222222',
- fontSize: 12 // 设置字号为20px
-
- }
- },
- data: [{ name: '当日损失率' }]
- }, {
- left: '0',
- bottom: 0,
- itemHeight: 8,
- itemWidth: 8,
- icon: "circle",
- textStyle: {
- color: '#999999', // 设置文字颜色为灰色
- fontSize: 10 // 设置字号为20px
- },
- formatter: function (name) {
- return name + ` ${(data.accumulateddischargetime * 1).toFixed(2)} %`;
- },
- data: [{ name: '月累计损失率' }]
- }],
- tooltip: {
- trigger: 'item'
- },
- series: [{
- type: 'pie',
- radius: ['40%', '60%'],
- center: ['50%', '40%'],
- avoidLabelOverlap: false,
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 0,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: [{
- value: (data.accumulatedchargetime * 1).toFixed(2),
- name: '当日损失率',
- itemStyle: { color: '#4DF096' }
- }, {
- value: (data.accumulateddischargetime * 1).toFixed(2),
- name: '月累计损失率',
- itemStyle: { color: '#3C9EFA' }
- }]
- }]
- };
- },
- onInformation() {
- wx.navigateTo({
- url: '/pages/Information/index',
- })
- },
- // 查询电站
- getpowestation() {
- api.request(`/syspowerstation/selectpowestation`, 'POST', {})
- .then((res) => {
- if (res.code == 200) {
- res.data.unshift({
- powerstationAddress: "",
- powerstationId: "",
- powerstationImg: "",
- powerstationName: "全部电站"
- })
- this.setData({
- objectArray: res.data
- })
- this.getaddredisredis()
- for (let index = 0; index < res.data.length; index++) {
-
- if (res.data[index].powerstationId == wx.getStorageSync('powerstationId')) {
- this.setData({
- index: index
- })
- return
- } else {
- this.setData({
- index: ''
- })
-
- }
- }
-
-
- }
- })
- .catch((err) => {
- console.error('请求失败:', err);
- // 在这里处理请求失败的情况
- });
- },
- getaddredisredis(){
- let data = {
- powerstationId: wx.getStorageSync('powerstationId')
- }
- api.request(`/syspowerstation/addredisredis`, 'POST', data)
- .then((res) => {
- console.log(res);
- })
- .catch((err) => {
- console.error('请求失败:', err);
- // 在这里处理请求失败的情况
- });
- },
- bindPickerChange: function (e) {
- console.log('picker发送选择改变,携带值为', e.detail.value)
- this.setData({
- index: e.detail.value
- })
- wx.setStorage({
- key: 'powerstationId', // 存储的key值
- data: this.data.objectArray[e.detail.value].powerstationId
- });
- let data = {
- powerstationId: this.data.objectArray[e.detail.value].powerstationId
- }
- api.request(`/syspowerstation/addredisredis`, 'POST', data)
- .then((res) => {
- console.log(res);
- if (this.data.index == '') {
- this.gitpower()
- } else {
-
- this.getworkoder()
- this.gitpower()
-
- }
- })
- .catch((err) => {
- console.error('请求失败:', err);
- // 在这里处理请求失败的情况
- });
- },
-
- initChart_right: function () {
-
- var unitName = '上网电量/万kWh'
- let _this = this;
-
- // 初始化选中索引(-1表示无选中)
- // this.setData({ activeBarIndex: 0 });
-
- this.ecline2.init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr
- });
- canvas.setChart(chart);
-
- // 原始柱体颜色(默认样式)
- const originalColor = 'rgba(60, 158, 250, 0.5)';
- // 高亮颜色
- const highlightColor = 'rgba(60, 158, 250, 1)';
-
- // 图表配置项
- var option = {
- title: {
- subtext: unitName,
- textStyle: { color: 'rgba(0, 0, 0, 0)' }
- },
- grid: {
- left: '1%',
- top: '18%',
- right: '1%',
- bottom: '20%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: _this.data.ymdlist,
- axisTick: { show: false },
- axisLabel: { interval: 0 }
- },
- yAxis: {
- type: 'value',
- x: 'center',
- axisTick: { show: false },
- splitLine: { show: false }
- },
- dataZoom: {
- type: 'inside',
- start: 0,
- end: 50
- },
- series: [{
- type: "bar",
- barMaxWidth: 20,
- label: { show: true, position: 'top', color: '#222' },
- data: _this.data.chargeTotal,
- itemStyle: {
- color: function (params) {
- // 只有选中的柱体用高亮色,其他保持原始色
- return params.dataIndex === _this.data.activeBarIndex
- ? highlightColor
- : originalColor;
- },
- barBorderRadius: [2, 2, 0, 0],
- // 选中柱体悬停增强
- emphasis: {
- shadowBlur: 10,
- shadowColor: 'rgba(0, 0, 0, 0)'
- }
- }
- }]
- };
-
- chart.setOption(option);
-
- // 柱体点击事件
- chart.on('click', function (params) {
- if (params.componentType !== 'series' || params.seriesType !== 'bar') {
- return;
- }
-
- const clickedIndex = params.dataIndex;
- // 切换选中状态(点击已选中的柱体则取消高亮)
- if (clickedIndex === _this.data.activeBarIndex) {
- return
- }
-
- const newActiveIndex = clickedIndex;
- _this.setData({ activeBarIndex: newActiveIndex }, () => {
- // 重新设置颜色样式
- chart.setOption({
- series: [{
- itemStyle: {
- color: function (p) {
- return p.dataIndex === _this.data.activeBarIndex
- ? highlightColor
- : originalColor;
- }
- }
- }]
- });
- });
- _this.choicestation()
-
- });
-
- return chart;
- });
- },
- //点击的柱体
- choicestation() {
- console.log(this.data.activeBarIndex);
- console.log(this.data.powerdata);
- this.setData({
- activeBardata: this.data.powerdata.sysPowerstationdatalist[this.data.activeBarIndex]
- })
-
- },
- convertTimestamp(value, unit = 'day') {
- // 如果是数字,视为时间戳,转换为日期字符串
- if (typeof value === 'number') {
- // 处理毫秒级和秒级时间戳
- const timestamp = value.toString().length === 10 ? value * 1000 : value;
- return this.formatDate(new Date(timestamp), unit);
- }
-
- // 如果是字符串,视为日期字符串,转换为时间戳(毫秒)
- if (typeof value === 'string') {
- // 支持 YYYY-MM-DD、YYYY-MM、YYYY 三种格式
- const dateParts = value.split('-');
- let year = parseInt(dateParts[0], 10);
- let month = dateParts.length > 1 ? parseInt(dateParts[1], 10) - 1 : 0; // 月份从0开始
- let day = dateParts.length > 2 ? parseInt(dateParts[2], 10) : 1;
-
- // 处理无效日期
- const date = new Date(year, month, day);
- if (isNaN(date.getTime())) {
- console.error('无效的日期格式:', value);
- return null;
- }
-
- return date.getTime();
- }
-
- console.error('不支持的转换类型:', typeof value);
- return null;
- },
-
- /**
- * 切换日/月/年单位
- */
- handleUnitChange(e) {
- console.log(e);
- const targetClass = e.currentTarget.dataset.name;
- let currentUnit = 'day';
- if (targetClass == "choiceday") currentUnit = 'day';
- else if (targetClass == "choicemoon") currentUnit = 'month';
- else if (targetClass == "choiceyear") currentUnit = 'year';
-
- const formattedDate = this.formatDate(new Date(this.data.actualDate), 'day');
- this.setData({ currentUnit, currentDate: formattedDate }, () => {
- this.updateDisableStatus();
- });
- },
- // 选择电站
- bindchart(e) {
- console.log(e);
- this.setData({
- activeBarIndex: e.currentTarget.dataset.index,
- activeBardata: this.data.powerdata.sysPowerstationdatalist[e.currentTarget.dataset.index]
- })
- this.initChart_right();
-
- },
- /**
- * 处理翻页逻辑:单箭头=当前单位,双箭头=上级单位
- */
- handleDateNav(e) {
- const { currentUnit, actualDate, minDate, maxDate } = this.data;
- const action = e.currentTarget.dataset.action;
- const currentDateObj = new Date(actualDate);
- const minDateObj = new Date(minDate);
- const maxDateObj = new Date(maxDate);
- let newDateObj;
-
- // 确定翻页单位
- const navUnit = action.includes('day') ? currentUnit : this.getUpperUnit(currentUnit);
- // 计算新日期
- switch (navUnit) {
- case 'day':
- newDateObj = new Date(currentDateObj);
- action.startsWith('prev')
- ? newDateObj.setDate(currentDateObj.getDate() - 1)
- : newDateObj.setDate(currentDateObj.getDate() + 1);
- break;
- case 'month':
- newDateObj = new Date(currentDateObj);
- action.startsWith('prev')
- ? newDateObj.setMonth(newDateObj.getMonth() - 1)
- : newDateObj.setMonth(newDateObj.getMonth() + 1);
- // 处理跨月日期溢出
- if (newDateObj.getDate() !== currentDateObj.getDate()) {
- newDateObj.setDate(0);
- }
- break;
- case 'year':
- newDateObj = new Date(currentDateObj);
- action.startsWith('prev')
- ? newDateObj.setFullYear(newDateObj.getFullYear() - 1)
- : newDateObj.setFullYear(newDateObj.getFullYear() + 1);
- // 处理闰年2月29日特殊情况
- if (newDateObj.getDate() !== currentDateObj.getDate()) {
- newDateObj.setDate(0);
- }
- break;
- }
- console.log(newDateObj);
-
- // 检查是否超出最小/最大日期范围
- if (newDateObj.getTime() < minDateObj.getTime() || newDateObj.getTime() > maxDateObj.getTime()) {
- wx.showToast({
- title: '超出时间范围',
- icon: 'none'
- });
- return; // 超出范围则不更新
- }
-
- // 正常更新日期
- const newActualDate = this.formatDate(newDateObj, 'day');
- const newDisplayDate = this.formatDate(newDateObj, currentUnit);
- console.log(newActualDate);
- console.log(newDisplayDate);
- this.setData({
- actualDate: newActualDate,
- currentDate: newDisplayDate
- }, () => {
- this.updateDisableStatus();
- });
- this.gitpower()
-
- },
-
- /**
- * 获取上级单位
- */
- getUpperUnit(unit) {
- const upperMap = { day: 'month', month: 'year', year: 'year' };
- return upperMap[unit];
- },
-
- /**
- * 更新禁用状态:同时判断最小和最大日期边界
- */
- updateDisableStatus() {
- const { currentUnit, actualDate, minDate, maxDate } = this.data;
- const currentObj = new Date(actualDate);
- const minObj = new Date(minDate);
- const maxObj = new Date(maxDate);
- const upperUnit = this.getUpperUnit(currentUnit);
- const status = { isMin: false, isMax: false, isUpperMin: false, isUpperMax: false };
-
- // 判断当前单位边界
- status.isMin = this.isDateEqual(currentObj, minObj, currentUnit);
- status.isMax = this.isDateEqual(currentObj, maxObj, currentUnit);
-
- // 判断上级单位边界
- status.isUpperMin = this.isDateEqual(currentObj, minObj, upperUnit);
- status.isUpperMax = this.isDateEqual(currentObj, maxObj, upperUnit);
-
- this.setData(status);
- },
-
- /**
- * 按指定单位比较两个日期是否相等
- */
- isDateEqual(date1, date2, unit) {
- if (unit === 'day') {
- return date1.getFullYear() === date2.getFullYear()
- && date1.getMonth() === date2.getMonth()
- && date1.getDate() === date2.getDate();
- } else if (unit === 'month') {
- return date1.getFullYear() === date2.getFullYear()
- && date1.getMonth() === date2.getMonth();
- } else if (unit === 'year') {
- return date1.getFullYear() === date2.getFullYear();
- }
- return false;
- },
-
- /**
- * 日历选择器相关方法
- */
- onCalendarClick() {
- console.log(this.data.currentDate);
- // console.log(dateToTimestamp.dateToTimestamp(this.data.currentDate));
- this.setData({
- currentTime: new Date(this.data.currentDate).getTime()
- })
- console.log(this.data.currentTime);
- this.setData({ visible: true });
- },
-
- handleConfirm(e) {
- console.log(e);
- // 1761062400000
- // 1761753600000
- const selectedDate = e.detail.value;
- const { minDate, maxDate, currentUnit } = this.data;
- const selectedObj = new Date(selectedDate);
- const minObj = new Date(minDate);
- const maxObj = new Date(maxDate);
-
- // 检查选中日期是否在有效范围内
- if (selectedObj.getTime() < minObj.getTime() || selectedObj.getTime() > maxObj.getTime()) {
- this.setData({ visible: false });
- return;
- }
-
- console.log(timestamp(selectedObj));
- // const formattedDate = this.formatDate(new Date(selectedDate), currentUnit);
- const formattedDate = timestamp(selectedObj)
- console.log(formattedDate);
-
- this.setData({
- actualDate: selectedDate,
- currentDate: formattedDate,
- visible: false
- }, () => {
- this.updateDisableStatus();
- });
- this.gitpower()
-
- },
-
- onClose(e) {
- console.log(e);
-
- this.setData({ visible: false });
- },
-
- /**
- * 动态格式化日期
- */
- formatDate(date, unit) {
- // 处理传入的date参数(兼容字符串格式的日期)
- const targetDate = new Date(date);
-
- // 校验日期有效性
- if (isNaN(targetDate.getTime())) {
- console.error('无效的日期格式:', date);
- return ''; // 或返回默认值
- }
-
- // 从传入的日期中获取年、月、日
- const year = targetDate.getFullYear();
- const month = String(targetDate.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需+1
- const day = String(targetDate.getDate()).padStart(2, '0');
-
- // 根据单位返回对应格式
- switch (unit) {
- case 'day':
- return `${year}-${month}-${day}`; // 例如:2025-11-04
- case 'month':
- return `${year}-${month}`; // 例如:2025-11
- case 'year':
- return `${year}`; // 例如:2025
- default:
- return `${year}-${month}-${day}`; // 默认返回完整日期
- }
- },
-
- /**
- * 外部调用接口:设置最小日期
- */
- setMinDate(minDate) {
- if (new Date(minDate) && this.isValidDate(minDate)) {
- this.setData({ minDate }, () => {
- this.checkDateInRange();
- this.updateDisableStatus();
- });
- }
- },
-
- /**
- * 外部调用接口:设置最大日期
- */
- setMaxDate(maxDate) {
- if (new Date(maxDate) && this.isValidDate(maxDate)) {
- this.setData({ maxDate }, () => {
- this.checkDateInRange();
- this.updateDisableStatus();
- });
- }
- },
-
- /**
- * 检查当前日期是否在有效范围内,不在则自动调整
- */
- checkDateInRange() {
- const { actualDate, minDate, maxDate, currentUnit } = this.data;
- const currentObj = new Date(actualDate);
- const minObj = new Date(minDate);
- const maxObj = new Date(maxDate);
- let adjustedDate = actualDate;
-
- if (currentObj.getTime() < minObj.getTime()) {
- adjustedDate = minDate;
- } else if (currentObj.getTime() > maxObj.getTime()) {
- adjustedDate = maxDate;
- }
-
- if (adjustedDate !== actualDate) {
- this.setData({
- actualDate: adjustedDate,
- currentDate: this.formatDate(new Date(adjustedDate), currentUnit)
- });
- }
- },
-
- /**
- * 验证日期格式是否有效
- */
- isValidDate(dateString) {
- const regExp = /^\d{4}-\d{2}-\d{2}$/;
- if (!regExp.test(dateString)) return false;
-
- const date = new Date(dateString);
- return date.toISOString().slice(0, 10) === dateString;
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- // this.initChartright()
- this.gitpower()
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- async onPullDownRefresh() {
- await this.getworkoder()
- await this.gitpower()
- await wx.stopPullDownRefresh();
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
- })
|