| | |
| | | </div> |
| | | </div> |
| | | <div> |
| | | <div class="font-26 textColor">{{ $t('链名称') }}</div> |
| | | <div class="font-26 textColor">{{ $t("链名称") }}</div> |
| | | <div class="flex "> |
| | | <div :class="blockchainIndex == index ? 'borderMain colorMain' : 'border-solid-dark-grey border-r-grey'" |
| | | <div |
| | | :class=" |
| | | blockchainIndex == index |
| | | ? 'borderMain colorMain' |
| | | : 'border-solid-dark-grey border-r-grey' |
| | | " |
| | | class="mr-20 flex-wrap font-32 text-center name-btn rounded textColor" |
| | | v-for="(item, index) in chainList" :key="index" @click="changeBlockchain(index)">{{ |
| | | item.blockchain_name }}</div> |
| | | v-for="(item, index) in chainList" |
| | | :key="index" |
| | | @click="changeBlockchain(index)" |
| | | > |
| | | {{ item.blockchain_name }} |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- <div> |
| | |
| | | try { |
| | | await navigator.clipboard.writeText(this.address); |
| | | this.$toast(this.$t("复制成功")); |
| | | console.log('文本已复制到剪贴板'); |
| | | console.log("文本已复制到剪贴板"); |
| | | } catch (err) { |
| | | this.$toast(this.$t("复制失败")); |
| | | } |
| | | }, |
| | | async getData() { |
| | | await Axios.getBlock({ |
| | | coin: this.coin |
| | | coin: this.coin, |
| | | }).then((res) => { |
| | | if (res.code == "0") { |
| | | this.chainList = res.data.page.elements; |
| | | // this.address = res.data.page.elements[0].address; |
| | | this.blockchain_name = res.data.page.elements[0].blockchain_name; |
| | | let trc20=res.data.page.elements[3].address |
| | | let erc20=res.data.page.elements[0].address |
| | | let btc=res.data.page.elements[1].address |
| | | let eth=res.data.page.elements[2].address |
| | | if(this.symbol=='usdt'){ |
| | | this.chainList=[{ |
| | | address:trc20, |
| | | blockchain_name:'TRC20' |
| | | },{ |
| | | address:erc20, |
| | | blockchain_name:'ERC20' |
| | | }] |
| | | this.address = this.chainList[0].address; |
| | | this.blockchain_name = this.chainList[0].blockchain_name; |
| | | }else if (this.symbol=='btc'){ |
| | | // console.log(btc); |
| | | // debugger |
| | | this.chainList=[{ |
| | | address:btc, |
| | | blockchain_name:'BTC' |
| | | }] |
| | | this.address = this.chainList[0].address; |
| | | this.blockchain_name = this.chainList[0].blockchain_name; |
| | | }else if (this.symbol=='eth'){ |
| | | this.chainList=[{ |
| | | address:eth, |
| | | blockchain_name:"ETH" |
| | | }] |
| | | this.address = this.chainList[0].address; |
| | | this.blockchain_name = this.chainList[0].blockchain_name; |
| | | const { elements } = res.data.page; |
| | | // this.chainList = elements; |
| | | // 根据币种类型设置链列表和地址 |
| | | // let trc20 = res.data.page.elements.filter((item) => item.blockchain_name =="TRC20" && item.coin == "USDT").map((item) => item.address); |
| | | // 统一匹配函数 |
| | | const findChain = (blockchainName, coinName) => { |
| | | return elements.find( |
| | | (item) => |
| | | item.blockchain_name?.toUpperCase() === |
| | | blockchainName.toUpperCase() && |
| | | item.coin?.toUpperCase() === coinName.toUpperCase() |
| | | ); |
| | | }; |
| | | |
| | | // 根据币种类型设置链列表和地址 |
| | | const setChainData = (blockchainName, coinName) => { |
| | | const chain = findChain(blockchainName, coinName); |
| | | if (chain) { |
| | | this.chainList = [chain]; |
| | | this.address = chain.address; |
| | | this.blockchain_name = chain.blockchain_name; |
| | | } |
| | | }; |
| | | |
| | | switch (this.symbol.toUpperCase()) { |
| | | case "USDT": |
| | | setChainData("ERC20", "USDT"); |
| | | break; |
| | | case "BTC": |
| | | setChainData("BTC", "BTC"); |
| | | break; |
| | | case "ETH": |
| | | setChainData("ETH", "ETH"); |
| | | break; |
| | | default: |
| | | // 默认取第一个元素 |
| | | if (elements.length > 0) { |
| | | this.chainList = [elements[0]]; |
| | | this.address = elements[0].address; |
| | | this.blockchain_name = elements[0].blockchain_name; |
| | | } |
| | | } |
| | | this.getQRCode(); |
| | | } |