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; temp.finished = item.finished; 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 <= 4) { item.style = 'red'; item.mark = '3'; } else if(pointNum === 0){ item.style = 'red'; item.mark = '5'; } 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, continuousDay }) }); }, countTheDay: function (item) { } })