|
@@ -68,13 +68,14 @@ import { ref } from "vue";
|
|
|
import { format } from "../../utils/date";
|
|
import { format } from "../../utils/date";
|
|
|
|
|
|
|
|
let timer: any;
|
|
let timer: any;
|
|
|
|
|
+let statusTimer: any;
|
|
|
const step = ref(0);
|
|
const step = ref(0);
|
|
|
const options = ref<any>();
|
|
const options = ref<any>();
|
|
|
const status = ref({
|
|
const status = ref({
|
|
|
time: 30,
|
|
time: 30,
|
|
|
start: false,
|
|
start: false,
|
|
|
cancel: false,
|
|
cancel: false,
|
|
|
- error: false
|
|
|
|
|
|
|
+ error: false,
|
|
|
});
|
|
});
|
|
|
const chargeInfo = ref<any[]>([]);
|
|
const chargeInfo = ref<any[]>([]);
|
|
|
const startStartTimer = () => {
|
|
const startStartTimer = () => {
|
|
@@ -101,13 +102,13 @@ const startStartTimer = () => {
|
|
|
}, 1000);
|
|
}, 1000);
|
|
|
};
|
|
};
|
|
|
const startStatusTimer = () => {
|
|
const startStatusTimer = () => {
|
|
|
- setTimeout(() => {
|
|
|
|
|
|
|
+ statusTimer = setTimeout(() => {
|
|
|
fetchChargeStatus()
|
|
fetchChargeStatus()
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
if (status.value.cancel) {
|
|
if (status.value.cancel) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if ([1, 2].includes(res.StartChargeSeqStat)) {
|
|
|
|
|
|
|
+ if ([1, 2].includes(res.chargeStatus)) {
|
|
|
setChargeData(res);
|
|
setChargeData(res);
|
|
|
}
|
|
}
|
|
|
startStatusTimer();
|
|
startStatusTimer();
|
|
@@ -126,7 +127,7 @@ const start = () => {
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
- status.value.error = true
|
|
|
|
|
|
|
+ status.value.error = true;
|
|
|
timer && clearTimeout(timer);
|
|
timer && clearTimeout(timer);
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
content: `${err.errMsg}`,
|
|
content: `${err.errMsg}`,
|
|
@@ -196,9 +197,9 @@ const finish = () => {
|
|
|
});
|
|
});
|
|
|
fetchChargeStatus()
|
|
fetchChargeStatus()
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if ([1, 2].includes(res.StartChargeSeqStat)) {
|
|
|
|
|
|
|
+ if ([1, 2].includes(res.chargeStatus)) {
|
|
|
// 当前充电中
|
|
// 当前充电中
|
|
|
- const start = new Date(res.StartTime.replace(/-/g, "/"));
|
|
|
|
|
|
|
+ const start = new Date(res.startTime.replace(/-/g, "/"));
|
|
|
const end = new Date();
|
|
const end = new Date();
|
|
|
const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
|
|
const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
|
|
|
const min = parseInt(`${diff / 60}`);
|
|
const min = parseInt(`${diff / 60}`);
|
|
@@ -212,15 +213,15 @@ const finish = () => {
|
|
|
const _chargeInfo = [
|
|
const _chargeInfo = [
|
|
|
{
|
|
{
|
|
|
label: "累计充电量",
|
|
label: "累计充电量",
|
|
|
- value: `${res.TotalPower}度`,
|
|
|
|
|
|
|
+ value: `${res.totalPower}度`,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: "累计费用",
|
|
label: "累计费用",
|
|
|
- value: `${res.ElecMoney}元`,
|
|
|
|
|
|
|
+ value: `${res.elecMoney}元`,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: "开始时间",
|
|
label: "开始时间",
|
|
|
- value: res.StartTime,
|
|
|
|
|
|
|
+ value: res.startTime,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: "结束时间",
|
|
label: "结束时间",
|
|
@@ -231,19 +232,19 @@ const finish = () => {
|
|
|
value: time,
|
|
value: time,
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
- if (res.Soc) {
|
|
|
|
|
|
|
+ if (res.soc) {
|
|
|
_chargeInfo.unshift({
|
|
_chargeInfo.unshift({
|
|
|
label: "剩余电量",
|
|
label: "剩余电量",
|
|
|
- value: `${res.Soc}%`,
|
|
|
|
|
|
|
+ value: `${res.soc}%`,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
chargeInfo.value = _chargeInfo;
|
|
chargeInfo.value = _chargeInfo;
|
|
|
cancelCharge(options.value && options.value.sn ? options.value.sn : "")
|
|
cancelCharge(options.value && options.value.sn ? options.value.sn : "")
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
|
- if (res.FailReason) {
|
|
|
|
|
|
|
+ if (res.failReason) {
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
- content: res.FailReason,
|
|
|
|
|
|
|
+ content: res.failReason,
|
|
|
showCancel: false,
|
|
showCancel: false,
|
|
|
success() {
|
|
success() {
|
|
|
uni.navigateBack();
|
|
uni.navigateBack();
|
|
@@ -282,7 +283,7 @@ const finish = () => {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
const setChargeData = (res: any) => {
|
|
const setChargeData = (res: any) => {
|
|
|
- const start = new Date(res.StartTime.replace(/-/g, "/"));
|
|
|
|
|
|
|
+ const start = new Date(res.startTime.replace(/-/g, "/"));
|
|
|
const end = new Date();
|
|
const end = new Date();
|
|
|
const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
|
|
const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
|
|
|
const min = parseInt(`${diff / 60}`);
|
|
const min = parseInt(`${diff / 60}`);
|
|
@@ -295,25 +296,25 @@ const setChargeData = (res: any) => {
|
|
|
const _chargeInfo = [
|
|
const _chargeInfo = [
|
|
|
{
|
|
{
|
|
|
label: "累计充电量",
|
|
label: "累计充电量",
|
|
|
- value: `${res.TotalPower}度`,
|
|
|
|
|
|
|
+ value: `${res.totalPower}度`,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: "累计费用",
|
|
label: "累计费用",
|
|
|
- value: `${res.ElecMoney}元`,
|
|
|
|
|
|
|
+ value: `${res.elecMoney}元`,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: "开始时间",
|
|
label: "开始时间",
|
|
|
- value: res.StartTime,
|
|
|
|
|
|
|
+ value: res.startTime,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: "累计用时",
|
|
label: "累计用时",
|
|
|
value: time,
|
|
value: time,
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
- if (res.Soc) {
|
|
|
|
|
|
|
+ if (res.soc) {
|
|
|
_chargeInfo.unshift({
|
|
_chargeInfo.unshift({
|
|
|
label: "剩余电量",
|
|
label: "剩余电量",
|
|
|
- value: `${res.Soc}%`,
|
|
|
|
|
|
|
+ value: `${res.soc}%`,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
chargeInfo.value = _chargeInfo;
|
|
chargeInfo.value = _chargeInfo;
|
|
@@ -322,10 +323,10 @@ const fetchStatus = (data?: any) => {
|
|
|
if (status.value.cancel) {
|
|
if (status.value.cancel) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const promise = status ? Promise.resolve(data) : fetchChargeStatus();
|
|
|
|
|
|
|
+ const promise = data ? Promise.resolve(data) : fetchChargeStatus();
|
|
|
promise
|
|
promise
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if ([1, 2].includes(res.StartChargeSeqStat)) {
|
|
|
|
|
|
|
+ if ([1, 2].includes(res.chargeStatus)) {
|
|
|
// 当前充电中
|
|
// 当前充电中
|
|
|
status.value.start = true;
|
|
status.value.start = true;
|
|
|
step.value = 2;
|
|
step.value = 2;
|
|
@@ -343,8 +344,8 @@ const fetchStatus = (data?: any) => {
|
|
|
const onImgLoad = () => {
|
|
const onImgLoad = () => {
|
|
|
fetchChargeStatus()
|
|
fetchChargeStatus()
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if ([1, 2].includes(res.StartChargeSeqStat)) {
|
|
|
|
|
- if (options.value && options.value.sn === res.ConnectorID) {
|
|
|
|
|
|
|
+ if ([1, 2].includes(res.chargeStatus)) {
|
|
|
|
|
+ if (options.value && options.value.sn === res.connectorId) {
|
|
|
fetchStatus(res);
|
|
fetchStatus(res);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -374,6 +375,7 @@ onLoad((_options: any) => {
|
|
|
});
|
|
});
|
|
|
onHide(() => {
|
|
onHide(() => {
|
|
|
timer && clearTimeout(timer);
|
|
timer && clearTimeout(timer);
|
|
|
|
|
+ statusTimer && clearTimeout(statusTimer);
|
|
|
});
|
|
});
|
|
|
onShow(() => {
|
|
onShow(() => {
|
|
|
startStartTimer();
|
|
startStartTimer();
|