admin 发表于 2024-5-25 18:19:11

预约时间段开发



代码:
Days(20)//从今天开始20天时间
Days(days) {
            if(days == '' || days == null || days == undefined || typeof days != "number"){
                return false;
            }
            let weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
            let res = [];//返回数据
            let today = new Date().getTime();//今天
            for(let i = 0; i < days; i++){
                let list={
                  month:null,
                  day:null,
                  currDay:null,
                  flag:false
                };
                let _day = new Date(today + 86400000 * i),
                  year = _day.getFullYear(),
                  month = (_day.getMonth() + 1),
                  day = _day.getDate();

                let index = _day.getDay()
                let currDay = weekday
                month < 10 ? '0' + month : month;
                day < 10 ? '0' + day : day;
                list.month=month;
                list.day=day;
                list.currDay=currDay;
                res.push(list);
            }
            res.currDay='今天';
            res.currDay='明天';
            return res;
      }


页: [1]
查看完整版本: 预约时间段开发