|
@@ -0,0 +1,70 @@
|
|
|
|
|
+import apiCharge from "../../api/apiCharge";
|
|
|
|
|
+import Dialog from "../../components/Dialog";
|
|
|
|
|
+import { PageList } from "../Router";
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ haveResult() {
|
|
|
|
|
+ return global.QrCodeResult && global.QrCodeResult.connectorPk;
|
|
|
|
|
+ },
|
|
|
|
|
+ setResult(info) {
|
|
|
|
|
+ global.QrCodeResult = info;
|
|
|
|
|
+ },
|
|
|
|
|
+ getResult() {
|
|
|
|
|
+ return global.QrCodeResult;
|
|
|
|
|
+ },
|
|
|
|
|
+ clearResult() {
|
|
|
|
|
+ global.QrCodeResult = {};
|
|
|
|
|
+ },
|
|
|
|
|
+ applyInputStation(text, sitePk, back) {
|
|
|
|
|
+ if (text.indexOf('-') > 0) {
|
|
|
|
|
+ const arr = text.split('-');
|
|
|
|
|
+ if (arr.length >= 2) {
|
|
|
|
|
+ let bid = '', cid = '';
|
|
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
|
|
+ let sb = arr[i]?.trim();
|
|
|
|
|
+ if (i == (arr.length-1)) {
|
|
|
|
|
+ cid = sb;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (i > 0) {
|
|
|
|
|
+ bid += '-';
|
|
|
|
|
+ }
|
|
|
|
|
+ bid += sb;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ const qr = {
|
|
|
|
|
+ sitePk: sitePk,
|
|
|
|
|
+ chargeBoxId: bid,
|
|
|
|
|
+ connectorId: cid
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('====================================');
|
|
|
|
|
+ console.log(qr);
|
|
|
|
|
+ console.log('====================================');
|
|
|
|
|
+ Dialog.showProgressDialog();
|
|
|
|
|
+ apiCharge.checkQRStatus(qr).then(res => {
|
|
|
|
|
+ Dialog.dismissLoading();
|
|
|
|
|
+ if (res.data && res.data.chargeBoxId) {
|
|
|
|
|
+ this.setResult(res.data);
|
|
|
|
|
+ back(true)
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(({err, code}) => {
|
|
|
|
|
+ Dialog.dismissLoading();
|
|
|
|
|
+ back(false, '')
|
|
|
|
|
+ Dialog.showDialog({
|
|
|
|
|
+ title: 'Error',
|
|
|
|
|
+ message: err,
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ callback: btn => {
|
|
|
|
|
+ if (code == 5194 && btn == Dialog.BUTTON_OK) {
|
|
|
|
|
+ startPage(PageList.myVehicles);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ back(false, 'Station ID is incorrect');
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ back(false, 'Station ID is incorrect');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|