Browse Source

数据四率中默认上月当天到当月当天

taidong
mk 10 months ago
parent
commit
17ade4117a
  1. 43
      pages/statistics/modules/HotlineRates/HotlineRates.js

43
pages/statistics/modules/HotlineRates/HotlineRates.js

@ -1,21 +1,22 @@
import {event12345Rates} from "../../../../utils/statisticsApi";
import {formatTime} from "../../../../utils/util";
const formatDay2 = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDay()
return [year, month, day].map(formatNumber).join('-')
}
const formatDay = date => {
const year = date.getFullYear()
const month = date.getMonth()
const day = date.getDay()
return [year, month, day].map(formatNumber).join('-')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
const formatNumber = n => (n < 10 ? '0' : '') + n;
const formatCurrentAndLastMonthDay = () => {
const today = new Date();
const year = today.getFullYear();
const month = today.getMonth() + 1;
const day = today.getDate();
// 上个月的日期
const lastMonthDate = new Date(year, month - 1, day);
const lastYear = lastMonthDate.getFullYear();
const lastMonth = lastMonthDate.getMonth() + 1;
const lastDay = lastMonthDate.getDate();
return {
currentDay: [year, month, day].map(formatNumber).join('-'),
lastMonthDay: [lastYear, lastMonth-1, lastDay].map(formatNumber).join('-'),
};
};
Component({
properties: {
curVal: {
@ -33,13 +34,11 @@ Component({
showitem: 3,
},
ready() {
const { currentDay, lastMonthDay } = formatCurrentAndLastMonthDay();
this.setData({
day: formatDay(new Date()),
})
this.setData({
day2: formatDay2(new Date())
day:lastMonthDay,
day2: currentDay
})
this.getList()
},
methods: {

Loading…
Cancel
Save