|
@@ -273,7 +273,7 @@ import { ref } from "vue";
|
|
|
import ChargeMachine from "../machines/charge-machine/charge-machine.vue";
|
|
import ChargeMachine from "../machines/charge-machine/charge-machine.vue";
|
|
|
import PriceDesc from "../machines/price-desc/price-desc.vue";
|
|
import PriceDesc from "../machines/price-desc/price-desc.vue";
|
|
|
import { format } from "@/utils/date";
|
|
import { format } from "@/utils/date";
|
|
|
-import { to, reLaunch } from "../../utils/navigate";
|
|
|
|
|
|
|
+import { to } from "../../utils/navigate";
|
|
|
|
|
|
|
|
const DAY = 24 * 60 * 60 * 1000;
|
|
const DAY = 24 * 60 * 60 * 1000;
|
|
|
const options = ref<any>();
|
|
const options = ref<any>();
|
|
@@ -470,7 +470,7 @@ const changeHour = (index: number) => {
|
|
|
})
|
|
})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
|
- if (res && [0].includes(res.chargeStatus)) {
|
|
|
|
|
|
|
+ if (res && res.isAppointment) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon: "success",
|
|
icon: "success",
|
|
|
title: "修改成功",
|
|
title: "修改成功",
|
|
@@ -578,9 +578,21 @@ const startAppointmentCountDown = () => {
|
|
|
appointmentCountDown.value = formatAppointmentCountDown(
|
|
appointmentCountDown.value = formatAppointmentCountDown(
|
|
|
appointmentData.value.startTime
|
|
appointmentData.value.startTime
|
|
|
);
|
|
);
|
|
|
- appointmentCountDownTimer = setTimeout(() => {
|
|
|
|
|
- startAppointmentCountDown();
|
|
|
|
|
- }, 1000);
|
|
|
|
|
|
|
+ if (appointmentCountDown.value) {
|
|
|
|
|
+ appointmentCountDownTimer = setTimeout(() => {
|
|
|
|
|
+ startAppointmentCountDown();
|
|
|
|
|
+ }, 1000);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ content: "当前预约时间已到,将开始进行充电",
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ success() {
|
|
|
|
|
+ uni.switchTab({
|
|
|
|
|
+ url: "/pages/map/map",
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const formatAppointmentCountDown = (time: string) => {
|
|
const formatAppointmentCountDown = (time: string) => {
|
|
@@ -588,14 +600,7 @@ const formatAppointmentCountDown = (time: string) => {
|
|
|
const date = new Date(time.replace(/-/g, "/"));
|
|
const date = new Date(time.replace(/-/g, "/"));
|
|
|
let secondTime = parseInt(`${(date.getTime() - now.getTime()) / 1000}`);
|
|
let secondTime = parseInt(`${(date.getTime() - now.getTime()) / 1000}`);
|
|
|
if (secondTime <= 0) {
|
|
if (secondTime <= 0) {
|
|
|
- uni.showModal({
|
|
|
|
|
- content: "当前预约时间已到,将开始进行充电",
|
|
|
|
|
- showCancel: false,
|
|
|
|
|
- success() {
|
|
|
|
|
- reLaunch();
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ return "";
|
|
|
}
|
|
}
|
|
|
let hourTime = 0;
|
|
let hourTime = 0;
|
|
|
let minuteTime = 0; // 分
|
|
let minuteTime = 0; // 分
|
|
@@ -661,7 +666,7 @@ const submit = () => {
|
|
|
if (chargeType.value === 0) {
|
|
if (chargeType.value === 0) {
|
|
|
fetchChargeStatus()
|
|
fetchChargeStatus()
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if (res && [0].includes(res.chargeStatus)) {
|
|
|
|
|
|
|
+ if (res && res.isAppointment) {
|
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon: "success",
|
|
icon: "success",
|
|
@@ -697,9 +702,7 @@ const submitNow = () => {
|
|
|
});
|
|
});
|
|
|
startAppointmentCharge(options.value.sn)
|
|
startAppointmentCharge(options.value.sn)
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: `/pages-charge/ordering/ordering?sn=${options.value.sn}&start=1`,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ _checkStartCharge();
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
@@ -710,6 +713,19 @@ const submitNow = () => {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const _checkStartCharge = () => {
|
|
|
|
|
+ fetchChargeStatus().then((res) => {
|
|
|
|
|
+ if (res && [2].includes(res.chargeStatus)) {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `/pages-charge/ordering/ordering?sn=${options.value.sn}&start=1`,
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ _checkStartCharge();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
onLoad((_options: any) => {
|
|
onLoad((_options: any) => {
|
|
|
// sn=SN100523042860091 测试环境
|
|
// sn=SN100523042860091 测试环境
|
|
|
console.log("options", _options);
|
|
console.log("options", _options);
|
|
@@ -739,7 +755,7 @@ onLoad((_options: any) => {
|
|
|
return fetchChargeStatus(false, true);
|
|
return fetchChargeStatus(false, true);
|
|
|
})
|
|
})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if (res && [0].includes(res.chargeStatus)) {
|
|
|
|
|
|
|
+ if (res && res.isAppointment) {
|
|
|
appointmentData.value = res;
|
|
appointmentData.value = res;
|
|
|
startAppointmentCountDown();
|
|
startAppointmentCountDown();
|
|
|
}
|
|
}
|