index.js 1.8 KB

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