Merge remote-tracking branch 'origin/master'
commit
f6a22b33b8
|
@ -1,47 +1,27 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-table
|
||||
: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>
|
||||
<span style="text-align: center">账户余额: {{ balance }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { userBalance } from "@/api/system/user"; // 引入 API 方法
|
||||
import { getToken } from "@/utils/auth"; // 引入获取 Token 的方法
|
||||
import {userBalance} from "@/api/system/user";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
listDate: [],
|
||||
userId: null
|
||||
balance: null, // 用于存储用户余额
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.userId = getToken(); // 从 Token 中获取用户 ID
|
||||
if (this.userId) {
|
||||
this.fetchUserBalance(this.userId); // 获取用户余额
|
||||
async created() {
|
||||
try {
|
||||
const userId = 1; // 根据实际情况获取用户 ID
|
||||
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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue