优化代码

This commit is contained in:
wangsongsole 2022-08-15 15:51:59 +08:00
parent b7f5960fa4
commit be7942ae0b
1 changed files with 22 additions and 41 deletions

View File

@ -85,47 +85,28 @@ export function getNowTime() {
export function sortWeeks(weeks) { export function sortWeeks(weeks) {
var _weeks = [] //创建临时排序的数组 var _weeks = [] //创建临时排序的数组
for (var i = 0; i < weeks.length; i++) { for (var i = 0; i < weeks.length; i++) {
if (weeks[i] == '周一') { switch (weeks[i]) {
var _week = {} case '周一':
_week['id'] = 1 _weeks.push({ id: 1, name: '周一' })
_week['name'] = '周一' break
_weeks.push(_week) case '周二':
} _weeks.push({ id: 2, name: '周二' })
if (weeks[i] == '周二') { break
var _week = {} case '周三':
_week['id'] = 2 _weeks.push({ id: 3, name: '周三' })
_week['name'] = '周二' break
_weeks.push(_week) case '周四':
} _weeks.push({ id: 4, name: '周四' })
if (weeks[i] == '周三') { break
var _week = {} case '周五':
_week['id'] = 3 _weeks.push({ id: 5, name: '周五' })
_week['name'] = '周三' break
_weeks.push(_week) case '周六':
} _weeks.push({ id: 6, name: '周六' })
if (weeks[i] == '周四') { break
var _week = {} case '周日':
_week['id'] = 4 _weeks.push({ id: 7, name: '周日' })
_week['name'] = '周四' break
_weeks.push(_week)
}
if (weeks[i] == '周五') {
var _week = {}
_week['id'] = 5
_week['name'] = '周五'
_weeks.push(_week)
}
if (weeks[i] == '周六') {
var _week = {}
_week['id'] = 6
_week['name'] = '周六'
_weeks.push(_week)
}
if (weeks[i] == '周日') {
var _week = {}
_week['id'] = 7
_week['name'] = '周日'
_weeks.push(_week)
} }
} }
_weeks.sort(function (a, b) { _weeks.sort(function (a, b) {