statistics1.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. showCal: false,
  8. // start: '',
  9. // startTime: false,
  10. // end: '',
  11. // endTime: false,
  12. // dayStyle: [{
  13. // month: 'current',
  14. // day: new Date().getDate(),
  15. // color: 'white',
  16. // background: '#AAD4F5'
  17. // },
  18. // {
  19. // month: 'current',
  20. // day: new Date().getDate(),
  21. // color: 'white',
  22. // background: '#AAD4F5'
  23. // }
  24. // ],
  25. list: {}
  26. },
  27. start: function() {
  28. var that = this;
  29. that.calendar = that.selectComponent("#calendar")
  30. var starTime = ''
  31. var day = ''
  32. var endTime = ''
  33. that.calendar.xianShi({
  34. data: function(res) {
  35. console.log(res) //选择的日期
  36. if (res != null) {
  37. if (res.length == 1) {
  38. starTime = res[0].data
  39. } else if (res.length == 2) {
  40. starTime = res[0].data
  41. endTime = res[1].data
  42. day = res[1].chaDay
  43. console.log(endTime)
  44. let data = {
  45. " pay_time_between[0]": starTime,
  46. " pay_time_between[1]": endTime,
  47. }
  48. app.request('order/profitDetail', data, 'GET').then(res => {
  49. console.log(res);
  50. if (res.statusCode == 200) {
  51. console.log(res)
  52. that.setData({
  53. list: res.data
  54. })
  55. }
  56. })
  57. }
  58. } else {
  59. starTime = ''
  60. day = ''
  61. endTime = ''
  62. }
  63. that.setData({
  64. starTime: starTime,
  65. endTime: endTime,
  66. day: day,
  67. })
  68. }
  69. })
  70. },
  71. getState() {
  72. let day = new Date();
  73. day.setTime(day.getTime());
  74. let today = day.getFullYear() + "-" + (day.getMonth() + 1) + "-" + day.getDate();
  75. var day1 = new Date();
  76. day1.setTime(day1.getTime() + 24 * 60 * 60 * 1000);
  77. var tommorw = day1.getFullYear() + "-" + (day1.getMonth() + 1) + "-" + day1.getDate();
  78. this.setData({
  79. starTime: today,
  80. endTime: tommorw
  81. })
  82. let data = {
  83. " pay_time_between[0]": this.data.starTime,
  84. " pay_time_between[1]": this.data.endTime,
  85. }
  86. app.request('order/profitDetail', data, 'GET').then(res => {
  87. if (res.statusCode == 200) {
  88. console.log(res)
  89. this.setData({
  90. list: res.data
  91. })
  92. }
  93. })
  94. },
  95. inquire() {
  96. let that = this;
  97. let begin = Date.parse(new Date(that.data.start));
  98. let finish = Date.parse(new Date(that.data.end));
  99. if (!that.data.start) {
  100. wx.showToast({
  101. title: '开始日期不能为空',
  102. icon: 'none'
  103. })
  104. } else if (!that.data.end) {
  105. wx.showToast({
  106. title: '结束日期不能为空',
  107. icon: 'none'
  108. })
  109. } else if (begin > finish) {
  110. wx.showToast({
  111. title: '结束日期不能大于开始日期',
  112. icon: 'none'
  113. })
  114. } else {
  115. let data = {
  116. " pay_time_between[0]": that.data.starTime,
  117. " pay_time_between[1]": that.data.endTime,
  118. }
  119. app.request('order/profitDetail', data, 'GET').then(res => {
  120. if (res.statusCode == 200) {
  121. console.log(res)
  122. this.setData({
  123. list: res.data
  124. })
  125. }
  126. })
  127. }
  128. },
  129. //给点击的日期设置一个背景颜色
  130. dayClick: function(e) {
  131. let that = this;
  132. console.log(that.data.startTime)
  133. if (that.data.startTime == true) {
  134. that.setData({
  135. start: e.detail.year + "-" + e.detail.month + "-" + e.detail.day,
  136. showCal: false
  137. })
  138. }
  139. if (that.data.endTime == true) {
  140. that.setData({
  141. end: e.detail.year + "-" + e.detail.month + "-" + e.detail.day,
  142. showCal: false
  143. })
  144. }
  145. let clickDay = e.detail.day;
  146. let changeDay = `dayStyle[1].day`;
  147. let changeBg = `dayStyle[1].background`;
  148. this.setData({
  149. [changeDay]: clickDay,
  150. [changeBg]: "#84e7d0"
  151. })
  152. },
  153. onLoad: function() {
  154. this.getState();
  155. }
  156. })