Commit 8d22ccd7 by xiexiaoqin

fix : startTime

parent fbc467d7
import { getInterTime } from '../../utils/utils';
const currentDate = new Date();
const weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const durationList = [{ value: 60, label: '1小时' }, { value: 120, label: '2小时' }, { value: 30, label: '30分钟' }];
......@@ -179,9 +180,10 @@ Component({
methods: {
//设置初始值
setInitialValue() {
let startDate = new Date();
let startDate = getInterTime(new Date());
//结束日期默认+ 半小时
let endDate = new Date();
let endDate = getInterTime(new Date());
const min = endDate.getMinutes();
endDate.setMinutes(min + 30);
// 赋值
......
import { addSchedule, getUserScheduleInTime } from '../../api/request.js'
import { throttle } from './../../utils/utils.js'
import { throttle, getInterTime } from './../../utils/utils.js'
import create from 'dd-store'
create.Page({
data: {
......@@ -348,12 +348,13 @@ create.Page({
},
// 获取时间参数
getTimes(time = new Date()) {
let date = new Date(time)
let date = getInterTime(new Date(time))
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
let hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
let miunutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
return `${year}/${month}/${day} ${hour}:${miunutes}:00`
},
// 是否跨天
......
......@@ -4,7 +4,7 @@ export function throttle(fn, gapTime) {
gapTime = 1500;
}
let _lastTime = null;
return function() {
return function () {
let _nowTime = new Date();
if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments); //将this和参数传给原函数
......@@ -14,13 +14,13 @@ export function throttle(fn, gapTime) {
}
export function debounce(fn, delay) {
let timeout = null;
return function () {
clearTimeout(timeout);
timeout = setTimeout(() => {
fn.apply(this, arguments);
}, delay);
};
let timeout = null;
return function () {
clearTimeout(timeout);
timeout = setTimeout(() => {
fn.apply(this, arguments);
}, delay);
};
}
// 判断时间 刚刚 五分钟以内 十分钟以内 正常时间年月日
......@@ -141,3 +141,15 @@ export function getCurrentMonthLast(date) {
}
return date.getFullYear() + "-" + month + "-" + day;
}
//开始时间取整
export function getInterTime(time) {
let date = time;
if (typeof time == 'string') {
date = new Date(time)
}
const min = date.getMinutes();
const addMin = Math.floor(min / 5) * 5 + 5;
date.setMinutes(addMin);
return date;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment