| | |
| | | </van-dropdown-menu> |
| | | </div> |
| | | <span class="title">ANT-ETH</span> |
| | | <div class="right flex align-center"> |
| | | <div class="right flex align-center" @click="showAccreditModal"> |
| | | <img src="../../assets/images/icon.png" class="icon"/> |
| | | <span>{{ $t("message.ConnectWallet") }}</span> |
| | | </div> |
| | |
| | | }, |
| | | setup() { |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | // 获取地址 |
| | | let walletAddress = ref(''); |
| | | async function init() { |
| | | if(window.tronWeb){ |
| | | walletAddress = window.tronWeb.defaultAddress.base58; |
| | | }else{ |
| | | showAccreditModal() |
| | | } |
| | | } |
| | | |
| | | let isShowApproveModal = ref(false); |
| | | let isShowAccreditModal = ref(false); |
| | | let isShowWalletModal = ref(false); |
| | | let provider = reactive(new WalletConnectProvider({ |
| | | infuraId: '27e484dcd9e3efcfd25a83a78777cdf1', |
| | | bridge: "https://bridge.walletconnect.org", |
| | | })) |
| | | let web3 = new Web3(provider); |
| | | let showAccreditModal = () => { |
| | | proxy.isShowApproveModal = false |
| | | proxy.isShowAccreditModal = true |
| | | } |
| | | let showWalletModal = () => { |
| | | let provider = new WalletConnectProvider({ |
| | | infuraId: '27e484dcd9e3efcfd25a83a78777cdf1', |
| | | bridge: "https://bridge.walletconnect.org", |
| | | }) |
| | | async function showWalletModal(){ |
| | | proxy.isShowAccreditModal = false; |
| | | provider.enable(); |
| | | const accounts = await web3.eth.getAccounts(); |
| | | alert(accounts) |
| | | } |
| | | let showDappModal = () => { |
| | | proxy.isShowAccreditModal = false |
| | |
| | | } |
| | | let changeLanguage = (type) => { |
| | | proxy.$i18n.locale = type; |
| | | } |
| | | // 获取地址 |
| | | let walletAddress = ref(''); |
| | | async function init() { |
| | | if(window.tronWeb){ |
| | | walletAddress = window.tronWeb.defaultAddress.base58; |
| | | sessionStorage.setItem('address', walletAddress); |
| | | }else{ |
| | | showAccreditModal() |
| | | } |
| | | } |
| | | onMounted(() => { |
| | | init() |
| | |
| | | showDappModal, |
| | | |
| | | // 中英文切换 |
| | | changeLanguage |
| | | changeLanguage, |
| | | |
| | | walletAddress, //地址 |
| | | }; |
| | | }, |
| | | methods: { |
| | | isApprove () { |
| | | const { proxy } = getCurrentInstance(); |
| | | proxy.$axios({ |
| | | url: '/dapp/common/isApprove/' + this.walletAddress, |
| | | method: 'get' |
| | | }).then((res) => { |
| | | if(res.code === 200) { |
| | | |
| | | }else{ |
| | | this.showAccreditModal() |
| | | } |
| | | }).catch((err) => { |
| | | this.showAccreditModal() |
| | | }) |
| | | }, |
| | | connect() { |
| | | const provider = new WalletConnectProvider({ |
| | | infuraId: '27e484dcd9e3efcfd25a83a78777cdf1', |