|
- // components/dateLsit/dateLsit.js
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- week:['日','一','二','三','四','五','六'],
- dateLsit:[],
- year: new Date().getFullYear(),
- month: new Date().getMonth()+1,
- },
- showDate(){//刷新日历
- let thenDey = this.getThenWeek()
-
- },
-
- getDays(year, month){//获取每月有多少天
- let tempDateArr = []
- let thenDate = new Date(year, month, 0).getDate()
- return thenDate
- },
- getLastMonth(year, month){//上一个月最后一天是多少号
- if(month==1){
- month =12
- year = year-1
- }else{
- month = month-1
- }
- let tempDateArr = []
- let thenDate = new Date(year, month, 0).getDate()
- return thenDate
- },
- getThenWeek(year, month){//获取每个月第一天是星期几
- if (month == 1) {
- month = 12
- year = year - 1
- } else {
- month = month - 1
- }
- let date = new Date()
- date.setFullYear(year)
- date.setMonth(month)
- date.setDate(1)
- return date.getDay()
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(this.getThenWeek(2021,3))
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|