index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. weeks: ["日", "一", "二", "三", "四", "五", "六"],
  7. calendarRows: this.getCalendarRows()
  8. };
  9. },
  10. methods: {
  11. getCalendarRows() {
  12. const d = /* @__PURE__ */ new Date();
  13. const year = d.getFullYear();
  14. const month = d.getMonth();
  15. const firstDay = new Date(year, month, 1).getDay();
  16. const days = new Date(year, month + 1, 0).getDate();
  17. const rows = [];
  18. let row = new Array(7).fill(0);
  19. let day = 1;
  20. for (let i = 0; i < 6; i++) {
  21. for (let j = 0; j < 7; j++) {
  22. if (i === 0 && j < firstDay)
  23. continue;
  24. if (day > days)
  25. break;
  26. row[j] = day++;
  27. }
  28. rows.push([...row]);
  29. row = new Array(7).fill(0);
  30. if (day > days)
  31. break;
  32. }
  33. return rows;
  34. },
  35. isToday(d) {
  36. const now = /* @__PURE__ */ new Date();
  37. return d === now.getDate();
  38. }
  39. }
  40. };
  41. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  42. return {
  43. a: common_vendor.f($data.weeks, (w, k0, i0) => {
  44. return {
  45. a: common_vendor.t(w),
  46. b: w
  47. };
  48. }),
  49. b: common_vendor.f($data.calendarRows, (row, i, i0) => {
  50. return {
  51. a: common_vendor.f(row, (d, k1, i1) => {
  52. return {
  53. a: common_vendor.t(d > 0 ? d : ""),
  54. b: d,
  55. c: $options.isToday(d) ? 1 : ""
  56. };
  57. }),
  58. b: i
  59. };
  60. })
  61. };
  62. }
  63. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3ceb4997"]]);
  64. wx.createPage(MiniProgramPage);
  65. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/calendar/index.js.map