博客
关于我
微信小程序可以点击左右按钮切换,一次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/

你可能感兴趣的文章
mysql 常用命令
查看>>
Mysql 常见ALTER TABLE操作
查看>>
MySQL 常见的 9 种优化方法
查看>>
MySQL 常见的开放性问题
查看>>
Mysql 常见错误
查看>>
mysql 常见问题
查看>>
MYSQL 幻读(Phantom Problem)不可重复读
查看>>
mysql 往字段后面加字符串
查看>>
mysql 快照读 幻读_innodb当前读 与 快照读 and rr级别是否真正避免了幻读
查看>>
MySQL 快速创建千万级测试数据
查看>>
mysql 快速自增假数据, 新增假数据,mysql自增假数据
查看>>
MySql 手动执行主从备份
查看>>
Mysql 批量修改四种方式效率对比(一)
查看>>
mysql 批量插入
查看>>
Mysql 报错 Field 'id' doesn't have a default value
查看>>
MySQL 报错:Duplicate entry 'xxx' for key 'UNIQ_XXXX'
查看>>
Mysql 拼接多个字段作为查询条件查询方法
查看>>
mysql 排序id_mysql如何按特定id排序
查看>>
Mysql 提示:Communication link failure
查看>>
mysql 插入是否成功_PDO mysql:如何知道插入是否成功
查看>>