博客
关于我
微信小程序可以点击左右按钮切换,一次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 replace函数替换字符串语句的用法(mysql字符串替换)
查看>>
mysql replace用法
查看>>
Mysql Row_Format 参数讲解
查看>>
mysql select, from ,join ,on ,where groupby,having ,order by limit的执行顺序和书写顺序
查看>>
MySQL Server 5.5安装记录
查看>>
mysql server has gone away
查看>>
mysql skip-grant-tables_MySQL root用户忘记密码怎么办?修改密码方法:skip-grant-tables
查看>>
mysql slave 停了_slave 停止。求解决方法
查看>>
MySQL SQL 优化指南:主键、ORDER BY、GROUP BY 和 UPDATE 优化详解
查看>>
MYSQL sql语句针对数据记录时间范围查询的效率对比
查看>>
mysql sum 没返回,如果没有找到任何值,我如何在MySQL中获得SUM函数以返回'0'?
查看>>
mysql sysbench测试安装及命令
查看>>
mysql Timestamp时间隔了8小时
查看>>
Mysql tinyint(1)与tinyint(4)的区别
查看>>
MySQL Troubleshoting:Waiting on query cache mutex
查看>>
mysql union orderby 无效
查看>>
mysql v$session_Oracle 进程查看v$session
查看>>
mysql where中如何判断不为空
查看>>
MySQL Workbench 使用手册:从入门到精通
查看>>
MySQL Workbench 数据库建模详解:从设计到实践
查看>>