Skip to content

Commit f8cc63f

Browse files
committed
feat: add user info to topup link
1 parent 0a37aa4 commit f8cc63f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

web/default/src/pages/TopUp/index.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const TopUp = () => {
88
const [topUpLink, setTopUpLink] = useState('');
99
const [userQuota, setUserQuota] = useState(0);
1010
const [isSubmitting, setIsSubmitting] = useState(false);
11+
const [user, setUser] = useState({});
1112

1213
const topUp = async () => {
1314
if (redemptionCode === '') {
@@ -41,14 +42,22 @@ const TopUp = () => {
4142
showError('超级管理员未设置充值链接!');
4243
return;
4344
}
44-
window.open(topUpLink, '_blank');
45+
let url = new URL(topUpLink);
46+
let username = user.username;
47+
let user_id = user.id;
48+
// add username and user_id to the topup link
49+
url.searchParams.append('username', username);
50+
url.searchParams.append('user_id', user_id);
51+
url.searchParams.append('transaction_id', crypto.randomUUID());
52+
window.open(url.toString(), '_blank');
4553
};
4654

4755
const getUserQuota = async ()=>{
4856
let res = await API.get(`/api/user/self`);
4957
const {success, message, data} = res.data;
5058
if (success) {
5159
setUserQuota(data.quota);
60+
setUser(data);
5261
} else {
5362
showError(message);
5463
}
@@ -80,7 +89,7 @@ const TopUp = () => {
8089
}}
8190
/>
8291
<Button color='green' onClick={openTopUpLink}>
83-
获取兑换码
92+
充值
8493
</Button>
8594
<Button color='yellow' onClick={topUp} disabled={isSubmitting}>
8695
{isSubmitting ? '兑换中...' : '兑换'}

0 commit comments

Comments
 (0)