Procházet zdrojové kódy

transfer信息显示

龚成明 před 3 roky
rodič
revize
8f5f16d4b9
1 změnil soubory, kde provedl 63 přidání a 16 odebrání
  1. 63 16
      src/components/History.vue

+ 63 - 16
src/components/History.vue

@@ -90,7 +90,6 @@
         :search="search"
         :items-per-page="200"
         :loading="loading"
-        @click:row="changeShowBlock"
       >
         <!--        :sort-by="['ts', 'block', 'nonce']"-->
         <!--        :sort-desc="[true, true, true]"-->
@@ -134,10 +133,37 @@
             <span>{{ item.hash }}</span>
           </v-tooltip>
         </template>
-        <!-- Data -->
-        <template v-slot:item.data="{ item }">
+        <!-- tradeInfo -->
+        <template v-slot:item.tradeInfo="{ item }">
           <div @mouseenter="changeShowBlock(item, false)">
-            {{ item.data }}
+            <v-container>
+              <div v-for="trade in item.tradeInfo">
+                <v-row>
+                  <v-chip class="ma-2" label>
+                    <div v-if="trade.token.toLowerCase() == '0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85'">
+                      一个
+                    </div>
+                    <div v-else>
+                      {{ new Number(trade.amount).toLocaleString().replaceAll(',', '') }}
+                    </div>
+                  </v-chip>
+                  <v-chip color="primary" class="ma-2" label @click="jump(trade.token, 'token')">
+                    <div v-if="trade.token.toLowerCase() == '0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85'">
+                      ENS
+                    </div>
+                    <div v-else>
+                      {{ getSimpleStr2(trade.token) }}
+                    </div>
+                  </v-chip>
+                  <v-chip dark color="pink" class="ma-2" label @click="jump(trade.from)">{{ getSimpleStr2(trade.from) }}</v-chip>
+                  <v-icon>mdi-arrow-expand-right</v-icon>
+                  <v-chip dark color="teal" class="ma-2" label @click="jump(trade.to)">{{ getSimpleStr2(trade.to) }}</v-chip>
+                </v-row>
+                <v-row>
+                  <v-divider></v-divider>
+                </v-row>
+              </div>
+            </v-container>
           </div>
         </template>
         <!-- From -->
@@ -207,8 +233,6 @@
 </template>
 
 <script>
-  import axios from 'axios'
-
   export default {
     name: 'History',
 
@@ -238,14 +262,23 @@
         }
         return fmt;
       },
-      // 最后四位
+      // 获取简易str
       getSimpleStr (str) {
         if (str && str.indexOf('x') !== -1) {
           return str.substr(0, 7) + '...' + str.substr(-4)
         } else {
-          return ''
+          return str
+        }
+      },
+      // 获取简易str2
+      getSimpleStr2 (str) {
+        if (str && str.indexOf('x') !== -1 && str.length > 15) {
+          return str.substr(0, 5)
+        } else {
+          return str
         }
       },
+      // 获取数据
       async pullData () {
         let url = '/ethmev/findByHashOrBlockOrDataVague'
 
@@ -253,14 +286,24 @@
         this.loading = true
 
         const rst = await this.$http.post(url, this.query)
+        this.loading = false
 
-        this.tableData = rst.data.data
+        if (!rst.data.state) {
+          this.$msgkit.error(rst.data.msg)
 
-        // this.tableData.map(function (one) {
-        //   one.data = JSON.parse(one.data)
-        // })
+          return
+        }
 
-        this.loading = false
+        this.$msgkit.success(rst.data.msg)
+        this.tableData = rst.data.data
+
+        this.tableData.map(function (one) {
+          try {
+            one.tradeInfo = JSON.parse(one.data).tradeInfo
+          } catch (e) {
+            one.tradeInfo = []
+          }
+        })
       },
       async deleteByHash(hash_code) {
         if (confirm('要删吗?\n' + hash_code)) {
@@ -286,8 +329,12 @@
 
         return new Date(year, month - 1, day, hour, minute, second).getTime() / 1000
       },
-      jump (pairAddress) {
-        window.open('https://etherscan.io/address/' + pairAddress)
+      jump (pairAddress, type) {
+        if (type === 'token') {
+          window.open('https://etherscan.io/token/' + pairAddress)
+        } else {
+          window.open('https://etherscan.io/address/' + pairAddress)
+        }
       },
       changeShowBlock (item, openSnackbar) {
         if (openSnackbar) this.blockSnackbar = true
@@ -313,7 +360,7 @@
         { text: 'Block', value: 'block', width: '150' },
         // { text: 'Sender', value: 'fm' },
         { text: 'Hash', value: 'hash' },
-        { text: 'Data', value: 'data', width: '800' },
+        { text: 'TradeInfo', value: 'tradeInfo', width: '800' },
         // { text: '交易数量', value: 'amount' },
         // { text: '利润', value: 'profit' },
         // { text: 'Gas', value: 'gas' },