123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- <template>
- <div class="page-wrapper" ref="pageWrapperDom">
- <div class="content">
- <div class="balance">
- <div class="wallet">
- <font>Balance Valuation</font>
- </div>
- </div>
- <div class="amount-wrapper">
- <div class="amount">
- <a-tooltip :title="'$'+canWithdrawBalance">
- ${{ getBit(canWithdrawBalance) }}
- </a-tooltip>
- </div>
- <div class="right">
- <div class="bill" @click="showTransactions">
- <red-dot class="red-dot" v-if="unReadCountWallet > 0"></red-dot>
- <img :src="require('@/assets/svg/icon-home-list.svg')" />
- </div>
- <img :src="require('@/assets/svg/icon-home-refresh.svg')"
- class="icon"
- :class="{ transform_rotate: iconRotate }"
- @click="refreshList" />
- </div>
- </div>
- </div>
- <currency-list
- v-if="userInfo.accessToken"
- style="height: calc(100% - 118px);"
- ref="currencyListDom"
- :showRefresh="false"
- :page="'top-up'"
- @selectCurrency="selectCurrency"></currency-list>
- </div>
- </template>
- <script setup>
- import { ref, onMounted, inject } from "vue";
- import redDot from "@/view/components/red-dot.vue";
- import CurrencyList from "@/view/components/currency-list.vue";
- import {
- getChromeStorage,
- } from "@/uilts/chromeExtension";
- import { getBalance } from "@/http/account";
- import { getAllMessageInfo } from "@/http/messageApi"
- import { setBadgeInfo, hideBadge } from "@/logic/background/twitter";
- import Report from "@/log-center/log";
- import router from "@/router/popup.js";
- import { getBit } from "@/uilts/help";
- let withdraw_info = inject('withdraw_info')
- withdraw_info.paypal = {}
- var moment = require("moment");
- let userInfo = ref({});
- let canWithdrawBalance = ref(0);
- withdraw_info.paypal.amount_value = canWithdrawBalance
- withdraw_info.balance = 0
- let isRequestWithdrawBalance = ref(false);
- let currencyListDom = ref('');
- let iconRotate = ref(false)
- // 钱包未读数
- let unReadCountWallet = ref(0);
- let walletWithdrawConfig = ref({
- withdrawUSDPaypalFee: 0,
- withdrawUSDPreMinAmount: 100,
- withdrawUSDSwitch: "",
- withdrawUSDPaypalFeeDesc: ''
- });
- withdraw_info.paypal.wallet_withdraw_config = walletWithdrawConfig
- function selectCurrency(_params) {
- router.push({
- path: 'currencyDetail',
- query: {
- params: JSON.stringify(_params)
- }
- });
- }
- onMounted(() => {
- checkLoginState((res) => {
- if (res) {
- getAccountBalance();
- Report.reportLog({
- pageSource: Report.pageSource.denetHomePage,
- businessType: Report.businessType.pageView,
- },{
- type: window.location.href.indexOf('home.html') > -1 ? 'web' : 'extensions'
- });
- setMessageCount();
- } else {
- Report.reportLog({
- pageSource: Report.pageSource.denetLogin,
- businessType: Report.businessType.pageView,
- });
- }
- });
- });
- const setMessageCount = () => {
- getAllMessageInfo({params: {
- }}).then(res => {
- if(res.code == 0) {
- let {unReadCountTotal = 0, unReadCountWalletDetail = 0, unReadCountTaskLuckdrop = 0} = res.data;
- unReadCountWallet.value = unReadCountWalletDetail;
- if(unReadCountTotal > 0) {
- let text = unReadCountTotal > 99 ? '99+' : unReadCountTotal+'';
- setBadgeInfo({data: {text}});
- } else {
- hideBadge();
- }
- }
- });
- }
- /**
- * 获取账户余额
- */
- const getAccountBalance = () => {
- isRequestWithdrawBalance.value = false;
- getBalance({}).then((res) => {
- isRequestWithdrawBalance.value = true;
- if (res.code == 0) {
- if (res.data) {
- canWithdrawBalance.value = res.data.allAssetValuationUSD;
- withdraw_info.balance = res.data.allAssetValuationUSD || 0
- }
- }
- });
- };
- const getUserInfo = (cb) => {
- getChromeStorage("userInfo", (res) => {
- cb && cb(res);
- });
- };
- /**
- * 检查登录状态
- */
- const checkLoginState = (cb) => {
- getUserInfo((res) => {
- if (res && res.accessToken) {
- userInfo.value = res;
- } else {
- userInfo.value = {};
- }
- cb && cb(res);
- });
- };
- const showTransactions = () => {
- router.push('/transactions')
- };
- // 点击提现
- const clickWithdraw = () => {
- Report.reportLog({
- pageSource: Report.pageSource.denetHomePage,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.withdrawButton
- });
- router.push('/withdraw/home');
- }
- const clickTopUp = () => {
- Report.reportLog({
- pageSource: Report.pageSource.denetHomePage,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.topupButton
- });
- router.push('/top-up/home');
- }
- const refreshList = () => {
- if (iconRotate.value) {
- return
- }
- iconRotate.value = true
- setTimeout(() => {
- iconRotate.value = false
- }, 1000)
- getAccountBalance();
- if(currencyListDom.value) {
- currencyListDom.value.getCurrencyInfoList && currencyListDom.value.getCurrencyInfoList();
- }
- }
- </script>
- <style lang="scss" scoped>
- html,
- body {
- padding: 0 !important;
- margin: 0 !important;
- }
- .page-wrapper {
- width: 375px;
- height: 100%;
- box-sizing: border-box;
- overflow-y: auto;
- .nav-bar {
- padding: 14px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .item {
- display: flex;
- align-items: center;
- font-size: 13px;
- cursor: pointer;
- img {
- width: 16px;
- height: 16px;
- margin-right: 4px;
- }
- }
- .left {
- font-weight: 500;
- }
- .right {
- color: #b6b6b6;
- }
- }
- .content {
- padding: 12px 16px 10px 16px;
- background: #1D9BF0;
- box-sizing: border-box;
- .icon-money {
- width: 70px;
- height: 70px;
- }
- .balance {
- display: flex;
- justify-content: space-between;
- .wallet {
- font {
- font-size: 13px;
- color: #fff;
- opacity: 0.7;
- }
- }
- }
- .amount-wrapper {
- margin-top: 2px;
- font-weight: 700;
- font-size: 36px;
- color: #fff;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .amount {
- display: inline-block;
- }
- .right {
- display: flex;
- align-items: center;
- .bill {
- height: 24px;
- width: 24px;
- position: relative;
- img {
- width: 24px;
- height: 24px;
- cursor: pointer;
- position: absolute;
- left: 0;
- top: 0;
- }
- .red-dot {
- position: absolute;
- right: 0px;
- top: -1px;
- z-index: 100;
- }
- }
- .icon {
- margin-left: 22px;
- cursor: pointer;
- }
- .transform_rotate {
- transform: rotate(360deg);
- transition-duration: 1s;
- }
- }
- }
- .msg {
- margin-top: 10px;
- font-size: 13px;
- color: #b6b6b6;
- }
- }
- }
- .page-wrapper::-webkit-scrollbar {
- display: none;
- }
- </style>
|