业务场景:在界面上点击后端回传字段如‘2020年第21周’,此时需要往后端传所选周的始末时间(年月日 时分秒)
const selectTime = '2020年第21周'
const year1 = selectTime .split('年')[0]
// 截取当前选择的周数
const week = selectTime .split('第')[1].split('周')[0]
// 起始日期
const params = `${year1}-01-01 00:00:00`
// 起始时间转时间戳
const timeYear = (new Date(params)).getTime()
// 获取当前年份一月一日周几(例如2020年一月一日为周三)
const whichDay = (new Date(params)).getDay()
// 根据第一周和非第一周获取选取周数,获取一月一日至当前周始所用时间
const timeWeekStart = Number(week) === 1 ? ((Number(week) - 1) * 7) * 24 * 60 * 60 * 1000 : ((Number(week) - 1) * 7 - (whichDay - 1)) * 24 * 60 * 60 * 1000
// 根据第一周和非第一周获取选取周数,获取一月一日至当前周终所用时间
const timeWeekEnd = ((Number(week) - 1) * 7 + (7 - whi