小程序
小游戏
企业微信
微信支付
扫描小程序码分享
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
检查下格式,真机调试时候使用的电脑端的时间格式
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
怎么个不正常
var util = require('../../utils/util.js');
Component ({
options: {
addGlobalClass: true
},
properties: {
obj:{
type:Object,
value:{}
}
data: {
hasEmptyGrid: false
ready(options) {
let year = this.data.obj.project_signs[0].year
let month = this.data.obj.project_signs[0].month
let day = this.data.obj.project_signs[0].day
const cur_year = new Date( year + '/' + month ).getFullYear();
const cur_month = new Date( year + '/' + month ).getMonth() + 1;
const weeks_ch = ['日', '一', '二', '三', '四', '五', '六'];
this.calculateEmptyGrids(cur_year, cur_month);
this.calculateDays(cur_year, cur_month);
this.setData({
cur_year,
cur_month,
sign_in_count: new Date(this.data.obj.sign_in_count).getDate(),
sign_out_count: new Date(this.data.obj.sign_out_count).getDate(),
no_work_count: new Date(this.data.obj.no_work_count).getDate()
})
methods: {
getThisMonthDays(year, month) {
return new Date(year, month, 0).getDate();
getFirstDayOfWeek(year, month) {
return new Date(Date.UTC(year, month - 1, 1)).getDay();
calculateEmptyGrids(year, month) {
const firstDayOfWeek = this.getFirstDayOfWeek(year, month);
let empytGrids = [];
if (firstDayOfWeek > 0) {
for (let i = 0; i < firstDayOfWeek; i++) {
empytGrids.push(i);
hasEmptyGrid: true,
empytGrids
});
} else {
hasEmptyGrid: false,
empytGrids: []
calculateDays(year, month) {
let days = [];
const thisMonthDays = this.getThisMonthDays(year, month);
for (let i = 1; i <= thisMonthDays; i++) {
days.push(i);
days
handleCalendar(e) {
const handle = e.currentTarget.dataset.handle;
const cur_year = this.data.cur_year;
const cur_month = this.data.cur_month;
if (handle === 'prev') {
let newMonth = cur_month - 1;
let newYear = cur_year;
if (newMonth < 1) {
newYear = cur_year - 1;
newMonth = 12;
this.calculateDays(newYear, newMonth);
this.calculateEmptyGrids(newYear, newMonth);
cur_year: newYear,
cur_month: newMonth
let newMonth = cur_month + 1;
if (newMonth > 12) {
newYear = cur_year + 1;
newMonth = 1;
onShareAppMessage() {
return {
title: '工程日志',
desc: '分享查看',
path: 'pages/home/projectlog/main'
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
检查下格式,真机调试时候使用的电脑端的时间格式
怎么个不正常
var util = require('../../utils/util.js');
Component ({
options: {
addGlobalClass: true
},
properties: {
obj:{
type:Object,
value:{}
}
},
data: {
hasEmptyGrid: false
},
ready(options) {
let year = this.data.obj.project_signs[0].year
let month = this.data.obj.project_signs[0].month
let day = this.data.obj.project_signs[0].day
const cur_year = new Date( year + '/' + month ).getFullYear();
const cur_month = new Date( year + '/' + month ).getMonth() + 1;
const weeks_ch = ['日', '一', '二', '三', '四', '五', '六'];
this.calculateEmptyGrids(cur_year, cur_month);
this.calculateDays(cur_year, cur_month);
this.setData({
cur_year,
cur_month,
sign_in_count: new Date(this.data.obj.sign_in_count).getDate(),
sign_out_count: new Date(this.data.obj.sign_out_count).getDate(),
no_work_count: new Date(this.data.obj.no_work_count).getDate()
})
},
methods: {
getThisMonthDays(year, month) {
return new Date(year, month, 0).getDate();
},
getFirstDayOfWeek(year, month) {
return new Date(Date.UTC(year, month - 1, 1)).getDay();
},
calculateEmptyGrids(year, month) {
const firstDayOfWeek = this.getFirstDayOfWeek(year, month);
let empytGrids = [];
if (firstDayOfWeek > 0) {
for (let i = 0; i < firstDayOfWeek; i++) {
empytGrids.push(i);
}
this.setData({
hasEmptyGrid: true,
empytGrids
});
} else {
this.setData({
hasEmptyGrid: false,
empytGrids: []
});
}
},
calculateDays(year, month) {
let days = [];
const thisMonthDays = this.getThisMonthDays(year, month);
for (let i = 1; i <= thisMonthDays; i++) {
days.push(i);
}
this.setData({
days
});
},
handleCalendar(e) {
const handle = e.currentTarget.dataset.handle;
const cur_year = this.data.cur_year;
const cur_month = this.data.cur_month;
if (handle === 'prev') {
let newMonth = cur_month - 1;
let newYear = cur_year;
if (newMonth < 1) {
newYear = cur_year - 1;
newMonth = 12;
}
this.calculateDays(newYear, newMonth);
this.calculateEmptyGrids(newYear, newMonth);
this.setData({
cur_year: newYear,
cur_month: newMonth
})
} else {
let newMonth = cur_month + 1;
let newYear = cur_year;
if (newMonth > 12) {
newYear = cur_year + 1;
newMonth = 1;
}
this.calculateDays(newYear, newMonth);
this.calculateEmptyGrids(newYear, newMonth);
this.setData({
cur_year: newYear,
cur_month: newMonth
})
}
},
onShareAppMessage() {
return {
title: '工程日志',
desc: '分享查看',
path: 'pages/home/projectlog/main'
}
}
}
})