function getTime(type){
let now = new Date();
let nowDayOfWeek = now.getDay(); //今天本周的第几天
let nowDay = now.getDate(); //当前日
let nowMonth = now.getMonth() + 1; //当前月 下标从0开始
let nowYear = now.getFullYear(); //当前年
let d = new Date(nowYear, (nowMonth + 1), 0).getDate();
//上月
let lastMonthDate = new Date(); //上月日期
lastMonthDate.setDate(1);
lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
let lastMonthYear = lastMonthDate.getFullYear();
let lastMonth = lastMonthDate.getMonth() + 1;
let lastYear = nowYear - 1;
let weekStart = new Date(nowYear, nowMonth - 1, nowDay - nowDayOfWeek + 1);
let weekEnd = new Date(nowYear, nowMonth - 1, nowDay + (7 - nowDayOfWeek));
let time: [string, string, string] = ["", "", "0"];
switch (type) {
case "0":
break;
//本周
case "1":
time = [formatDate(weekStart), formatDate(now), "4"];
break;
//本月
case "2":
let month = nowMonth < 10 ? '0' + nowMonth : nowMonth
time = [nowYear + "-" + month + "-01", formatDate(now), "4"];
break;
//本年
case "3":
time = [nowYear + "-01-01", formatDate(now), "2"];
break;
//上周
case "4":
time = [formatDate(new Date(nowYear, nowMonth-1, nowDay - nowDayOfWeek - 6)), formatDate(new Date(nowYear, nowMonth-1, nowDay - nowDayOfWeek)), "4"];
break;
//上月
case "5":
time = [formatDate(new Date(lastMonthYear, lastMonth, 1)), formatDate(new Date(lastMonthYear, lastMonth, d)), "4"];
break;
//上年
case "6":
time = [lastYear + "-01-01", lastYear + "-12-31", "2"];
break;
}
return time;
}