littleFlower.js 8.5 KB

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