博客
关于我
微信小程序可以点击左右按钮切换,一次7天
阅读量:611 次
发布时间:2019-03-12

本文共 3077 字,大约阅读时间需要 10 分钟。

我们的需求就是这种效果

实现的代码

html部分

data: {    show: false,    active: -1,    weekDate: ['日', '一', '二', '三', '四', '五', '六'],    dateArr: [],    isTodayWeek: false,    todayIndex: 0,    lastweek: true,    nowdate: new Date().getDate(),    datetip: false, //圆点的高亮不高亮    datelist: [], //后台返的14天的状态数据    isdayorder: [], //当天的任务详情      },  //获取14天的亮度状态  getstatus() {    if (!wx.getStorageSync('token')) return    Api.request(oderRoot + '/api/work/schedule/status', {}, 'GET').then(res => {      var _time = new Date();      var year = _time.getFullYear()      var month = _time.getMonth() + 1      res.forEach((item, index) => {        month = parseInt(month)        var day = parseInt(item.date)        var lastDay = 0        if (index > 0) {          lastDay = parseInt(res[index - 1].date)        }        if (lastDay > day) {          if (month == 12) {            year += 1            month = 1          } else {            month += 1          }        }        if (day < 10) {          day = '0' + '' + day        }        if (month < 10) {          month = '0' + '' + month        }        item.day = year + '-' + month + '-' + day      })      // console.log(res)      this.setData({        datelist: res   //前端遍历是这个datelist       })    })  },  /**   * 上周切换   */  lastWeek: function () {    var _this = this;    var _time = new Date();    var lastDay, month, year;    if (_this.data.isToday - 7 <= 0) {      if (_this.data.month <= 1) {        month = 12        year = _this.data.year - 1      } else {        month = _this.data.month - 1        year = _this.data.year      }      lastDay = new Date(year, month, 0).getDate() + (_this.data.isToday - 7)    } else {      lastDay = _this.data.isToday - 7      month = _this.data.month      year = _this.data.year    }    _this.setData({      isToday: lastDay,      month: month,      year: year,      mountTotalDay: new Date(year, month, 0).getDate(),      nextWeek: false,      lastweek: true    })    // _this.dateInit(lastDay, _this.data.isWeek);  },  /**   * 下周切换   */  nextWeek: function () {    var _this = this;    var _time = new Date();    var nextDay, month, year;    if (_this.data.isToday + 7 > _this.data.mountTotalDay) {      nextDay = _this.data.isToday + 7 - _this.data.mountTotalDay      if (_this.data.month > 11) {        month = 1        year = _this.data.year + 1      } else {        month = _this.data.month + 1        year = _this.data.year      }    } else {      nextDay = _this.data.isToday + 7      month = _this.data.month      year = _this.data.year    }    _this.setData({      isToday: nextDay,      month: month,      year: year,      mountTotalDay: new Date(year, month, 0).getDate(),      lastweek: false,      nextWeek: true    })    // console.log(this.data.month,"month")    // _this.dateInit(nextDay, _this.data.isWeek);  }
{ {year}}-{ {month<10?'0'+month:month}}
{ {item}}
 
{ {item.date}}

 

转载地址:http://yjwaz.baihongyu.com/

你可能感兴趣的文章
MySQL5.7.37windows解压版的安装使用
查看>>
mysql5.7免费下载地址
查看>>
mysql5.7命令总结
查看>>
mysql5.7安装
查看>>
mysql5.7性能调优my.ini
查看>>
MySQL5.7新增Performance Schema表
查看>>
Mysql5.7深入学习 1.MySQL 5.7 中的新增功能
查看>>
Webpack 之 basic chunk graph
查看>>
Mysql5.7版本单机版my.cnf配置文件
查看>>
mysql5.7的安装和Navicat的安装
查看>>
mysql5.7示例数据库_Linux MySQL5.7多实例数据库配置
查看>>
Mysql8 数据库安装及主从配置 | Spring Cloud 2
查看>>
mysql8 配置文件配置group 问题 sql语句group不能使用报错解决 mysql8.X版本的my.cnf配置文件 my.cnf文件 能够使用的my.cnf配置文件
查看>>
MySQL8.0.29启动报错Different lower_case_table_names settings for server (‘0‘) and data dictionary (‘1‘)
查看>>
MYSQL8.0以上忘记root密码
查看>>
Mysql8.0以上重置初始密码的方法
查看>>
mysql8.0新特性-自增变量的持久化
查看>>
Mysql8.0注意url变更写法
查看>>
Mysql8.0的特性
查看>>
MySQL8修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查看>>