Kaynağa Gözat

[edit] refresh currency

wenliming 2 yıl önce
ebeveyn
işleme
abccd5a392
2 değiştirilmiş dosya ile 25 ekleme ve 23 silme
  1. 8 0
      src/http/publishApi.js
  2. 17 23
      src/view/popup/currency-detail.vue

+ 8 - 0
src/http/publishApi.js

@@ -75,6 +75,14 @@ export function searchCurrencyInfo(params) {
   })
 }
 
+export function getCurrencyInfoBySymbol(params) {
+  return service({
+    url: `/currency/v2/getCurrencyInfoBySymbol`,
+    method: 'post',
+    data: params
+  })
+}
+
 export function syncChainTokenRechargeRecord(params) {
   return service({
     url: `/wallet/recharge/syncChainTokenRechargeRecord`,

+ 17 - 23
src/view/popup/currency-detail.vue

@@ -2,7 +2,7 @@
   <div class="currency-detail-page">
     <v-head :title="currencyInfo.tokenSymbol" 
             :show_more="false"
-            :show_refresh="false"
+            :show_refresh="true"
             :show_list="true"
             :transactionsRouterParams="{
               backUrl: 'back'
@@ -58,7 +58,7 @@ import router from "@/router/popup.js";
 import Report from "@/log-center/log";
 import { getStorage } from "@/uilts/help";
 
-import { syncChainTokenRechargeRecord } from "@/http/publishApi";
+import { getCurrencyInfoBySymbol } from "@/http/publishApi";
 
 import VHead from '@/view/popup/components/head.vue'
 import currencySelect from "@/view/components/currency-select.vue";
@@ -154,30 +154,24 @@ const depositHandle = (_params) => {
 };
 
 const onRefresh = () => {
-    asyncTokenRechRecord(currencyInfo.value, (res) => {
-      if(res.code == 0 && res.data && res.data.length) {
-          let currencyData = res.data[0];
-          if(currencyData.currencyCode == currencyInfo.value.currencyCode) {
-            currencyInfo.value.balance = currencyData.balance;
-            currencyInfo.value.usdEstimateBalance = currencyData.usdEstimateBalance;
-          }
+  getCurrencyInfoBySymbol({
+    params: {
+      symbol: currencyInfo.value.tokenSymbol
+    }
+  }).then(res => {
+    if(res.code == 0) {
+      if(res.data && res.data.currencyCategories && res.data.currencyCategories.length) {
+        let data = res.data.currencyCategories[0].data;
+        if(data.length) {
+          let {totalBalance = '', totalUsdEstimateBalance = ''} = data[0] || {};
+          currencyInfo.value.totalBalance = totalBalance;
+          currencyInfo.value.totalUsdEstimateBalance = totalUsdEstimateBalance;
+        }
       }
-    })
+    }
+  })
 };
 
-
-const asyncTokenRechRecord = (_params, cb) => {
-    let { currencyCode = '' } = _params;
-    if(!currencyCode || currenciesData.value.length > 1) return;
-    syncChainTokenRechargeRecord({
-        params: {
-            currencyCode: currencyCode
-        }
-    }).then(res => {
-        cb && cb(res)
-    })
-}
-
 onMounted(() => {
     let {params = '{}'} = router.currentRoute.value.query;