index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { jump } from '../../component/calendar/index.js';
  2. const app = getApp()
  3. const conf = {
  4. data: {
  5. calendarConfig: {
  6. // 配置内置主题
  7. theme: 'default'
  8. }
  9. },
  10. doSomeThing() {
  11. // 调用日历方法
  12. this.calendar.enableArea(['2022-3-7', '2022-4-7']);
  13. }
  14. };
  15. Page({
  16. /**
  17. * 选择日期后执行的事件
  18. * currentSelect 当前点击的日期
  19. * allSelectedDays 选择的所有日期(当mulit为true时,allSelectedDays有值)
  20. */
  21. afterTapDay(e) {
  22. console.log('afterTapDay', e.detail); // => { currentSelect: {}, allSelectedDays: [] }
  23. },
  24. onLoad: function(){
  25. app.checkLogin(res=>{
  26. if( !res.userId ){
  27. wx.navigateTo({
  28. url: '/pages/index/index',
  29. })
  30. }
  31. })
  32. },
  33. /**
  34. * 当日历滑动时触发(适用于周/月视图)
  35. * 可在滑动时按需在该方法内获取当前日历的一些数据
  36. */
  37. onSwipe(e) {
  38. console.log('onSwipe', e.detail);
  39. const dates = this.calendar.getCalendarDates();
  40. },
  41. /**
  42. * 当改变月份时触发
  43. * => current 当前年月 / next 切换后的年月
  44. */
  45. whenChangeMonth(e) {
  46. console.log('whenChangeMonth', e.detail);
  47. // => { current: { month: 3, ... }, next: { month: 4, ... }}
  48. },
  49. /**
  50. * 周视图下当改变周时触发
  51. * => current 当前周信息 / next 切换后周信息
  52. */
  53. whenChangeWeek(e) {
  54. console.log('whenChangeWeek', e.detail);
  55. // {
  56. // current: { currentYM: {year: 2019, month: 1 }, dates: [{}] },
  57. // next: { currentYM: {year: 2019, month: 1}, dates: [{}] },
  58. // directionType: 'next_week'
  59. // }
  60. },
  61. /**
  62. * 日期点击事件(此事件会完全接管点击事件),需自定义配置 takeoverTap 值为真才能生效
  63. * currentSelect 当前点击的日期
  64. */
  65. onTapDay(e) {
  66. console.log('onTapDay', e.detail); // => { year: 2019, month: 12, day: 3, ...}
  67. },
  68. /**
  69. * 日历初次渲染完成后触发事件,如设置事件标记
  70. */
  71. afterCalendarRender(e) {
  72. console.log('afterCalendarRender', e);
  73. }
  74. });