Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Dashboard.vue
Show All 28 Lines | export default { | ||||
}, | }, | ||||
data() { | data() { | ||||
return { | return { | ||||
status: {}, | status: {}, | ||||
balance: 0 | balance: 0 | ||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
const authInfo = this.$store.state.isLoggedIn ? this.$store.state.authInfo : null | const authInfo = this.$store.state.authInfo | ||||
if (authInfo) { | |||||
this.status = authInfo.statusInfo | this.status = authInfo.statusInfo | ||||
this.getBalance(authInfo) | this.getBalance(authInfo) | ||||
} else { | |||||
this.$root.startLoading() | |||||
axios.get('/api/auth/info') | |||||
.then(response => { | |||||
this.$store.state.authInfo = response.data | |||||
this.status = response.data.statusInfo | |||||
this.getBalance(response.data) | |||||
this.$root.stopLoading() | |||||
}) | |||||
.catch(this.$root.errorHandler) | |||||
} | |||||
}, | }, | ||||
methods: { | methods: { | ||||
getBalance(authInfo) { | getBalance(authInfo) { | ||||
this.balance = 0; | this.balance = 0; | ||||
// TODO: currencies, multi-wallets, accounts | // TODO: currencies, multi-wallets, accounts | ||||
authInfo.wallets.forEach(wallet => { | authInfo.wallets.forEach(wallet => { | ||||
this.balance += wallet.balance | this.balance += wallet.balance | ||||
}) | }) | ||||
}, | }, | ||||
statusUpdate(user) { | statusUpdate(user) { | ||||
this.status = Object.assign({}, this.status, user) | this.status = Object.assign({}, this.status, user) | ||||
this.$store.state.authInfo.statusInfo = this.status | this.$store.state.authInfo.statusInfo = this.status | ||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |