123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- import httpRequestApi from '../../../utils/APIClient';
- import {
- formatDate
- } from '../../../utils/util';
- Page({
- data: {
- misssionList: [],
- continuousDay: 0
- },
- onLoad: function (options) {
- wx.setNavigationBarTitle({
- title: '小红花'
- })
- httpRequestApi.getMissionList().success((res) => {
- res.data.data.forEach(item => {
- const temp = {}
- temp.title = item.task.title;
- temp.type = item.task.type;
- temp.type = item.task.type;
- temp.bonus = item.task.award;
- this.data.misssionList.push(temp)
- });
- this.setData({
- misssionList: this.data.misssionList
- })
- this.getSignInData();
- });
- },
- getSignInData: function () {
- httpRequestApi.getSignInData().success(res => {
- console.log(res)
- let today = res.data.data.currentTime;
- let continuousDay = res.data.data.continuousDay;
- let dateList = [];
- let myIndex = 0
- for (let index = 0; index < 7; index++) {
- let temp = {};
- temp.index = index;
- if (continuousDay <= 7) {
- if (continuousDay - 1 === index) {
- temp.isToday = true
- myIndex = index;
- } else {
- temp.isToday = false
- }
- } else {
- if (6 === index) {
- temp.isToday = true
- myIndex = index;
- } else {
- temp.isToday = false
- }
- }
- dateList.push(temp);
- }
- dateList.forEach((item, index) => {
- let pointNum = myIndex - index;
- switch (continuousDay) {
- case 1:
- if (pointNum >= 0 && pointNum <= 5) {
- item.style = 'red';
- item.mark = '3';
- } else if (pointNum < 0 && pointNum >= -3) {
- item.style = 'white';
- item.mark = '3';
- } else {
- item.style = 'white';
- item.mark = '5';
- }
- break;
- case 2:
- if (pointNum >= 0 && pointNum <= 2) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum < 0 && pointNum >= -2) {
- item.style = 'white';
- item.mark = '3';
- } else {
- item.style = 'white';
- item.mark = '5';
- }
- break;
- case 3:
- if (pointNum >= 0 && pointNum <= 3) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum === -1) {
- item.style = 'white';
- item.mark = '3';
- } else {
- item.style = 'white';
- item.mark = '5';
- }
- break;
- case 4:
- if (pointNum >= 0 && pointNum <= 4) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else {
- item.style = 'white';
- item.mark = '5';
- }
- break;
- case 5:
- if (pointNum >= 0 && pointNum <= 5) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else {
- item.style = 'white';
- item.mark = '5';
- }
- break;
- case 6:
- if (pointNum >= 1) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum < 1 && pointNum >= 0) {
- item.style = 'red';
- item.mark = '5';
- } else {
- item.style = 'white';
- item.mark = '5';
- }
- break;
- case 7:
- if (pointNum >= 2) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum < 2 && pointNum >= 0) {
- item.style = 'red';
- item.mark = '5';
- } else {
- item.style = 'white';
- item.mark = '5';
- }
- break;
- case 8:
- if (pointNum >= 3) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum < 3 && pointNum >= 0) {
- item.style = 'red';
- item.mark = '5';
- }
- break;
- case 9:
- if (pointNum >= 4) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum < 4 && pointNum >= 0) {
- item.style = 'red';
- item.mark = '5';
- }
- break;
- case 10:
- if (pointNum >= 5) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum < 5 && pointNum >= 0) {
- item.style = 'red';
- item.mark = '5';
- }
- break;
- case 11:
- if (pointNum >= 6) {
- item.style = 'red';
- item.mark = '3';
- // 超过今天五个圈圈
- } else if (pointNum < 6 && pointNum >= 0) {
- item.style = 'red';
- item.mark = '5';
- }
- break;
- default:
- item.style = 'red';
- item.mark = '5';
- break;
- }
- // 生成日期
- if (pointNum < 0) {
- item.time = formatDate(today + (pointNum * 86400000 * -1), 6);
- }
- if (pointNum === 0) {
- item.time = '今日';
- }
- if (pointNum > 0) {
- item.time = formatDate(today - pointNum * 86400000, 6);
- }
- });
- this.setData({
- dateList
- })
- });
- },
- countTheDay: function (item) {
- }
- })
|