作者 吴亚瑞

测评答题判断

... ... @@ -6,11 +6,11 @@ Page({
* 页面的初始数据
*/
data: {
data_arr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],//周
year:"",//当前年
month:"",//当前月份
today:'',//当前选中的日期
fixed_today:'',//当前日期
data_arr: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], //周
year: "", //当前年
month: "", //当前月份
today: '', //当前选中的日期
fixed_today: '', //当前日期
sbox: [{ // 打卡任务列表
img: '/img/ic_date_dangri@2x.png',
text: '当日任务',
... ... @@ -19,12 +19,12 @@ Page({
{
img: '/img/ic_date_dangri@2x.png',
text: '测评任务',
bool:true
bool: true
},
{
img: '/img/ic_date_dangri@2x.png',
text: '比赛任务',
bool:true
bool: true
}
]
},
... ... @@ -32,14 +32,19 @@ Page({
var index = e.currentTarget.dataset.index;
var item = this.data.sbox[index];
console.log(item)
if(item.type == 'today'){
if (item.type == 'today') {
wx.redirectTo({
url: '/pages/first/first?id=' + item.id + "&clockType=" + item.TodayStatus + "&type=" + item.type,
})
}else if(item.type == 'match'){
})
} else if (item.type == 'match') {
wx.redirectTo({
url: '/pages/first/first?id=' + item.id + "&clockType=" + item.TodayStatus + "&type=" + item.type,
})
})
} else {
wx.redirectTo({
url: '/pages/question/question?id=' + item.id
})
}
// this.data.sbox[index].bool =false
... ... @@ -52,23 +57,28 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let now = new Date()//获取年
let year = now.getFullYear()//获取月
let today = now.getDate()//获取月
let fixed_today = now.getDate()//获取月
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
year,
month,
today,
fixed_today
})
this.showCalendar()
this.DayList()
},
showCalendar(){
let {year,month} = this.data
showCalendar() {
let {
year,
month
} = this.data
//以下两个month已经+1
let currentMonthDays = new Date(year,month,0).getDate() //获取当前月份的天数
let currentMonthDays = new Date(year, month, 0).getDate() //获取当前月份的天数
let calendar = []
// for(var i=1;i <= currentMonthDays; i++){
// ({
... ... @@ -81,56 +91,60 @@ Page({
// }
let startWeek = new Date(year + '/' + month + '/' + 1).getDay(); //本月第一天是从星期几开始的
this.setData({
currentMonthDays,startWeek,calendar
currentMonthDays,
startWeek,
calendar
})
},
DayList(){
},
DayList() {
var that = this;
var month = this.data.year + '-' + this.data.month
app.post("index/DayList", {month}).then(res => {
if(res.code == 1){
app.post("index/DayList", {
month
}).then(res => {
if (res.code == 1) {
//打卡 补卡状态
let calendar = []
//相应日期的任务列表
var sbox = [];
res.data.forEach((val,ind) => {
res.data.forEach((val, ind) => {
//打卡 补卡状态判断
if(val.TodayStatus == 1){
val.clock = 'clock';//正常打卡
}else if(val.TodayStatus == 0){
val.clock = 'no_clock';//缺卡
}else{
if (val.TodayStatus == 1) {
val.clock = 'clock'; //正常打卡
} else if (val.TodayStatus == 0) {
val.clock = 'no_clock'; //缺卡
} else {
val.clock = ''
}
val.day = ind+1;
val.day = ind + 1;
calendar.push(val)
//相应日期的任务列表判断
if(val.day == this.data.today){
if(val.TodayId){
if (val.day == this.data.today) {
if (val.TodayId) {
sbox.push({
img: '/img/ic_date_dangri@2x.png',
text: '当日任务',
id:val.TodayId,
type:'today',
clockType:val.TodayStatus
id: val.TodayId,
type: 'today',
clockType: val.TodayStatus
})
}
if(val.MatchId){
if (val.MatchId) {
sbox.push({
img: '/img/ic_date_dangri@2x.png',
text: '比赛任务',
id:val.MatchId,
type:'match',
clockType:''
id: val.MatchId,
type: 'match',
clockType: ''
})
}
if(val.EvaluationId){
if (val.EvaluationId) {
sbox.push({
img: '/img/ic_date_dangri@2x.png',
text: '测评任务',
id:val.EvaluationId,
type:'',
clockType:''
id: val.EvaluationId,
type: '',
clockType: ''
})
}
}
... ... @@ -142,8 +156,8 @@ Page({
}
}).catch(err => {
wx.showToast({
title: err.msg,
icon: 'none'
title: err.msg,
icon: 'none'
})
})
},
... ... @@ -196,36 +210,36 @@ Page({
},
//切换日期 打卡任务
handoffDate(e){
handoffDate(e) {
let sbox = []
var data = e.currentTarget.dataset.item;
if(this.data.fixed_today < data.day){
if (this.data.fixed_today < data.day) {
return
}
if(data.TodayId){
if (data.TodayId) {
sbox.push({
img: '/img/ic_date_dangri@2x.png',
text: '当日任务',
id:data.TodayId
id: data.TodayId
})
}
if(data.MatchId){
if (data.MatchId) {
sbox.push({
img: '/img/ic_date_dangri@2x.png',
text: '比赛任务',
id:data.MatchId
id: data.MatchId
})
}
if(data.EvaluationId){
if (data.EvaluationId) {
sbox.push({
img: '/img/ic_date_dangri@2x.png',
text: '测评任务',
id:data.EvaluationId
id: data.EvaluationId
})
}
this.setData({
today:data.day,
today: data.day,
sbox
})
}
... ...
... ... @@ -37,7 +37,7 @@ Page({
getlist() {
var that = this;
app.post("evaluation/EvaluationQuestion", {
evaluation_id: 1
evaluation_id: this.id
}).then(res => {
let list = res.data.List
... ... @@ -112,7 +112,7 @@ Page({
} else {
var that = this;
app.post("evaluation/EvaluationTask", {
evaluation_id: 1,
evaluation_id: this.id,
json: JSON.stringify(this.data.clockData)
}).then(res => {
... ...
... ... @@ -23,7 +23,7 @@
align-items: center;
padding: 0 48rpx;
padding-bottom: 80rpx;
background: rgba(77, 76, 84, 1);
background: #3A3942;
}
.top-1 {
... ...