更新时间:2021-05-10 01:37:44
//当前日历显示的年份 showYear:2021, //当前日历显示的月份 showMonth:5, //当前日历显示的天数 showDays:6, eventName:"load", //初始化日历 init: function(signList) { calUtil.setMonthAndDay(); calUtil.draw(signList); calUtil.bindEnvent(); }, draw: function(signList) { //绑定日历 var str = calUtil.drawCal(calUtil.showYear, calUtil.showMonth, signList); $("#calendar").html(str); //绑定日历表头 var calendarName = calUtil.showYear + "年" + calUtil.showMonth + "月"; $(".calendar_month_span").html(calendarName); }, //获取当前选择的年月 setMonthAndDay: function() { switch (calUtil.eventName) { case "load": var current = new Date(); calUtil.showYear = current.getFullYear(); calUtil.showMonth = current.getMonth() + 1; break; case "prev": var nowMonth = $(".calendar_month_span").html().split("年")[1].split("月")[0]; calUtil.showMonth = parseInt(nowMonth) - 1; if (calUtil.showMonth == 0) { calUtil.showMonth = 12; calUtil.showYear -= 1; } break; case "next": var nowMonth = $(".calendar_month_span").html().split("年")[1].split("月")[0]; calUtil.showMonth = parseInt(nowMonth) + 1; if (calUtil.showMonth == 13) { calUtil.showMonth = 1; calUtil.showYear += 1; } break; } }, //ajax获取日历json数据 var signList = [{ "signDay": "09" }, { "signDay": "11" }, { "signDay": "12" }, { "signDay": "13" }]; calUtil.init(signList);