|
@@ -59,7 +59,7 @@
|
|
|
<view class="mt-40 flex-center">
|
|
<view class="mt-40 flex-center">
|
|
|
<view
|
|
<view
|
|
|
class="flex-center height-68 br-68 fs-26 color-666"
|
|
class="flex-center height-68 br-68 fs-26 color-666"
|
|
|
- style="width: 184rpx; border: 1rpx solid rgba(0, 0, 0, 0.3)"
|
|
|
|
|
|
|
+ style="width: 184rpx; border: 1px solid rgba(0, 0, 0, 0.3)"
|
|
|
@click="cancelAppointment"
|
|
@click="cancelAppointment"
|
|
|
>取消预约</view
|
|
>取消预约</view
|
|
|
>
|
|
>
|
|
@@ -164,7 +164,9 @@
|
|
|
<style-dialog
|
|
<style-dialog
|
|
|
v-if="chargeTimeDialog"
|
|
v-if="chargeTimeDialog"
|
|
|
@close="closeTime"
|
|
@close="closeTime"
|
|
|
- title="请选择充电时间"
|
|
|
|
|
|
|
+ :title="
|
|
|
|
|
+ '请选择' + (chargeTime.isPowerSaving ? '省电模式' : '') + '充电时间'
|
|
|
|
|
+ "
|
|
|
>
|
|
>
|
|
|
<view class="flex" style="border-top: 1rpx solid rgba(0, 0, 0, 0.1)">
|
|
<view class="flex" style="border-top: 1rpx solid rgba(0, 0, 0, 0.1)">
|
|
|
<view
|
|
<view
|
|
@@ -282,13 +284,10 @@ const changeType = (index: number) => {
|
|
|
chargeType.value = index;
|
|
chargeType.value = index;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const isPassTime = (hour: string, time: number) => {
|
|
|
|
|
|
|
+const isPassTime = (hour: string, day: number) => {
|
|
|
const now = new Date();
|
|
const now = new Date();
|
|
|
- const _hour = Number(hour.substring(0, 2));
|
|
|
|
|
- if (typeof _hour !== "number") {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- return now.getHours() >= _hour && now.getDate() === Number(format("d", time));
|
|
|
|
|
|
|
+ const time = new Date(format("y/M/d", day) + " " + hour + ":00");
|
|
|
|
|
+ return now > time;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const getHourPrice = (hour: string) => {
|
|
const getHourPrice = (hour: string) => {
|
|
@@ -301,30 +300,37 @@ const getHourPrice = (hour: string) => {
|
|
|
return price;
|
|
return price;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const rebuildHours = (now: Date) => {
|
|
|
|
|
|
|
+const rebuildHours = (day: Date) => {
|
|
|
timesInfo.value.hour = [];
|
|
timesInfo.value.hour = [];
|
|
|
- let hourTemp = "";
|
|
|
|
|
- let priceTemp = "";
|
|
|
|
|
- for (let index = 0; index < 24; index++) {
|
|
|
|
|
- hourTemp = index >= 10 ? `${index}` : `0${index}`;
|
|
|
|
|
- priceTemp = getHourPrice(hourTemp);
|
|
|
|
|
- timesInfo.value.hour.push({
|
|
|
|
|
- format: `${hourTemp}:00`,
|
|
|
|
|
- formatPrice: priceTemp,
|
|
|
|
|
- disabled: isPassTime(
|
|
|
|
|
- `${hourTemp}:00`,
|
|
|
|
|
- chargeTime.value.time ? chargeTime.value.time : now.getTime()
|
|
|
|
|
- ),
|
|
|
|
|
- });
|
|
|
|
|
- timesInfo.value.hour.push({
|
|
|
|
|
- format: `${hourTemp}:30`,
|
|
|
|
|
|
|
+ const nowHour = format("h");
|
|
|
|
|
+ const isTaday = format("d") === format("d", day.getTime());
|
|
|
|
|
+ // 当前时间的24小时内
|
|
|
|
|
+ let startHour = isTaday ? Number(nowHour) : 0;
|
|
|
|
|
+ let endHour = isTaday ? 24 : Number(nowHour) + 1;
|
|
|
|
|
+ if (chargeTime.value.isPowerSaving) {
|
|
|
|
|
+ startHour = 0;
|
|
|
|
|
+ endHour = 8;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (let index = startHour; index < endHour; index++) {
|
|
|
|
|
+ timesInfo.value.hour = [...timesInfo.value.hour, ...buildHours(index, day)];
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const buildHours = (hour: number, day: Date) => {
|
|
|
|
|
+ let res: any[] = [];
|
|
|
|
|
+ let hourTemp = hour >= 10 ? `${hour}` : `0${hour}`;
|
|
|
|
|
+ let priceTemp = getHourPrice(hourTemp);
|
|
|
|
|
+ for (let index = 0; index < 12; index++) {
|
|
|
|
|
+ res.push({
|
|
|
|
|
+ format: `${hourTemp}:${index * 5 >= 10 ? index * 5 : `0${index * 5}`}`,
|
|
|
formatPrice: priceTemp,
|
|
formatPrice: priceTemp,
|
|
|
disabled: isPassTime(
|
|
disabled: isPassTime(
|
|
|
- `${hourTemp}:30`,
|
|
|
|
|
- chargeTime.value.time ? chargeTime.value.time : now.getTime()
|
|
|
|
|
|
|
+ `${hourTemp}:${index * 5 >= 10 ? index * 5 : `0${index * 5}`}`,
|
|
|
|
|
+ chargeTime.value.time ? chargeTime.value.time : day.getTime()
|
|
|
),
|
|
),
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ return res;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const selectTime = () => {
|
|
const selectTime = () => {
|
|
@@ -354,17 +360,6 @@ const selectTime = () => {
|
|
|
year: year === nextyear ? "" : nextyear.slice(2),
|
|
year: year === nextyear ? "" : nextyear.slice(2),
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
- // 时间
|
|
|
|
|
- // timesInfo.value.hour = priceInfo.value.policyInfos.map((item: any) => {
|
|
|
|
|
- // return {
|
|
|
|
|
- // format: item.startTime,
|
|
|
|
|
- // formatPrice: item.totalPrice,
|
|
|
|
|
- // disabled: isPassTime(
|
|
|
|
|
- // item.startTime,
|
|
|
|
|
- // chargeTime.value.time ? chargeTime.value.time : now.getTime()
|
|
|
|
|
- // ),
|
|
|
|
|
- // };
|
|
|
|
|
- // });
|
|
|
|
|
rebuildHours(now);
|
|
rebuildHours(now);
|
|
|
|
|
|
|
|
// 预约时间
|
|
// 预约时间
|
|
@@ -406,7 +401,9 @@ const changeDay = (index: number) => {
|
|
|
}
|
|
}
|
|
|
const now = new Date(chargeTime.value.time);
|
|
const now = new Date(chargeTime.value.time);
|
|
|
rebuildHours(now);
|
|
rebuildHours(now);
|
|
|
- chargeTime.value.scrollId = "";
|
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ chargeTime.value.scrollId = `hour-${timesInfo.value.hour[0].format}`;
|
|
|
|
|
+ }, 0);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const changeHour = (index: number) => {
|
|
const changeHour = (index: number) => {
|
|
@@ -466,6 +463,18 @@ const changeHour = (index: number) => {
|
|
|
|
|
|
|
|
const changePowerSaving = (e: any) => {
|
|
const changePowerSaving = (e: any) => {
|
|
|
chargeTime.value.isPowerSaving = e.detail.value;
|
|
chargeTime.value.isPowerSaving = e.detail.value;
|
|
|
|
|
+ chargeTime.value = {
|
|
|
|
|
+ time: 0, // 时间戳
|
|
|
|
|
+ day: "",
|
|
|
|
|
+ hour: "",
|
|
|
|
|
+ isPowerSaving: chargeTime.value.isPowerSaving, // 省电模式
|
|
|
|
|
+ format: "",
|
|
|
|
|
+ formatPrice: "",
|
|
|
|
|
+ scrollId: "",
|
|
|
|
|
+ };
|
|
|
|
|
+ if (chargeTime.value.isPowerSaving) {
|
|
|
|
|
+ selectTime();
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const closeTime = () => {
|
|
const closeTime = () => {
|
|
@@ -583,11 +592,13 @@ const submit = () => {
|
|
|
let query = "";
|
|
let query = "";
|
|
|
if (chargeType.value === 0) {
|
|
if (chargeType.value === 0) {
|
|
|
query += "isBooking=true";
|
|
query += "isBooking=true";
|
|
|
|
|
+ if (chargeTime.value.isPowerSaving && !chargeTime.value.hour) {
|
|
|
|
|
+ query += `&startTime=${format("y-M-d", startTime)} 00:00:00`;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ }
|
|
|
query += `&startTime=${format("y-M-d", startTime)} ${
|
|
query += `&startTime=${format("y-M-d", startTime)} ${
|
|
|
- chargeTime.value.isPowerSaving
|
|
|
|
|
- ? "00:00:00"
|
|
|
|
|
- : `${chargeTime.value.hour}:00`
|
|
|
|
|
- }`;
|
|
|
|
|
|
|
+ chargeTime.value.hour
|
|
|
|
|
+ }:00`;
|
|
|
if (chargeTime.value.isPowerSaving) {
|
|
if (chargeTime.value.isPowerSaving) {
|
|
|
query += `&endTime=${format("y-M-d", startTime)} 08:00:00`;
|
|
query += `&endTime=${format("y-M-d", startTime)} 08:00:00`;
|
|
|
}
|
|
}
|