index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. const _Http = getApp().globalData.http,
  2. getHeight = require("../../utils/getRheRemainingHeight");
  3. Page({
  4. data: {
  5. list: [],
  6. },
  7. onLoad(options) {},
  8. /* 日历加载完成 */
  9. handleCalendarLoad({
  10. detail
  11. }) {
  12. console.log("日历加载完成", detail)
  13. /* let {
  14. year,
  15. month,
  16. day
  17. } = detail.date;
  18. month = month < 10 ? "0" + month : month;
  19. day = day < 10 ? "0" + day : day;
  20. this.querySignIn(year + '-' + month + '-' + day) */
  21. },
  22. /* 日期发生变化 */
  23. handleCalendarDateChange({
  24. detail
  25. }) {
  26. console.log("日期发生变化", detail)
  27. this.setData({
  28. list: []
  29. })
  30. if (detail.date.marker) {
  31. let {
  32. year,
  33. month,
  34. day
  35. } = detail.date;
  36. month = month < 10 ? "0" + month : month;
  37. day = day < 10 ? "0" + day : day;
  38. this.querySignIn(year + '-' + month + '-' + day)
  39. }
  40. },
  41. /* 查询签到日 */
  42. checkIn(content) {
  43. _Http.basic({
  44. "accesstoken": "3614131fa126be7f41ea07d99b5d9fe6",
  45. "id": 20221229150001,
  46. content
  47. }).then(res => {
  48. console.log("查询签到日", content, res)
  49. if (res.data.length) {
  50. this.selectComponent("#calendar").setMarkers(res.data.map(v => {
  51. let date = v.split("-");
  52. return {
  53. year: date[0],
  54. month: date[1],
  55. day: date[2],
  56. type: "schedule",
  57. mark: '签到',
  58. color: '#2a97ff',
  59. bgColor: '#cce6ff'
  60. }
  61. }))
  62. }
  63. })
  64. },
  65. /* 查询签到记录 */
  66. querySignIn(signindate) {
  67. _Http.basic({
  68. "id": 20221229150101,
  69. "content": {
  70. signindate,
  71. pageSize: 999
  72. }
  73. }).then(res => {
  74. console.log('查询签到记录', res)
  75. this.setData({
  76. list: res.data
  77. })
  78. })
  79. },
  80. /* 日期范围发生变化 */
  81. handleCalendarRangeChange({
  82. detail
  83. }) {
  84. console.log("日期范围变化", detail)
  85. let {
  86. year,
  87. month,
  88. day
  89. } = detail.curr;
  90. this.checkIn({
  91. year,
  92. month
  93. });
  94. this.setData({
  95. list: []
  96. })
  97. month = month < 10 ? "0" + month : month;
  98. day = day < 10 ? "0" + day : day;
  99. this.querySignIn(year + '-' + month + '-' + day)
  100. },
  101. /* 更新日期数据 */
  102. toDate(date) {
  103. this.selectComponent("#calendar").toDate(date)
  104. },
  105. toSignIn() {
  106. wx.navigateTo({
  107. url: '/packageA/clockIn/signIn',
  108. })
  109. },
  110. onReady() {
  111. this.setListHeight();
  112. },
  113. setListHeight() {
  114. getHeight.getHeight('.head', this).then(res => {
  115. if (this.data.listHeight != res)
  116. this.setData({
  117. listHeight: res
  118. })
  119. });
  120. },
  121. })