| | |
| | | <div class="box-content"> |
| | | <div class="row flex align-center justify-between"> |
| | | <span class="name">{{$t("message.TotalOutput")}}</span> |
| | | <span class="count">{{myAccountInfo.totalMine}} ETH</span> |
| | | <span class="count">{{myAccountInfo.totalMine || 0}} ETH</span> |
| | | </div> |
| | | <div class="row flex align-center justify-between"> |
| | | <span class="name">{{$t("message.IncomeBalance")}}</span> |
| | | <span class="count">{{myAccountInfo.availableWallet}} USDT</span> |
| | | <span class="count">{{myAccountInfo.availableWallet || 0}} USDT</span> |
| | | </div> |
| | | <div class="row flex align-center justify-between"> |
| | | <span class="name">{{$t("message.Exchangeable")}}</span> |
| | | <span class="count">{{myAccountInfo.availableMine}} ETH</span> |
| | | <span class="count">{{myAccountInfo.availableMine || 0}} ETH</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | <span class="all" style="color: #3D8AF2" @click="allExchange">{{$t("message.RedeemAll")}}</span> |
| | | <button class="btn" :disabled="!ethAmount" @click="submitExchange">{{$t("message.Exchange")}}</button> |
| | | <button class="btn" :disabled="!ethAmount || isRequesting" @click="submitExchange">{{$t("message.Exchange")}}</button> |
| | | <div class="tips"> |
| | | <p>{{$t("message.Price")}}:1ETH ≈ {{info.newPrice}}USDT</p> |
| | | <p>{{$t("message.Tip1")}}</p> |
| | |
| | | <span>USDT</span> |
| | | </div> |
| | | <input placeholder="0.000" type="number" v-model.number="usdtAmount"/> |
| | | <span class="all">{{$t("message.WithdrawalAmount")}}</span> |
| | | <span class="all" style="color: #3D8AF2" @click="allWithdraw">{{$t("message.WithdrawalAll")}}</span> |
| | | </div> |
| | | <div class="item flex-1 flex align-end flex-v"> |
| | | <div> |
| | | <img src="../../assets/images/icon5.png"/> |
| | | <span>USDT</span> |
| | | </div> |
| | | <span class="amount">{{myAccountInfo.availableWallet}}</span> |
| | | <span class="amount">{{myAccountInfo.availableWallet || 0}}</span> |
| | | <span class="all">{{$t("message.TotalBalance")}}</span> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </van-tab> |
| | | <van-tab :title='$t("message.Record")'> |
| | | <div class="box"> |
| | | <div class="box" style="min-height: 320px"> |
| | | <h3 class="title">{{$t("message.Record")}}</h3> |
| | | <div class="box-content"> |
| | | <div class="tab-wrap"> |
| | |
| | | <div class="list-row flex align-center justify-between" v-for="item in miningList"> |
| | | <span>{{item.createTime}}</span> |
| | | <span>{{$t("message.Mining")}}</span> |
| | | <span>{{item.amount}}</span> |
| | | <span>{{item.amount}} ETH</span> |
| | | </div> |
| | | </van-tab> |
| | | </van-tabs> |
| | |
| | | import { ref, reactive, onMounted, getCurrentInstance, defineComponent, computed} from 'vue'; |
| | | export default defineComponent({ |
| | | name: 'account', |
| | | setup() { |
| | | props: [ |
| | | 'simulateData' |
| | | ], |
| | | setup(props, context) { |
| | | console.log(props) |
| | | const activeNames = ref(['1']) |
| | | const { proxy } = getCurrentInstance(); |
| | | let exchangeList = ref([]) |
| | |
| | | let info = ref({}); |
| | | let ethAmount = ref(); |
| | | let usdtAmount = ref(); |
| | | let isRequesting = ref(false); |
| | | let ethToUsdtAmount = computed(() => { |
| | | if (!ethAmount.value || isNaN(ethAmount.value)) { |
| | | return '0.0000' |
| | | } |
| | | return (ethAmount.value * proxy.info.newPrice).toFixed(4) |
| | | }) |
| | | |
| | | function initData () { |
| | | if(props.simulateData) { |
| | | const {walletInfoVo: myAccountInfo,changes: exchangeList,withdraws: withdrawList,mines: miningList} = props.simulateData || {}; |
| | | proxy.myAccountInfo = myAccountInfo || {}; |
| | | proxy.exchangeList = exchangeList || []; |
| | | proxy.withdrawList = withdrawList || []; |
| | | proxy.miningList = miningList || []; |
| | | } else { |
| | | getWalletInfo() |
| | | getRecordList(1) |
| | | getRecordList(2) |
| | | getRecordList(3) |
| | | } |
| | | } |
| | | function getWalletInfo(){ |
| | | proxy.$axios({ |
| | | url: '/dapi/member/walletInfo', |
| | |
| | | if(res.code == 200) { |
| | | proxy.myAccountInfo = res.data; |
| | | } |
| | | }) |
| | | } |
| | | function allExchange () { |
| | | if(!proxy.myAccountInfo.availableMine) { |
| | | this.$toast(this.$t('message.NOETH')); |
| | | return; |
| | | } |
| | | ethAmount.value = proxy.myAccountInfo.availableMine |
| | | } |
| | | function submitExchange () { |
| | | if(Number(ethAmount.value) > Number(proxy.myAccountInfo.availableMine)) { |
| | | this.$toast(this.$t('message.NOETH2')); |
| | | return; |
| | | } |
| | | this.$toast.loading({ |
| | | message: this.$t('message.Submitting'), |
| | | overlay: true, |
| | | duration: 0 |
| | | }); |
| | | this.$axios({ |
| | | url: '/dapi/member/change', |
| | | method: 'post', |
| | | data: { |
| | | amount: ethAmount.value |
| | | } |
| | | }).then((res) => { |
| | | if(res.code == 200) { |
| | | ethAmount.value = ''; |
| | | this.$toast(this.$t('message.ExchangeSuc')); |
| | | getWalletInfo() |
| | | getRecordList(1) |
| | | }else{ |
| | | this.$toast(res.message); |
| | | } |
| | | this.$toast.clear(true) |
| | | }).catch(() => { |
| | | this.$toast.clear(true) |
| | | }) |
| | | } |
| | | function submitWithdraw () { |
| | | if(Number(usdtAmount.value) < 100) { |
| | | this.$toast(this.$t('message.MinWithdrawCount') + '100USDT'); |
| | | return; |
| | | } |
| | | if(Number(usdtAmount.value) > Number(proxy.myAccountInfo.availableWallet)) { |
| | | this.$toast(this.$t('message.NOETH2')); |
| | | return; |
| | | } |
| | | this.$toast.loading({ |
| | | message: this.$t('message.Submitting'), |
| | | overlay: true, |
| | | duration: 0 |
| | | }); |
| | | this.$axios({ |
| | | url: '/dapi/member/withdraw', |
| | | method: 'post', |
| | | data: { |
| | | amount: usdtAmount.value |
| | | } |
| | | }).then((res) => { |
| | | if(res.code == 200) { |
| | | usdtAmount.value = ''; |
| | | this.$toast(this.$t('message.Withdrawing2')); |
| | | getWalletInfo() |
| | | getRecordList(2) |
| | | }else{ |
| | | this.$toast(res.message); |
| | | } |
| | | this.$toast.clear(true) |
| | | }).catch(() => { |
| | | this.$toast.clear(true) |
| | | }) |
| | | } |
| | | function getRecordList (type) { |
| | |
| | | } |
| | | }) |
| | | } |
| | | function allExchange () { |
| | | if(!proxy.myAccountInfo.availableMine) { |
| | | this.$toast(this.$t('message.NOETH')); |
| | | return; |
| | | } |
| | | ethAmount.value = proxy.myAccountInfo.availableMine |
| | | } |
| | | function submitExchange () { |
| | | if(Number(ethAmount.value) > Number(proxy.myAccountInfo.availableMine)) { |
| | | this.$toast(this.$t('message.NOETH2')); |
| | | return; |
| | | } |
| | | proxy.isRequesting = true; |
| | | this.$axios({ |
| | | url: '/dapi/member/change', |
| | | method: 'post', |
| | | data: { |
| | | amount: ethAmount.value |
| | | } |
| | | }).then((res) => { |
| | | ethAmount.value = ''; |
| | | proxy.isRequesting = false; |
| | | if (res.code == 200) { |
| | | this.$toast(this.$t('message.ExchangeSuc')); |
| | | getWalletInfo() |
| | | getRecordList(1) |
| | | } else if(res.code == 401){ |
| | | this.$toast(this.$t('message.ApproveTip')); |
| | | } else { |
| | | this.$toast(res.message); |
| | | } |
| | | }).catch((err) => { |
| | | proxy.isRequesting = false; |
| | | }) |
| | | } |
| | | function allWithdraw () { |
| | | if(!proxy.myAccountInfo.availableWallet) { |
| | | return; |
| | | } |
| | | usdtAmount.value = proxy.myAccountInfo.availableWallet |
| | | } |
| | | function submitWithdraw () { |
| | | if(Number(usdtAmount.value) < 100) { |
| | | this.$toast(this.$t('message.MinWithdrawCount') + '100USDT'); |
| | | return; |
| | | } |
| | | if(Number(usdtAmount.value) > Number(proxy.myAccountInfo.availableWallet)) { |
| | | this.$toast(this.$t('message.NOETH2')); |
| | | return; |
| | | } |
| | | proxy.isRequesting = true; |
| | | this.$axios({ |
| | | url: '/dapi/member/withdraw', |
| | | method: 'post', |
| | | data: { |
| | | amount: usdtAmount.value |
| | | } |
| | | }).then((res) => { |
| | | usdtAmount.value = ''; |
| | | proxy.isRequesting = false; |
| | | if(res.code == 200) { |
| | | this.$toast(this.$t('message.Withdrawing2')); |
| | | getWalletInfo() |
| | | getRecordList(2) |
| | | } else if(res.code == 401){ |
| | | this.$toast(this.$t('message.ApproveTip')); |
| | | } else { |
| | | this.$toast(res.message); |
| | | } |
| | | }).catch(() => { |
| | | proxy.isRequesting = false; |
| | | }) |
| | | } |
| | | |
| | | function onClickTab (item) { |
| | | if(item.name === 2) { |
| | | getRecordList(1) |
| | |
| | | } |
| | | } |
| | | onMounted(() => { |
| | | getWalletInfo() |
| | | proxy.initData() |
| | | getRecordList(1) |
| | | getRecordList(2) |
| | | getRecordList(3) |
| | | proxy.initglobalSetData() |
| | | initData() |
| | | }) |
| | | return { |
| | | activeNames, |
| | |
| | | getWalletInfo, |
| | | allExchange, |
| | | submitExchange, |
| | | allWithdraw, |
| | | submitWithdraw, |
| | | onClickTab |
| | | onClickTab, |
| | | isRequesting |
| | | }; |
| | | }, |
| | | methods: { |
| | | initData () { |
| | | initglobalSetData () { |
| | | this.$axios({ |
| | | url: '/dapi/common/globalSetting', |
| | | method: 'get' |
| | |
| | | this.info = res.data; |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | } |
| | | } |
| | | }) |
| | | </script> |