|
@@ -118,7 +118,10 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="mt-20 block flex-align-center pl-30 pr-30 pt-30 pb-30" v-if="chargeType === 0">
|
|
|
|
|
|
|
+ <view
|
|
|
|
|
+ class="mt-20 block flex-align-center pl-30 pr-30 pt-30 pb-30"
|
|
|
|
|
+ v-if="chargeType === 0"
|
|
|
|
|
+ >
|
|
|
<view class="flex-column">
|
|
<view class="flex-column">
|
|
|
<view class="fs-28 lh-28 color-000 fw-500">省钱模式</view>
|
|
<view class="fs-28 lh-28 color-000 fw-500">省钱模式</view>
|
|
|
<view class="fs-24 lh-30 color-999 mt-8"
|
|
<view class="fs-24 lh-30 color-999 mt-8"
|
|
@@ -191,8 +194,14 @@
|
|
|
>
|
|
>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="flex-grow" style="height: 840rpx; overflow-y: auto">
|
|
|
|
|
|
|
+ <scroll-view
|
|
|
|
|
+ scroll-y
|
|
|
|
|
+ class="flex-grow"
|
|
|
|
|
+ style="height: 840rpx"
|
|
|
|
|
+ :scroll-into-view="chargeTime.scrollId"
|
|
|
|
|
+ >
|
|
|
<view
|
|
<view
|
|
|
|
|
+ :id="`hour-${hour.format}`"
|
|
|
class="flex-align-center pl-40 height-90 fs-32"
|
|
class="flex-align-center pl-40 height-90 fs-32"
|
|
|
v-for="(hour, index) in timesInfo.hour"
|
|
v-for="(hour, index) in timesInfo.hour"
|
|
|
:key="index"
|
|
:key="index"
|
|
@@ -207,7 +216,7 @@
|
|
|
>
|
|
>
|
|
|
{{ hour.format }}
|
|
{{ hour.format }}
|
|
|
</view>
|
|
</view>
|
|
|
- </view>
|
|
|
|
|
|
|
+ </scroll-view>
|
|
|
</view>
|
|
</view>
|
|
|
</style-dialog>
|
|
</style-dialog>
|
|
|
<PriceDesc
|
|
<PriceDesc
|
|
@@ -246,7 +255,7 @@ const timesInfo = ref<any>({
|
|
|
const chargeType = ref(1);
|
|
const chargeType = ref(1);
|
|
|
const chargeTypes = ref([
|
|
const chargeTypes = ref([
|
|
|
{
|
|
{
|
|
|
- title: "预约省钱充电",
|
|
|
|
|
|
|
+ title: "预约充电",
|
|
|
tip: "预约特定时间点开始充电",
|
|
tip: "预约特定时间点开始充电",
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -255,12 +264,13 @@ const chargeTypes = ref([
|
|
|
]);
|
|
]);
|
|
|
const chargeTimeDialog = ref(false);
|
|
const chargeTimeDialog = ref(false);
|
|
|
const chargeTime = ref({
|
|
const chargeTime = ref({
|
|
|
- isPowerSaving: false, // 省电模式
|
|
|
|
|
time: 0, // 时间戳
|
|
time: 0, // 时间戳
|
|
|
day: "",
|
|
day: "",
|
|
|
hour: "",
|
|
hour: "",
|
|
|
format: "",
|
|
format: "",
|
|
|
formatPrice: "",
|
|
formatPrice: "",
|
|
|
|
|
+ scrollId: "",
|
|
|
|
|
+ isPowerSaving: false, // 省电模式
|
|
|
});
|
|
});
|
|
|
const appointmentData = ref();
|
|
const appointmentData = ref();
|
|
|
const appointmentCountDown = ref();
|
|
const appointmentCountDown = ref();
|
|
@@ -278,6 +288,42 @@ const isPassTime = (hour: string, time: number) => {
|
|
|
return now.getHours() >= _hour && now.getDate() === Number(format("d", time));
|
|
return now.getHours() >= _hour && now.getDate() === Number(format("d", time));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const getHourPrice = (hour: string) => {
|
|
|
|
|
+ let price = "";
|
|
|
|
|
+ priceInfo.value.policyInfos.forEach((item: any) => {
|
|
|
|
|
+ if (Number(hour) >= Number(item.startTime.substring(0, 2))) {
|
|
|
|
|
+ price = item.totalPrice;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return price;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const rebuildHours = (now: Date) => {
|
|
|
|
|
+ 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`,
|
|
|
|
|
+ formatPrice: priceTemp,
|
|
|
|
|
+ disabled: isPassTime(
|
|
|
|
|
+ `${hourTemp}:30`,
|
|
|
|
|
+ chargeTime.value.time ? chargeTime.value.time : now.getTime()
|
|
|
|
|
+ ),
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const selectTime = () => {
|
|
const selectTime = () => {
|
|
|
if (!appointmentData.value && chargeType.value === 1) {
|
|
if (!appointmentData.value && chargeType.value === 1) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -306,21 +352,31 @@ const selectTime = () => {
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
// 时间
|
|
// 时间
|
|
|
- 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()
|
|
|
|
|
- ),
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // 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);
|
|
|
|
|
|
|
|
// 预约时间
|
|
// 预约时间
|
|
|
- if (!appointmentData.value && !chargeTime.value.day) {
|
|
|
|
|
- chargeTime.value.time = timesInfo.value.day[0].time;
|
|
|
|
|
- chargeTime.value.day = timesInfo.value.day[0].format;
|
|
|
|
|
|
|
+ if (!appointmentData.value) {
|
|
|
|
|
+ if (!chargeTime.value.day) {
|
|
|
|
|
+ chargeTime.value.time = timesInfo.value.day[0].time;
|
|
|
|
|
+ chargeTime.value.day = timesInfo.value.day[0].format;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 滚动到特定位置
|
|
|
|
|
+ if (chargeTime.value.hour) {
|
|
|
|
|
+ chargeTime.value.scrollId = `hour-${chargeTime.value.hour}`;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let hourNow = now.getHours();
|
|
|
|
|
+ chargeTime.value.scrollId = `hour-${hourNow}:00`;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// 修改时间
|
|
// 修改时间
|
|
|
if (appointmentData.value) {
|
|
if (appointmentData.value) {
|
|
@@ -345,13 +401,9 @@ const changeDay = (index: number) => {
|
|
|
chargeTime.value.hour = "";
|
|
chargeTime.value.hour = "";
|
|
|
chargeTime.value.formatPrice = "";
|
|
chargeTime.value.formatPrice = "";
|
|
|
}
|
|
}
|
|
|
- timesInfo.value.hour = priceInfo.value.policyInfos.map((item: any) => {
|
|
|
|
|
- return {
|
|
|
|
|
- format: item.startTime,
|
|
|
|
|
- formatPrice: item.totalPrice,
|
|
|
|
|
- disabled: isPassTime(item.startTime, chargeTime.value.time),
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const now = new Date(chargeTime.value.time);
|
|
|
|
|
+ rebuildHours(now);
|
|
|
|
|
+ chargeTime.value.scrollId = "";
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const changeHour = (index: number) => {
|
|
const changeHour = (index: number) => {
|
|
@@ -426,6 +478,7 @@ const closeTime = () => {
|
|
|
isPowerSaving: chargeTime.value.isPowerSaving, // 省电模式
|
|
isPowerSaving: chargeTime.value.isPowerSaving, // 省电模式
|
|
|
format: "",
|
|
format: "",
|
|
|
formatPrice: "",
|
|
formatPrice: "",
|
|
|
|
|
+ scrollId: "",
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -528,7 +581,7 @@ const submit = () => {
|
|
|
if (chargeType.value === 0) {
|
|
if (chargeType.value === 0) {
|
|
|
query += "isBooking=true";
|
|
query += "isBooking=true";
|
|
|
query += `&startTime=${format("y-M-d", startTime)} ${
|
|
query += `&startTime=${format("y-M-d", startTime)} ${
|
|
|
- chargeTime.value.isPowerSaving ? "00:00:00" : chargeTime.value.hour
|
|
|
|
|
|
|
+ chargeTime.value.isPowerSaving ? "00:00: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`;
|
|
@@ -569,6 +622,10 @@ const submit = () => {
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ content: `${err.errMsg}`,
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -585,6 +642,13 @@ const submitNow = () => {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
url: `/pages-charge/ordering/ordering?sn=${options.value.sn}&start=1`,
|
|
url: `/pages-charge/ordering/ordering?sn=${options.value.sn}&start=1`,
|
|
|
});
|
|
});
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ content: `${err.errMsg}`,
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|