littleFlower.js 8.1 KB

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