优化代码

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