Merge remote-tracking branch 'origin/master'
commit
f6a22b33b8
|
@ -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>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue