实现了从后台读取当前用户的账户余额。
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="owner-page">
|
<div class="owner-page">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="app-card elevation-1"></div>
|
<div class="app-card elevation-1">
|
||||||
|
<div>余额为 {{ balance }}</div>
|
||||||
|
</div>
|
||||||
<div class="app-sep"></div>
|
<div class="app-sep"></div>
|
||||||
<div class="app-card elevation-1"></div>
|
<div class="app-card elevation-1"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,12 +54,19 @@
|
|||||||
import {
|
import {
|
||||||
createNamespacedHelpers,
|
createNamespacedHelpers,
|
||||||
} from 'vuex'
|
} from 'vuex'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('owner')
|
const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('owner')
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Owner',
|
name: 'Owner',
|
||||||
|
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
balance:0,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState([
|
||||||
'headers',
|
'headers',
|
||||||
@@ -68,7 +77,22 @@ export default {
|
|||||||
]),
|
]),
|
||||||
...mapGetters([]),
|
...mapGetters([]),
|
||||||
},
|
},
|
||||||
|
created:async function(){
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted:async function(){
|
||||||
|
let account=sessionStorage.getItem('KEY_ACCOUNT')
|
||||||
|
try{
|
||||||
|
account=JSON.parse(account)
|
||||||
|
let result=await axios({
|
||||||
|
method:'post',
|
||||||
|
url:location.protocol+'//'+location.hostname+':6842/api/Account/getBalance',
|
||||||
|
data: {Account:{address:account.address}}
|
||||||
|
})
|
||||||
|
this.balance=result.data||0
|
||||||
|
} catch(e){}
|
||||||
|
}
|
||||||
|
,
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions([
|
...mapActions([
|
||||||
]),
|
]),
|
||||||
|
|||||||
Reference in New Issue
Block a user