Merge remote-tracking branch 'origin/master'

master
chaiyapeng 2024-08-23 22:12:34 +08:00
commit f6a22b33b8
1 changed files with 10 additions and 30 deletions

View File

@ -1,47 +1,27 @@
<template> <template>
<div> <div>
<el-table <span style="text-align: center">账户余额: {{ balance }}</span>
:data="listDate"
style="width: 100%">
<el-table-column
label="用户余额"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.userBalance }}</span>
</template>
</el-table-column>
</el-table>
</div> </div>
</template> </template>
<script> <script>
import { userBalance } from "@/api/system/user"; // API import {userBalance} from "@/api/system/user";
import { getToken } from "@/utils/auth"; // Token
export default { export default {
data() { data() {
return { return {
listDate: [], balance: null, //
userId: null
}; };
}, },
created() { async created() {
this.userId = getToken(); // Token ID try {
if (this.userId) { const userId = 1; // ID
this.fetchUserBalance(this.userId); // const response = await userBalance(userId);
this.balance = response.data.balance; //
} catch (error) {
console.error('Error fetching user balance:', error);
} }
}, },
methods: {
async fetchUserBalance(userId) {
try {
const response = await userBalance(userId);
this.listDate = [{ paymentAmount: response.data.userBalance }];
} catch (error) {
console.error('Error fetching user balance:', error);
}
},
}
}; };
</script> </script>