my-log.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. var app = getApp()
  2. var api = require('../../utils/api.js');
  3. Page({
  4. data: {
  5. loged: [
  6. {
  7. month: 'current',
  8. day: '1',
  9. color: '#77b9b9'
  10. },
  11. {
  12. month: 'current',
  13. day: '2',
  14. color: '#77b9b9'
  15. },
  16. {
  17. month: 'current',
  18. day: '3',
  19. color: '#f65556'
  20. },
  21. {
  22. month: 'current',
  23. day: '4',
  24. color: '#f65556'
  25. },
  26. {
  27. month: 'current',
  28. day: '5',
  29. color: '#f65556'
  30. }, {
  31. month: 'current',
  32. day: '6',
  33. color: '#77b9b9'
  34. },
  35. {
  36. month: 'current',
  37. day: '7',
  38. color: '#77b9b9'
  39. },
  40. {
  41. month: 'current',
  42. day: '8',
  43. color: '#77b9b9'
  44. },
  45. {
  46. month: 'current',
  47. day: '9',
  48. color: '#77b9b9'
  49. },
  50. ],
  51. thisMonthLearnTime: 0,
  52. totalLearnTime: 0,
  53. checkCardDays: 0
  54. },
  55. prevDate: function(e) {
  56. this.getMyLearnInfo(e.detail.currentYear, e.detail.currentMonth)
  57. },
  58. nextDate: function (e) {
  59. this.getMyLearnInfo(e.detail.currentYear, e.detail.currentMonth)
  60. },
  61. dateChange: function(e) {
  62. this.getMyLearnInfo(e.detail.currentYear, e.detail.currentMonth)
  63. },
  64. onLoad: function () {
  65. this.getMyLearnInfo()
  66. },
  67. getMyLearnInfo: function(year, month) {
  68. var date = new Date(),
  69. year = year || date.getFullYear(),
  70. month = month || date.getMonth() + 1
  71. var pt_student = wx.getStorageSync('pt_student')
  72. wx.request({
  73. url: api.getMyLearnInfoUrl,
  74. method: 'GET',
  75. data: {
  76. 'student_id': pt_student.id,
  77. 'year': year,
  78. 'month': month
  79. },
  80. success: res => {
  81. if (res.data.status == 'success') {
  82. // console.log(res)
  83. this.setData({
  84. loged: res.data.checkCardList,
  85. thisMonthLearnTime: res.data.thisMonthLearnTime,
  86. totalLearnTime: res.data.totalLearnTime,
  87. checkCardDays: res.data.checkCardDays
  88. })
  89. }
  90. }
  91. })
  92. }
  93. })