index.js 3.1 KB

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