2019-12-21 07:20:25 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<TitleBar/>
|
2019-12-21 11:22:21 +00:00
|
|
|
<CreditLists v-bind:users="users" @add:amount="addAmount"></CreditLists>
|
2019-12-21 07:20:25 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import TitleBar from "@/components/TitleBar";
|
|
|
|
import CreditLists from "@/components/baruser/CreditLists";
|
2019-12-21 11:22:21 +00:00
|
|
|
import httpClient from "../plugins/restService";
|
|
|
|
import axios from "axios";
|
2019-12-21 07:20:25 +00:00
|
|
|
export default {
|
|
|
|
name: "BarView",
|
|
|
|
components: {CreditLists, TitleBar},
|
|
|
|
created() {
|
|
|
|
this.getUser()
|
|
|
|
},
|
2019-12-21 11:22:21 +00:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
users: []
|
|
|
|
}
|
|
|
|
},
|
2019-12-21 07:20:25 +00:00
|
|
|
methods: {
|
|
|
|
getUser() {
|
|
|
|
// eslint-disable-next-line no-console
|
2019-12-21 11:22:21 +00:00
|
|
|
httpClient.getUserBar(this.$store.getters.getToken)
|
2019-12-21 07:20:25 +00:00
|
|
|
.then(response => {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log(response.data)
|
2019-12-21 11:22:21 +00:00
|
|
|
for (let user in response.data) {
|
|
|
|
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
|
|
|
|
this.users.push({
|
|
|
|
id: lastId + 1,
|
|
|
|
username: response.data[user].username,
|
|
|
|
firstname: response.data[user].firstname,
|
|
|
|
lastname: response.data[user].lastname,
|
|
|
|
amount: response.data[user].amount
|
|
|
|
})
|
|
|
|
}
|
2019-12-21 07:20:25 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log(error)
|
2019-12-21 11:22:21 +00:00
|
|
|
this.users = []
|
|
|
|
})
|
|
|
|
},
|
|
|
|
addAmount(username, amount) {
|
|
|
|
axios.post('http://192.168.5.118:5000/baradd', {userId: username, amount: amount}, {headers: {Token: this.$store.getters.getToken}})
|
|
|
|
//httpClient.addAmountBar(this.$store.getters.getToken, {username: username, amount: amount})
|
|
|
|
/*.then(response => {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log("responsedata: ", response.data)
|
2019-12-21 07:20:25 +00:00
|
|
|
})
|
2019-12-21 11:22:21 +00:00
|
|
|
.catch(error => {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log("error: ", error.response.data.error)
|
|
|
|
})*/
|
2019-12-21 07:20:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|