Refactor axios & Owner page

This commit is contained in:
saplf
2018-10-23 12:49:49 +08:00
parent 6a2eaaa175
commit 673e4a11b7
4 changed files with 29 additions and 23 deletions

View File

@@ -2,7 +2,7 @@
<div class="owner-page">
<div class="card-content">
<div class="app-card elevation-1">
<div>余额为 {{ balance }}</div>
<div>余额为 {{ balance }}</div>
</div>
<div class="app-sep"></div>
<div class="app-card elevation-1"></div>
@@ -54,19 +54,12 @@
import {
createNamespacedHelpers,
} from 'vuex'
import axios from 'axios'
const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('owner')
export default {
name: 'Owner',
data(){
return {
balance:0,
}
},
computed: {
...mapState([
'headers',
@@ -74,27 +67,18 @@ export default {
'pageEntity',
'fetching',
'filter',
'balance',
]),
...mapGetters([]),
},
created:async function(){
mounted() {
this.queryAccount()
},
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: {
...mapActions([
'queryAccount',
]),
...mapMutations([
'inputFilter',