Initial commit
Made-with: Cursor
This commit is contained in:
6
srde/miniprogram/pages/profile/profile.json
Normal file
6
srde/miniprogram/pages/profile/profile.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"status-badge": "/components/status-badge/status-badge"
|
||||
},
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
49
srde/miniprogram/pages/profile/profile.ts
Normal file
49
srde/miniprogram/pages/profile/profile.ts
Normal 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);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
15
srde/miniprogram/pages/profile/profile.wxml
Normal file
15
srde/miniprogram/pages/profile/profile.wxml
Normal file
@@ -0,0 +1,15 @@
|
||||
<view class="page">
|
||||
<view class="card">
|
||||
<view class="label">当前状态</view>
|
||||
<status-badge status="{{account.status}}" />
|
||||
<view class="lock-until" wx:if="{{account.trading_locked_until}}">锁仓至 {{account.trading_locked_until}}</view>
|
||||
</view>
|
||||
<view class="card">
|
||||
<view class="label">修改总资金</view>
|
||||
<input class="input" type="digit" value="{{capital}}" placeholder="输入新总资金" bindinput="onCapitalInput" />
|
||||
<button class="btn" bindtap="onSaveCapital" loading="{{saving}}">保存</button>
|
||||
</view>
|
||||
<view class="card danger">
|
||||
<button class="btn-reset" bindtap="onReset" loading="{{resetting}}">重置账户(危险操作)</button>
|
||||
</view>
|
||||
</view>
|
||||
6
srde/miniprogram/pages/profile/profile.wxss
Normal file
6
srde/miniprogram/pages/profile/profile.wxss
Normal file
@@ -0,0 +1,6 @@
|
||||
.page { padding: 20rpx; }
|
||||
.label { color: #888; margin-bottom: 12rpx; }
|
||||
.input { width: 100%; padding: 20rpx; border: 1rpx solid #ddd; border-radius: 12rpx; box-sizing: border-box; margin-bottom: 24rpx; }
|
||||
.btn { width: 100%; padding: 28rpx; background: #5a9; color: #fff; border-radius: 16rpx; border: none; }
|
||||
.lock-until { color: #a44; margin-top: 16rpx; font-size: 26rpx; }
|
||||
.btn-reset { width: 100%; padding: 28rpx; background: #a44; color: #fff; border-radius: 16rpx; border: none; }
|
||||
Reference in New Issue
Block a user