• 当前日期后的后几天


    onLoad: function (options) {
        var that = this;
    
        var oDate = new Date();   
        var dayArr = [];     
        for (var i = 0; i < 7; i++) {/*后7天*/
          dayArr.push(new Date(oDate.getFullYear(), oDate.getMonth(), oDate.getDate() + i));  
        }
    
        var date=[];
    
        for (var j = 0; j < dayArr.length;j++){
          date[j]={};  
          date[j].day = that.filterMonth(dayArr[j].getDate());
          date[j].month = that.filterMonth(dayArr[j].getMonth()+1);
          date[j].week = that.week(j, dayArr[j].getDay());
          date[j].simweek = that.simweek(dayArr[j].getDay());
    
        }
      
        console.log(date)
        that.setData({ date: date})
    
      },
      simweek: function (week){
        var weekDaay = ['', '', '', '', '', '', ''];
        switch (week) {
          case 0:
            return weekDaay[week];
            break;
          case 1:
            return weekDaay[week];
            break;
          case 2:
            return weekDaay[week];
            break;
          case 3:
            return weekDaay[week];
            break;
          case 4:
            return weekDaay[week];
            break;
          case 5:
            return weekDaay[week];
            break;
          case 6:
            return weekDaay[week];
            break;
        }
      },
      week:function(j,week){
        var weekDaay = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
        switch (j) {
          case 0:
            return '今天';
            break;
          case 1:
            return '明天';
            break;
          case 2:
            return '后天';
            break;
          case 3:
            return weekDaay[week];
            break;
          case 4:
            return weekDaay[week];
            break;
          case 5:
            return weekDaay[week];
            break;
          case 6:
            return weekDaay[week];
            break;
        }
      },
      filterMonth:function(m){
        if(m<10){
          return '0'+m
        }else{
          return m;
        }
      },
  • 相关阅读:
    java基础(上)
    java前奏
    Spring框架介绍
    bootstrap简单学习
    存储过程和函数
    触发器
    视图
    索引
    mysql增、删、改数据
    子查询
  • 原文地址:https://www.cnblogs.com/yewook/p/9620489.html
Copyright © 2020-2023  润新知