wkw 2 日 前
コミット
5a71ea27be
2 ファイル変更51 行追加5 行削除
  1. 2 0
      src/i18n/zhHk/wallet.js
  2. 49 5
      src/views/wallet/ybExchange/index.vue

+ 2 - 0
src/i18n/zhHk/wallet.js

@@ -66,4 +66,6 @@ export default {
     SigningTransaction: "正在簽名交易...",
     TransactionIsBeingSent: "正在發送交易...",
     WaitingForTransactionConfirmation: "正在等待交易確認...",
+    ExchangeSuccessful:"兌換成功",
+    ExchangeFailed:"兌換失敗"
 };

+ 49 - 5
src/views/wallet/ybExchange/index.vue

@@ -58,6 +58,16 @@
                 </div>
             </div>
         </van-popup>
+        <van-overlay :show="percentageShow">
+            <div class="progress-text">
+                <span>{{ pivotText }}</span>
+            </div>
+            <van-progress
+                class="progress"
+                stroke-width="8"
+                :percentage="percentage"
+            />
+        </van-overlay>
     </div>
 </template>
 
@@ -76,6 +86,12 @@ const selectIndex = ref(1);//1:wgt-元宝   2:元宝-wgt
 let WGTbalance = walletStore.tokenList[2].balance;
 const loading = ref(false);
 const isDisabled = ref(false);
+
+const percentageShow = ref(false);
+const percentage = ref(0);
+const pivotText = ref("Logging in...");
+
+
 const changePop = (i) => {
     selectIndex.value = i;
     text.value = '';
@@ -119,7 +135,12 @@ const confirm = () => {
         showToast($t('wallet.TheInputQuantityCannotExceedTheAvailableQuantity'));
 	    return;
 	}
+    show.value  = false;
     isDisabled.value = true;
+    percentageShow.value = true;
+    setTimeout(() => {
+        percentage.value = 30;
+    }, 1000);
     const { ciphertext, iv } = AES_CBC_ENCRYPT(walletStore.privateKey);
     let params = {
         address: walletStore.account,
@@ -133,13 +154,24 @@ const confirm = () => {
 
 }
 const getwgt2sycee = async (params) => {
+    setTimeout(() => {
+        percentage.value = 70;
+    }, 1500);
     let res = ''
-    if(selectIndex.value == 1){
-        res = await wgt2sycee(params).finally(() => {isDisabled.value = false});
-    }else{
-        res = await sycee2wgt(params).finally(() => {isDisabled.value = false});
+    try {
+        if (selectIndex.value == 1) {
+            res = await wgt2sycee(params);
+        } else {
+            res = await sycee2wgt(params);
+        }
+        showToast($t('wallet.ExchangeSuccessful'))
+    } catch (error) {
+        showToast($t('wallet.ExchangeFailed'))
+    } finally {
+        isDisabled.value = false;
+        percentage.value = 100;
+        percentageShow.value = false;
     }
-    show.value  = false;
 }
 const onRefresh = () => {
     setTimeout(() => {
@@ -341,4 +373,16 @@ height: 100%;
         width: auto !important;
     }
 }
+.progress {
+  width: 80vw;
+  margin: 0 auto;
+}
+.progress-text {
+  width: 100vw;
+  margin-top: 45vh;
+  margin-bottom: 30px;
+  display: flex;
+  justify-content: center;
+  color: #fff;
+}
 </style>