Initial commit

Made-with: Cursor
This commit is contained in:
Daniel
2026-02-28 18:39:00 +08:00
commit a94bd44c3a
49 changed files with 917 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import { mockAccount } from '../../services/api';
Page({
data: {
account: mockAccount,
capital: '',
saving: false,
resetting: false,
},
onLoad() {
const app = getApp<IAppOption>();
const acc = app.globalData.account || mockAccount;
this.setData({ account: acc, capital: String(acc.total_capital) });
},
onCapitalInput(e: WechatMiniprogram.CustomEvent) {
this.setData({ capital: e.detail.value as string });
},
onSaveCapital() {
const cap = parseFloat(this.data.capital);
if (!cap || cap <= 0) {
wx.showToast({ title: '请输入有效金额', icon: 'none' });
return;
}
this.setData({ saving: true });
setTimeout(() => {
const acc = { ...mockAccount, total_capital: cap, current_capital: cap };
getApp<IAppOption>().globalData.account = acc;
this.setData({ saving: false, account: acc });
wx.showToast({ title: '已保存' });
}, 500);
},
onReset() {
wx.showModal({
title: '确认重置',
content: '将清空所有交易数据,确定吗?',
success: (res) => {
if (res.confirm) {
this.setData({ resetting: true });
setTimeout(() => {
const acc = { ...mockAccount, current_capital: mockAccount.total_capital, consecutive_losses: 0, trading_locked_until: null, status: 'tradable' as const };
getApp<IAppOption>().globalData.account = acc;
this.setData({ resetting: false, account: acc });
wx.showToast({ title: '已重置' });
}, 500);
}
},
});
},
});