|
@@ -1,5 +1,5 @@
|
|
|
-import config from '@/config';
|
|
|
-import uma from 'umtrack-wx';
|
|
|
+import config from '@/config'
|
|
|
+import uma from 'umtrack-wx'
|
|
|
|
|
|
function umaInit() {
|
|
|
config.appKey &&
|
|
@@ -13,66 +13,66 @@ function umaInit() {
|
|
|
autoGetOpenid: false
|
|
|
// debug: true, // 是否打开调试模式
|
|
|
// uploadUserInfo: true // 自动上传用户信息,设为false取消上传,默认为false
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-const SliderUnit = 0.5; // 一个色块代表0.5个小时
|
|
|
-const TimeStart = 0;
|
|
|
-const TimeEnd = 24;
|
|
|
+const SliderUnit = 0.5 // 一个色块代表0.5个小时
|
|
|
+const TimeStart = 0
|
|
|
+const TimeEnd = 24
|
|
|
|
|
|
function generateTimeSliders(openStartTime, openEndTime, disabledPast = true) {
|
|
|
let start = TimeStart,
|
|
|
- end = TimeEnd;
|
|
|
- let duration = end - start;
|
|
|
- let times = [];
|
|
|
- let { juggeValue } = getNowTime();
|
|
|
+ end = TimeEnd
|
|
|
+ let duration = end - start
|
|
|
+ let times = []
|
|
|
+ let { juggeValue } = getNowTime()
|
|
|
for (let i = 0; i < duration / SliderUnit; i++) {
|
|
|
- let value = start + i * SliderUnit;
|
|
|
- let values = value.toString().split('.');
|
|
|
- let status = '';
|
|
|
- let label = '';
|
|
|
+ let value = start + i * SliderUnit
|
|
|
+ let values = value.toString().split('.')
|
|
|
+ let status = ''
|
|
|
+ let label = ''
|
|
|
if (values.length == 1) {
|
|
|
// 代表是整数
|
|
|
label =
|
|
|
- parseInt(values[0]) < 10 ? '0' + values[0] + ':00' : values[0] + ':00';
|
|
|
+ parseInt(values[0]) < 10 ? '0' + values[0] + ':00' : values[0] + ':00'
|
|
|
} else {
|
|
|
// 代表是有分钟
|
|
|
- let mniuts = SliderUnit * 60; // 转化分钟;
|
|
|
+ let mniuts = SliderUnit * 60 // 转化分钟;
|
|
|
label =
|
|
|
parseInt(values[0]) < 10
|
|
|
? '0' + values[0] + ':' + mniuts
|
|
|
- : values[0] + ':' + mniuts;
|
|
|
+ : values[0] + ':' + mniuts
|
|
|
}
|
|
|
if (disabledPast && value < juggeValue) {
|
|
|
- status = 'past'; // 过去时间
|
|
|
+ status = 'past' // 过去时间
|
|
|
}
|
|
|
|
|
|
if (openEndTime && value >= openStartTime && value <= openEndTime) {
|
|
|
- status = 'unOpened'; // 不在开放时间内
|
|
|
+ status = 'unOpened' // 不在开放时间内
|
|
|
}
|
|
|
|
|
|
times.push({
|
|
|
value,
|
|
|
label,
|
|
|
status
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
- return times;
|
|
|
+ return times
|
|
|
}
|
|
|
function getNowTime() {
|
|
|
- let now = new Date();
|
|
|
- let hour = now.getHours();
|
|
|
- let minuts = now.getMinutes();
|
|
|
+ let now = new Date()
|
|
|
+ let hour = now.getHours()
|
|
|
+ let minuts = now.getMinutes()
|
|
|
// let hour = 16;
|
|
|
// let minuts = 30;
|
|
|
- let minutsValue = 0;
|
|
|
+ let minutsValue = 0
|
|
|
if (minuts < 30) {
|
|
|
// 在30分钟内,都可以预约当前小时,故取0
|
|
|
- minutsValue = 0;
|
|
|
+ minutsValue = 0
|
|
|
} else {
|
|
|
- minutsValue = 0.5; // 在30分钟-59分钟内,都可以预约当前小时+半小时之后,故取0.5
|
|
|
+ minutsValue = 0.5 // 在30分钟-59分钟内,都可以预约当前小时+半小时之后,故取0.5
|
|
|
}
|
|
|
- let juggeValue = hour + minutsValue;
|
|
|
+ let juggeValue = hour + minutsValue
|
|
|
|
|
|
return {
|
|
|
juggeValue,
|
|
@@ -80,110 +80,110 @@ function getNowTime() {
|
|
|
hour,
|
|
|
minuts
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function getNowDate(date) {
|
|
|
- let now = new Date();
|
|
|
- return getDate(now);
|
|
|
+ let now = new Date()
|
|
|
+ return getDate(now)
|
|
|
}
|
|
|
|
|
|
function getDate(now) {
|
|
|
- let year = now.getFullYear();
|
|
|
- let month = now.getMonth() + 1;
|
|
|
- let date = now.getDate();
|
|
|
- return [year, getTowNum(month), getTowNum(date)].join('');
|
|
|
+ let year = now.getFullYear()
|
|
|
+ let month = now.getMonth() + 1
|
|
|
+ let date = now.getDate()
|
|
|
+ return [year, getTowNum(month), getTowNum(date)].join('')
|
|
|
}
|
|
|
|
|
|
function getTowNum(num) {
|
|
|
- num = parseInt(num);
|
|
|
- return num < 10 ? '0' + num : num;
|
|
|
+ num = parseInt(num)
|
|
|
+ return num < 10 ? '0' + num : num
|
|
|
}
|
|
|
|
|
|
function formateTimeValue(timeValue) {
|
|
|
- let value = parseFloat(timeValue);
|
|
|
- let hour = parseInt(timeValue);
|
|
|
- let minits = (value - hour) * 60;
|
|
|
- return `${getTowNum(hour)}${getTowNum(minits)}00`;
|
|
|
+ let value = parseFloat(timeValue)
|
|
|
+ let hour = parseInt(timeValue)
|
|
|
+ let minits = (value - hour) * 60
|
|
|
+ return `${getTowNum(hour)}${getTowNum(minits)}00`
|
|
|
}
|
|
|
|
|
|
function formateDateValue(dateValue) {
|
|
|
- return dateValue.replace(/-/g, '');
|
|
|
+ return dateValue.replace(/-/g, '')
|
|
|
}
|
|
|
|
|
|
function formateTimeToValue(time) {
|
|
|
- if (time === '') return 0;
|
|
|
- let hours = time.substring(0, 2);
|
|
|
- let mins = time.substring(2, 4);
|
|
|
- let hoursValue = parseInt(hours);
|
|
|
- let mintusValue = parseInt(mins) / 60;
|
|
|
- return hoursValue + mintusValue;
|
|
|
+ if (time === '') return 0
|
|
|
+ let hours = time.substring(0, 2)
|
|
|
+ let mins = time.substring(2, 4)
|
|
|
+ let hoursValue = parseInt(hours)
|
|
|
+ let mintusValue = parseInt(mins) / 60
|
|
|
+ return hoursValue + mintusValue
|
|
|
}
|
|
|
|
|
|
function formateTimeToColon(time) {
|
|
|
- let hours = time.substring(0, 2);
|
|
|
- let mins = time.substring(2, 4);
|
|
|
- return `${hours}:${mins}`;
|
|
|
+ let hours = time.substring(0, 2)
|
|
|
+ let mins = time.substring(2, 4)
|
|
|
+ return `${hours}:${mins}`
|
|
|
}
|
|
|
|
|
|
function endtimeToUnitTime(time) {
|
|
|
- let hours = time.substring(0, 2);
|
|
|
- let mins = time.substring(2, 4);
|
|
|
+ let hours = time.substring(0, 2)
|
|
|
+ let mins = time.substring(2, 4)
|
|
|
if (mins < 30) {
|
|
|
- mins = '00';
|
|
|
+ mins = '00'
|
|
|
} else {
|
|
|
- mins = '30';
|
|
|
+ mins = '30'
|
|
|
}
|
|
|
- return `${hours}${mins}00`;
|
|
|
+ return `${hours}${mins}00`
|
|
|
}
|
|
|
function startimeToUnitTime(time) {
|
|
|
- let hours = time.substring(0, 2);
|
|
|
- let mins = time.substring(2, 4);
|
|
|
+ let hours = time.substring(0, 2)
|
|
|
+ let mins = time.substring(2, 4)
|
|
|
if (mins < 30 && mins !== '00') {
|
|
|
- mins = '30';
|
|
|
+ mins = '30'
|
|
|
} else if (mins > 30) {
|
|
|
- mins = '00';
|
|
|
- hours = parseInt(hours) + 1;
|
|
|
+ mins = '00'
|
|
|
+ hours = parseInt(hours) + 1
|
|
|
hours = hours < 10 ? `0${hours}` : hours
|
|
|
} else {
|
|
|
}
|
|
|
- return `${hours}${mins}00`;
|
|
|
+ return `${hours}${mins}00`
|
|
|
}
|
|
|
|
|
|
function formateBookedList(bookedList) {
|
|
|
- let list = {};
|
|
|
+ let list = {}
|
|
|
if (!bookedList || (bookedList && bookedList.length == 0)) {
|
|
|
- return list;
|
|
|
+ return list
|
|
|
}
|
|
|
|
|
|
bookedList.forEach((item) => {
|
|
|
- let { startTime, endTime, startDate } = item;
|
|
|
- let key = startDate;
|
|
|
+ let { startTime, endTime, startDate } = item
|
|
|
+ let key = startDate
|
|
|
let data = {
|
|
|
start: formateTimeToValue(endtimeToUnitTime(startTime)),
|
|
|
end: formateTimeToValue(startimeToUnitTime(endTime)),
|
|
|
...item
|
|
|
- };
|
|
|
+ }
|
|
|
if (!list[key]) {
|
|
|
- list[key] = [data];
|
|
|
+ list[key] = [data]
|
|
|
} else {
|
|
|
- list[key].push(data);
|
|
|
+ list[key].push(data)
|
|
|
}
|
|
|
- });
|
|
|
- return list;
|
|
|
+ })
|
|
|
+ return list
|
|
|
}
|
|
|
|
|
|
function dateToDate(val) {
|
|
|
- const year = val.slice(0, 4);
|
|
|
- const month = val.slice(4, 6);
|
|
|
- const day = val.slice(6, 8);
|
|
|
- return `${year}-${month}-${day}`;
|
|
|
+ const year = val.slice(0, 4)
|
|
|
+ const month = val.slice(4, 6)
|
|
|
+ const day = val.slice(6, 8)
|
|
|
+ return `${year}-${month}-${day}`
|
|
|
}
|
|
|
|
|
|
function getWeekDay(date) {
|
|
|
- let week = date.getDay();
|
|
|
- let weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
|
- return weekday[week];
|
|
|
+ let week = date.getDay()
|
|
|
+ let weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
|
|
|
+ return weekday[week]
|
|
|
}
|
|
|
function checkSpaceControl(val) {
|
|
|
if (!val) {
|
|
@@ -191,18 +191,15 @@ function checkSpaceControl(val) {
|
|
|
title: '您没有权限!',
|
|
|
icon: 'none',
|
|
|
duration: 1500
|
|
|
- });
|
|
|
- return false;
|
|
|
+ })
|
|
|
+ return false
|
|
|
} else {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function carbonCredit(projectId) {
|
|
|
- if (projectId === 'Pj1101020007') {
|
|
|
- return '碳积分';
|
|
|
- }
|
|
|
- return '节能分';
|
|
|
+ return '碳积分'
|
|
|
}
|
|
|
|
|
|
function carbonCreditExplain(params) {
|
|
@@ -298,4 +295,4 @@ export {
|
|
|
TimeEnd,
|
|
|
TimeStart,
|
|
|
SliderUnit
|
|
|
-};
|
|
|
+}
|