backend gives me a start time and an end time, and I need to determine whether it is within this period of time. First, the start and end times may be multiple arrays, and the time period may be multiple data.
{"code":"0","data":{"nowDate":"2018-09-03 14:25:57","isCanUpdate":"0","list":[{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-17"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-18"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-19"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-20"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-21"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-22"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-23"}]},"info":""}
this is the data I have processed
computed:{
newTimesList(){
var day = this.childmessage.day
var newTimesList=this.initTimesList.map(function(item) {
return +new Date((day+" "+item).replace(/-/g,"/"));
})
return newTimesList
},
getTime(){
var timeLength = this.times.length;
var timesArray = [];
for (var i = 0; i < timeLength; iPP) {
var startTime = this.day+" "+this.times[i].startTime;
var endTime = this.day+" "+this.times[i].endTime;
var startTimeStr = +new Date(startTime.replace(/-/g,"/"));
var endTimeStr = +new Date(endTime.replace(/-/g,"/"));
var timesList = {
startTimeStr:startTimeStr,
endTimeStr : endTimeStr
}
timesArray.push(timesList)
return timesArray
}
},
hasArrange(){
var activeArray = []
for (var i = 0; i < this.getTime.length; iPP) {
for (var j = 0; j < this.newTimesList.length; jPP) {
// false
// if (this.newTimesList[j]>this.getTime[i]["startTimeStr"]&&this.newTimesList[j]<this.getTime[i]["endTimeStr"]) {
// var thisState = "true"
// activeArray.push(thisState)
// }else{
// var thisState = "false"
// activeArray.push(thisState)
// }
}
}
return activeArray
}
I want to judge whether there is an active class based on the subscript of the last data