|
|
// pages/eight/eight.js
|
|
|
const app = getApp()
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
sbox: [{
|
|
|
data_arr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],//周
|
|
|
year:"",//当前年
|
|
|
month:"",//当前月份
|
|
|
today:'',//当前选中的日期
|
|
|
fixed_today:'',//当前日期
|
|
|
sbox: [{ // 打卡任务列表
|
|
|
img: '/img/ic_date_dangri@2x.png',
|
|
|
text: '当日任务',
|
|
|
bool: true
|
...
|
...
|
@@ -22,7 +28,8 @@ Page({ |
|
|
}
|
|
|
]
|
|
|
},
|
|
|
gotoday(){
|
|
|
gotoday(e){
|
|
|
var data = e.currentTarget.dataset.id;
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/mission/mission',
|
|
|
})
|
...
|
...
|
@@ -41,9 +48,95 @@ Page({ |
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
let now = new Date()//获取年
|
|
|
let year = now.getFullYear()//获取月
|
|
|
let today = now.getDate()//获取月
|
|
|
let fixed_today = now.getDate()//获取月
|
|
|
// month获取是从 0~11
|
|
|
let month = now.getMonth() + 1
|
|
|
this.setData({
|
|
|
year,month,today,
|
|
|
fixed_today
|
|
|
})
|
|
|
this.showCalendar()
|
|
|
this.DayList()
|
|
|
},
|
|
|
showCalendar(){
|
|
|
let {year,month} = this.data
|
|
|
//以下两个month已经+1
|
|
|
let currentMonthDays = new Date(year,month,0).getDate() //获取当前月份的天数
|
|
|
let calendar = []
|
|
|
// for(var i=1;i <= currentMonthDays; i++){
|
|
|
// ({
|
|
|
// "date": i, //日期
|
|
|
// "TodayStatus": null, //今日任务状态 打卡类型:2=未打卡,1=正常打卡,0=补卡 null是没有今日任务
|
|
|
// "TodayId": null,//今日任务ID null是没有今日任务 用于今日任务状态未未打卡状态时 去补卡
|
|
|
// "MatchId": null, //比赛任务ID 用户判断当日是否有比赛任务 null未没有 不为空 则有
|
|
|
// "EvaluationId": null //测评任务ID 用户判断当日是否有测评任务 null未没有 不为空 则有
|
|
|
// })
|
|
|
// }
|
|
|
let startWeek = new Date(year + '/' + month + '/' + 1).getDay(); //本月第一天是从星期几开始的
|
|
|
this.setData({
|
|
|
currentMonthDays,startWeek,calendar
|
|
|
})
|
|
|
},
|
|
|
DayList(){
|
|
|
var that = this;
|
|
|
var month = this.data.year + '-' + this.data.month
|
|
|
app.post("index/DayList", {month}).then(res => {
|
|
|
if(res.code == 1){
|
|
|
//打卡 补卡状态
|
|
|
let calendar = []
|
|
|
//相应日期的任务列表
|
|
|
var sbox = [];
|
|
|
res.data.forEach((val,ind) => {
|
|
|
//打卡 补卡状态判断
|
|
|
if(val.TodayStatus == 1){
|
|
|
val.clock = 'clock';//正常打卡
|
|
|
}else if(val.TodayStatus == 0){
|
|
|
val.clock = 'no_clock';//缺卡
|
|
|
}else{
|
|
|
val.clock = ''
|
|
|
}
|
|
|
val.day = ind+1;
|
|
|
calendar.push(val)
|
|
|
//相应日期的任务列表判断
|
|
|
if(val.day == this.data.today){
|
|
|
if(val.TodayId){
|
|
|
sbox.push({
|
|
|
img: '/img/ic_date_dangri@2x.png',
|
|
|
text: '当日任务',
|
|
|
id:val.TodayId
|
|
|
})
|
|
|
}
|
|
|
if(val.MatchId){
|
|
|
sbox.push({
|
|
|
img: '/img/ic_date_dangri@2x.png',
|
|
|
text: '比赛任务',
|
|
|
id:val.MatchId
|
|
|
})
|
|
|
}
|
|
|
if(val.EvaluationId){
|
|
|
sbox.push({
|
|
|
img: '/img/ic_date_dangri@2x.png',
|
|
|
text: '测评任务',
|
|
|
id:val.EvaluationId
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
that.setData({
|
|
|
calendar,
|
|
|
sbox
|
|
|
})
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
wx.showToast({
|
|
|
title: err.msg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
...
|
...
|
@@ -91,5 +184,39 @@ Page({ |
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
},
|
|
|
//切换日期 打卡任务
|
|
|
handoffDate(e){
|
|
|
let sbox = []
|
|
|
var data = e.currentTarget.dataset.item;
|
|
|
if(this.data.fixed_today < data.day){
|
|
|
return
|
|
|
}
|
|
|
if(data.TodayId){
|
|
|
sbox.push({
|
|
|
img: '/img/ic_date_dangri@2x.png',
|
|
|
text: '当日任务',
|
|
|
id:data.TodayId
|
|
|
})
|
|
|
}
|
|
|
if(data.MatchId){
|
|
|
sbox.push({
|
|
|
img: '/img/ic_date_dangri@2x.png',
|
|
|
text: '比赛任务',
|
|
|
id:data.MatchId
|
|
|
})
|
|
|
}
|
|
|
if(data.EvaluationId){
|
|
|
sbox.push({
|
|
|
img: '/img/ic_date_dangri@2x.png',
|
|
|
text: '测评任务',
|
|
|
id:data.EvaluationId
|
|
|
})
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
today:data.day,
|
|
|
sbox
|
|
|
})
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|