Initial commit
Made-with: Cursor
This commit is contained in:
8
srde/miniprogram/pages/dashboard/dashboard.json
Normal file
8
srde/miniprogram/pages/dashboard/dashboard.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"risk-card": "/components/risk-card/risk-card",
|
||||
"status-badge": "/components/status-badge/status-badge",
|
||||
"trade-item": "/components/trade-item/trade-item"
|
||||
},
|
||||
"navigationBarTitleText": "风控首页"
|
||||
}
|
||||
37
srde/miniprogram/pages/dashboard/dashboard.ts
Normal file
37
srde/miniprogram/pages/dashboard/dashboard.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { mockAccount, mockTrades } from '../../services/api';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: true,
|
||||
error: '',
|
||||
account: mockAccount,
|
||||
trades: mockTrades.slice(0, 3),
|
||||
},
|
||||
onLoad() {
|
||||
this.load();
|
||||
},
|
||||
onShow() {
|
||||
const app = getApp<IAppOption>();
|
||||
if (app.globalData.account && Date.now() - app.globalData.accountLoadedAt < 30000) {
|
||||
this.setData({ account: app.globalData.account });
|
||||
} else {
|
||||
this.load();
|
||||
}
|
||||
},
|
||||
load() {
|
||||
this.setData({ loading: true, error: '' });
|
||||
const app = getApp<IAppOption>();
|
||||
setTimeout(() => {
|
||||
app.globalData.account = mockAccount;
|
||||
app.globalData.accountLoadedAt = Date.now();
|
||||
this.setData({
|
||||
loading: false,
|
||||
account: mockAccount,
|
||||
trades: mockTrades.slice(0, 3),
|
||||
});
|
||||
}, 300);
|
||||
},
|
||||
goCreate() {
|
||||
wx.navigateTo({ url: '/pages/create/create' });
|
||||
},
|
||||
});
|
||||
36
srde/miniprogram/pages/dashboard/dashboard.wxml
Normal file
36
srde/miniprogram/pages/dashboard/dashboard.wxml
Normal file
@@ -0,0 +1,36 @@
|
||||
<view class="page" wx:if="{{!loading && !error}}">
|
||||
<view class="section">
|
||||
<status-badge status="{{account.status}}" />
|
||||
</view>
|
||||
<view class="section card">
|
||||
<view class="row wrap">
|
||||
<risk-card title="总资金" value="{{account.total_capital}}" />
|
||||
<risk-card title="当前回撤" value="{{account.current_drawdown}}%" />
|
||||
<risk-card title="连续亏损" value="{{account.consecutive_losses}}" />
|
||||
</view>
|
||||
<view class="row wrap">
|
||||
<risk-card title="今日最大风险" value="{{account.daily_risk_limit}}" />
|
||||
<risk-card title="单笔最大风险" value="{{account.single_risk_limit}}" />
|
||||
</view>
|
||||
<view class="lock-msg" wx:if="{{account.status === 'locked'}}">当前处于锁仓期,请勿交易</view>
|
||||
</view>
|
||||
<view class="section" wx:if="{{account.status !== 'locked'}}">
|
||||
<button class="btn-primary" bindtap="goCreate">创建交易计划</button>
|
||||
</view>
|
||||
<view class="section">
|
||||
<view class="card-title">最近交易</view>
|
||||
<trade-item
|
||||
wx:for="{{trades}}"
|
||||
wx:key="id"
|
||||
id="{{item.id}}"
|
||||
symbol="{{item.symbol}}"
|
||||
direction="{{item.direction}}"
|
||||
entry_price="{{item.entry_price}}"
|
||||
status="{{item.status}}"
|
||||
position_size="{{item.position_size}}"
|
||||
pnl="{{item.pnl}}"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="loading" wx:if="{{loading}}">加载中...</view>
|
||||
<view class="error" wx:if="{{error}}">{{error}}</view>
|
||||
15
srde/miniprogram/pages/dashboard/dashboard.wxss
Normal file
15
srde/miniprogram/pages/dashboard/dashboard.wxss
Normal file
@@ -0,0 +1,15 @@
|
||||
.page { padding: 20rpx; }
|
||||
.section { margin-bottom: 24rpx; }
|
||||
.row.wrap { display: flex; flex-wrap: wrap; gap: 16rpx; }
|
||||
.card-title { color: #333; font-size: 28rpx; margin-bottom: 16rpx; padding: 0 20rpx; }
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
padding: 28rpx;
|
||||
background: #5a9;
|
||||
color: #fff;
|
||||
border-radius: 16rpx;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
}
|
||||
.lock-msg { color: #a44; padding: 16rpx 20rpx; font-size: 26rpx; }
|
||||
.loading, .error { padding: 80rpx; text-align: center; color: #888; }
|
||||
Reference in New Issue
Block a user