index.js 3.6 KB

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