From e9f52e30017ead0876fa87983aa7d74163308bb8 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 16 Aug 2021 17:02:28 +0800 Subject: [PATCH] add account page --- package.json | 1 + src/layouts/components/Navbar.vue | 4 +- src/libs/data/data.js | 14 + src/libs/fetch.js | 29 +- src/main.js | 1 + src/router/index.js | 20 +- src/views/ChartjsComponentDoughnutChart.vue | 21 + src/views/UserAccountDetail.vue | 506 ++++++++++++++++++++ src/views/UserAccounts.vue | 10 +- yarn.lock | 5 + 10 files changed, 600 insertions(+), 11 deletions(-) create mode 100644 src/views/ChartjsComponentDoughnutChart.vue create mode 100644 src/views/UserAccountDetail.vue diff --git a/package.json b/package.json index 66dc4695..403f09ec 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "vue-loader": "^15.9.6", "vue-perfect-scrollbar": "0.2.1", "vue-prism-component": "1.1.1", + "vue-qr": "^2.5.0", "vue-ripple-directive": "2.0.1", "vue-router": "3.4.9", "vue-select": "3.11.2", diff --git a/src/layouts/components/Navbar.vue b/src/layouts/components/Navbar.vue index c703c8de..3c188cf4 100644 --- a/src/layouts/components/Navbar.vue +++ b/src/layouts/components/Navbar.vue @@ -79,13 +79,13 @@ - + x.operator_address === addr) + if (val) { + return val.description.moniker + } + } + if (length > 0) { + return addr.substring(addr.length - length) + } + return addr +} + export * from 'compare-versions' export class Data { diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 20b30821..79b15390 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -194,10 +194,35 @@ const chainAPI = class ChainFetch { return ret } - static async getAuthAccount(baseurl, address) { - return ChainFetch.fetch(baseurl, '/auth/accounts/'.concat(address)).then(data => commonProcess(data)) + async getAuthAccount(address) { + return this.get('/auth/accounts/'.concat(address)).then(data => commonProcess(data)) } + async getBankAccountBalance(address) { + return this.get('/bank/balances/'.concat(address)).then(data => commonProcess(data)) + } + + async getStakingReward(address) { + return this.get(`/cosmos/distribution/v1beta1/delegators/${address}/rewards`).then(data => commonProcess(data)) + } + + async getStakingValidators(address) { + return this.get(`/cosmos/distribution/v1beta1/delegators/${address}/validators`).then(data => commonProcess(data)) + } + + async getStakingDelegations(address) { + return this.get(`/cosmos/staking/v1beta1/delegations/${address}`).then(data => commonProcess(data)) + } + + async getStakingRedelegations(address) { + return this.get(`/cosmos/staking/v1beta1/delegators/${address}/redelegations`).then(data => commonProcess(data)) + } + + async getStakingUnbonding(address) { + return this.get(`/cosmos/staking/v1beta1/delegators/${address}/unbonding_delegations`).then(data => commonProcess(data)) + } + // /cosmos/staking/v1beta1/delegations/{delegator_addr} + static async getBankBalance(baseurl, address) { return ChainFetch.fetch(baseurl, '/bank/balances/'.concat(address)).then(data => commonProcess(data)) } diff --git a/src/main.js b/src/main.js index f7ef159d..a7e9e930 100644 --- a/src/main.js +++ b/src/main.js @@ -17,6 +17,7 @@ import './global-components' // 3rd party plugins import '@/libs/portal-vue' import '@/libs/toastification' +import '@/libs/clipboard' Vue.use(VueI18n) diff --git a/src/router/index.js b/src/router/index.js index f76bebe9..b5648c80 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -76,7 +76,7 @@ const router = new VueRouter({ pageTitle: 'Address Book', breadcrumb: [ { - text: 'Transaction', + text: 'Address Book', active: true, }, ], @@ -98,6 +98,24 @@ const router = new VueRouter({ ], }, }, + { + path: '/:chain/account/:address', + name: 'chain-account', + component: () => import('@/views/UserAccountDetail.vue'), + meta: { + pageTitle: 'Accounts', + breadcrumb: [ + { + text: 'Accounts', + active: true, + }, + { + text: 'Detail', + active: true, + }, + ], + }, + }, { path: '/:chain/staking', name: 'staking', diff --git a/src/views/ChartjsComponentDoughnutChart.vue b/src/views/ChartjsComponentDoughnutChart.vue new file mode 100644 index 00000000..4d7df769 --- /dev/null +++ b/src/views/ChartjsComponentDoughnutChart.vue @@ -0,0 +1,21 @@ + diff --git a/src/views/UserAccountDetail.vue b/src/views/UserAccountDetail.vue new file mode 100644 index 00000000..b5605d45 --- /dev/null +++ b/src/views/UserAccountDetail.vue @@ -0,0 +1,506 @@ + + + diff --git a/src/views/UserAccounts.vue b/src/views/UserAccounts.vue index ac784cb5..53ae0e24 100644 --- a/src/views/UserAccounts.vue +++ b/src/views/UserAccounts.vue @@ -46,21 +46,19 @@ class="cursor-pointer" /> - - Send + Transfer - Detail + Detail - Remove + Remove diff --git a/yarn.lock b/yarn.lock index b373605f..b0d2935e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11255,6 +11255,11 @@ vue-property-decorator@^8.0.0: dependencies: vue-class-component "^7.1.0" +vue-qr@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/vue-qr/-/vue-qr-2.5.0.tgz#2b938f8d4c3d07eaf9e4931b714e32f7ca15b5dd" + integrity sha512-lVCEqzZyhrZ49dr6n1C4dMNH/tvKJzRwJhCi9vxWYpiosYTWM0J5m5RsJ745S88XWwgTeOynKMGbyOLG9ZP20Q== + vue-ripple-directive@2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/vue-ripple-directive/-/vue-ripple-directive-2.0.1.tgz"