博客
关于我
微信小程序可以点击左右按钮切换,一次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 面试,必须掌握的 8 大核心点
查看>>
MySQL 高可用性之keepalived+mysql双主
查看>>
MySQL 高性能优化规范建议
查看>>
mysql 默认事务隔离级别下锁分析
查看>>
Mysql--逻辑架构
查看>>
MySql-2019-4-21-复习
查看>>
mysql-5.6.17-win32免安装版配置
查看>>
mysql-5.7.18安装
查看>>
MySQL-Buffer的应用
查看>>
mysql-cluster 安装篇(1)---简介
查看>>
mysql-connector-java.jar乱码,最新版mysql-connector-java-8.0.15.jar,如何愉快的进行JDBC操作...
查看>>
mysql-connector-java各种版本下载地址
查看>>
mysql-EXPLAIN
查看>>
MySQL-Explain的详解
查看>>
mysql-group_concat
查看>>
MySQL-redo日志
查看>>
MySQL-【1】配置
查看>>
MySQL-【4】基本操作
查看>>
Mysql-丢失更新
查看>>
Mysql-事务阻塞
查看>>