littleFlower.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import httpRequestApi from '../../../utils/APIClient';
  2. import {
  3. formatDate
  4. } from '../../../utils/util';
  5. Page({
  6. data: {
  7. misssionList: [],
  8. continuousDay: 0
  9. },
  10. onLoad: function (options) {
  11. wx.setNavigationBarTitle({
  12. title: '小红花'
  13. })
  14. httpRequestApi.getMissionList().success((res) => {
  15. res.data.data.forEach(item => {
  16. const temp = {}
  17. temp.title = item.task.title;
  18. temp.type = item.task.type;
  19. temp.type = item.task.type;
  20. temp.bonus = item.task.award;
  21. this.data.misssionList.push(temp)
  22. });
  23. this.setData({
  24. misssionList: this.data.misssionList
  25. })
  26. this.getSignInData();
  27. });
  28. },
  29. getSignInData: function () {
  30. httpRequestApi.getSignInData().success(res => {
  31. console.log(res)
  32. let today = res.data.data.currentTime;
  33. let continuousDay = res.data.data.continuousDay;
  34. let dateList = [];
  35. let myIndex = 0
  36. for (let index = 0; index < 7; index++) {
  37. let temp = {};
  38. temp.index = index;
  39. if (continuousDay <= 7) {
  40. if (continuousDay - 1 === index) {
  41. temp.isToday = true
  42. myIndex = index;
  43. } else {
  44. temp.isToday = false
  45. }
  46. } else {
  47. if (6 === index) {
  48. temp.isToday = true
  49. myIndex = index;
  50. } else {
  51. temp.isToday = false
  52. }
  53. }
  54. dateList.push(temp);
  55. }
  56. dateList.forEach((item, index) => {
  57. let pointNum = myIndex - index;
  58. switch (continuousDay) {
  59. case 1:
  60. if (pointNum >= 0 && pointNum <= 5) {
  61. item.style = 'red';
  62. item.mark = '3';
  63. } else if (pointNum < 0 && pointNum >= -3) {
  64. item.style = 'white';
  65. item.mark = '3';
  66. } else {
  67. item.style = 'white';
  68. item.mark = '5';
  69. }
  70. break;
  71. case 2:
  72. if (pointNum >= 0 && pointNum <= 2) {
  73. item.style = 'red';
  74. item.mark = '3';
  75. // 超过今天五个圈圈
  76. } else if (pointNum < 0 && pointNum >= -2) {
  77. item.style = 'white';
  78. item.mark = '3';
  79. } else {
  80. item.style = 'white';
  81. item.mark = '5';
  82. }
  83. break;
  84. case 3:
  85. if (pointNum >= 0 && pointNum <= 3) {
  86. item.style = 'red';
  87. item.mark = '3';
  88. // 超过今天五个圈圈
  89. } else if (pointNum === -1) {
  90. item.style = 'white';
  91. item.mark = '3';
  92. } else {
  93. item.style = 'white';
  94. item.mark = '5';
  95. }
  96. break;
  97. case 4:
  98. if (pointNum >= 0 && pointNum <= 4) {
  99. item.style = 'red';
  100. item.mark = '3';
  101. // 超过今天五个圈圈
  102. } else {
  103. item.style = 'white';
  104. item.mark = '5';
  105. }
  106. break;
  107. case 5:
  108. if (pointNum >= 0 && pointNum <= 5) {
  109. item.style = 'red';
  110. item.mark = '3';
  111. // 超过今天五个圈圈
  112. } else {
  113. item.style = 'white';
  114. item.mark = '5';
  115. }
  116. break;
  117. case 6:
  118. if (pointNum >= 1) {
  119. item.style = 'red';
  120. item.mark = '3';
  121. // 超过今天五个圈圈
  122. } else if (pointNum < 1 && pointNum >= 0) {
  123. item.style = 'red';
  124. item.mark = '5';
  125. } else {
  126. item.style = 'white';
  127. item.mark = '5';
  128. }
  129. break;
  130. case 7:
  131. if (pointNum >= 2) {
  132. item.style = 'red';
  133. item.mark = '3';
  134. // 超过今天五个圈圈
  135. } else if (pointNum < 2 && pointNum >= 0) {
  136. item.style = 'red';
  137. item.mark = '5';
  138. } else {
  139. item.style = 'white';
  140. item.mark = '5';
  141. }
  142. break;
  143. case 8:
  144. if (pointNum >= 3) {
  145. item.style = 'red';
  146. item.mark = '3';
  147. // 超过今天五个圈圈
  148. } else if (pointNum < 3 && pointNum >= 0) {
  149. item.style = 'red';
  150. item.mark = '5';
  151. }
  152. break;
  153. case 9:
  154. if (pointNum >= 4) {
  155. item.style = 'red';
  156. item.mark = '3';
  157. // 超过今天五个圈圈
  158. } else if (pointNum < 4 && pointNum >= 0) {
  159. item.style = 'red';
  160. item.mark = '5';
  161. }
  162. break;
  163. case 10:
  164. if (pointNum >= 5) {
  165. item.style = 'red';
  166. item.mark = '3';
  167. // 超过今天五个圈圈
  168. } else if (pointNum < 5 && pointNum >= 0) {
  169. item.style = 'red';
  170. item.mark = '5';
  171. }
  172. break;
  173. case 11:
  174. if (pointNum >= 6) {
  175. item.style = 'red';
  176. item.mark = '3';
  177. // 超过今天五个圈圈
  178. } else if (pointNum < 6 && pointNum >= 0) {
  179. item.style = 'red';
  180. item.mark = '5';
  181. }
  182. break;
  183. default:
  184. item.style = 'red';
  185. item.mark = '5';
  186. break;
  187. }
  188. // 生成日期
  189. if (pointNum < 0) {
  190. item.time = formatDate(today + (pointNum * 86400000 * -1), 6);
  191. }
  192. if (pointNum === 0) {
  193. item.time = '今日';
  194. }
  195. if (pointNum > 0) {
  196. item.time = formatDate(today - pointNum * 86400000, 6);
  197. }
  198. });
  199. this.setData({
  200. dateList
  201. })
  202. });
  203. },
  204. countTheDay: function (item) {
  205. }
  206. })