vbea 1 жил өмнө
parent
commit
bf88cdcb88

+ 54 - 35
WebApp-Lite/pages/charge/index.vue

@@ -8,7 +8,8 @@
     <header-view
     <header-view
       title="Insert Charging Cable"
       title="Insert Charging Cable"
       :status="connectorInfo.status"
       :status="connectorInfo.status"
-      :isLoading="isLoading"/>
+      :isLoading="isLoading"
+      :password="password"/>
     <info-view
     <info-view
       :info="connectorInfo"
       :info="connectorInfo"
       :isLoading="isLoading"/>
       :isLoading="isLoading"/>
@@ -28,29 +29,43 @@
         class="ui-button margin0"
         class="ui-button margin0"
         type="primary"
         type="primary"
         @click="stopCharge">INPUT PIN TO STOP CHARGING</button>
         @click="stopCharge">INPUT PIN TO STOP CHARGING</button>
-      <button
-        v-else-if="connectorInfo.status == 'Finishing'"
-        class="ui-button margin0"
-        type="primary"
-        disabled>STOP CHARGING</button>
-      <template v-else-if="connectorInfo.status == 'Preparing'">
+      <view class="flexc" v-else-if="connectorInfo.status == 'Finishing'">
         <button
         <button
-          class="ui-button margin0"
+          class="ui-button margin0 flex3"
           type="primary"
           type="primary"
-          @click="onStart"
-          v-if="connectorInfo.paymentStatus == 'PAID'">START CHARGING</button>
+          :disabled="!chargingPk"
+          @click="toReceipt">VIEW RECEIPT</button>
+        <divide :size="24"/>
         <button
         <button
-          class="ui-button margin0"
-          type="primary"
-          @click="onPayment"
-          v-else>
-          <view class="flexcc">
-            <text>MAKE PAYMENT</text>
-            <view class="icon-key" v-if="password.length == 0">
-              <i-icon name="key-fill" size="32rpx" color="#333"/>
+          class="ui-button margin0 flex1"
+          type="accent"
+          @click="goBack">EXIT</button>
+      </view>
+      <template v-else-if="connectorInfo.status == 'Preparing'">
+        <template v-if="password">
+          <button
+            class="ui-button margin0"
+            type="primary"
+            @click="onStart"
+            v-if="connectorInfo.paymentStatus == 'PAID'">START CHARGING</button>
+          <button
+            class="ui-button margin0"
+            type="primary"
+            @click="onPayment"
+            v-else>
+            <view class="flexcc">
+              <text>MAKE PAYMENT</text>
+              <view class="icon-key" v-if="false">
+                <i-icon name="key-fill" size="32rpx" color="#333"/>
+              </view>
             </view>
             </view>
-          </view>
-        </button>
+          </button>
+        </template>
+        <button
+          v-else
+          class="ui-button margin0"
+          type="accent"
+          @click="showPinPage">INPUT PIN</button>
       </template>
       </template>
       <button
       <button
         v-else-if="connectorInfo.status == 'Available' && isLoading"
         v-else-if="connectorInfo.status == 'Available' && isLoading"
@@ -65,7 +80,7 @@
         :disabled="connectorInfo.status != 'Available' || isLoading">
         :disabled="connectorInfo.status != 'Available' || isLoading">
         <view class="flexcc">
         <view class="flexcc">
           <text>AUTHENTICATE</text>
           <text>AUTHENTICATE</text>
-          <view class="icon-key" v-if="password.length == 0">
+          <view class="icon-key" v-if="false">
             <i-icon name="key-fill" size="32rpx" color="#333"/>
             <i-icon name="key-fill" size="32rpx" color="#333"/>
           </view>
           </view>
         </view>
         </view>
@@ -136,6 +151,11 @@ export default {
     this.refreshStatus(500);
     this.refreshStatus(500);
   },
   },
   methods: {
   methods: {
+    goBack() {
+      uni.redirectTo({
+        url: "/pages/index/index"
+      })
+    },
     refreshStatus(time=2000) {
     refreshStatus(time=2000) {
       this.refreshId += 1;
       this.refreshId += 1;
       setTimeout(() => {
       setTimeout(() => {
@@ -166,7 +186,7 @@ export default {
           showCancel: false,
           showCancel: false,
           success: res => {
           success: res => {
             if (res.confirm) {
             if (res.confirm) {
-              uni.navigateBack();
+              this.goBack();
             }
             }
           }
           }
         })
         })
@@ -204,7 +224,7 @@ export default {
           showCancel: false,
           showCancel: false,
           success: res => {
           success: res => {
             if (res.confirm) {
             if (res.confirm) {
-              uni.navigateBack();
+              this.goBack();
             }
             }
           }
           }
         })
         })
@@ -213,7 +233,7 @@ export default {
       })
       })
     },
     },
     showPageWithStatus() {
     showPageWithStatus() {
-      //this.connectorInfo.status = "Available"
+      //this.connectorInfo.status = "Charging"
       switch (this.connectorInfo.status) {
       switch (this.connectorInfo.status) {
         case "Available":
         case "Available":
           if (this.isLoading) {
           if (this.isLoading) {
@@ -248,10 +268,9 @@ export default {
         case "Finishing":
         case "Finishing":
           if (this.connectorInfo.chargingPk) {
           if (this.connectorInfo.chargingPk) {
             this.chargingPk = this.connectorInfo.chargingPk;
             this.chargingPk = this.connectorInfo.chargingPk;
-            this.toReceipt();
+            //this.toReceipt();
           } else {
           } else {
             this.refreshStatus(5000);
             this.refreshStatus(5000);
-            //uni.navigateBack();
           }
           }
           break;
           break;
         default:
         default:
@@ -268,7 +287,7 @@ export default {
         this.onStop();
         this.onStop();
       } else {
       } else {
         this.showPin = false;
         this.showPin = false;
-        this.onAuthentic();
+        //this.onAuthentic();
       }
       }
     },
     },
     refreshPayment() {
     refreshPayment() {
@@ -278,12 +297,11 @@ export default {
       this.getChargingStatus();
       this.getChargingStatus();
     },
     },
     onAuthentic() {
     onAuthentic() {
-      if (this.password) {
-        this.isLoading = true;
-        this.refreshStatus();
-      } else {
-        this.showPin = true;
-      }
+      this.isLoading = true;
+      this.refreshStatus();
+    },
+    showPinPage() {
+      this.showPin = true;
     },
     },
     cancelAuth() {
     cancelAuth() {
       this.isLoading = false;
       this.isLoading = false;
@@ -376,8 +394,9 @@ export default {
         auth.setPaymentId("");
         auth.setPaymentId("");
         if (res.data.chargingPk) {
         if (res.data.chargingPk) {
           uni.hideLoading();
           uni.hideLoading();
-          this.chargingPk = res.data.chargingPk
-          this.toReceipt();
+          this.connectorInfo.status = "Finishing";
+          this.chargingPk = res.data.chargingPk;
+          //this.toReceipt();
         } else {
         } else {
           uni.showToast({
           uni.showToast({
             icon: "none",
             icon: "none",