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,6 @@
{
"usingComponents": {
"risk-card": "/components/risk-card/risk-card"
},
"navigationBarTitleText": "统计数据"
}

View File

@@ -0,0 +1,48 @@
import { mockStats } from '../../services/api';
Page({
data: {
loading: true,
stats: mockStats,
w: 300,
},
onLoad() {
const sys = wx.getSystemInfoSync();
this.setData({
stats: mockStats,
loading: false,
w: (sys.windowWidth || 320) - 40,
});
},
onReady() {
this.drawChart();
},
drawChart() {
const curve = mockStats.equity_curve;
const query = wx.createSelectorQuery().in(this);
query.select('#chart').fields({ node: true, size: true }).exec((res: any) => {
const canvas = res[0]?.node;
if (!canvas) return;
const ctx = canvas.getContext('2d');
const dpr = wx.getSystemInfoSync().pixelRatio || 2;
canvas.width = this.data.w * dpr;
canvas.height = 200 * dpr;
ctx.scale(dpr, dpr);
const w = this.data.w;
const h = 200;
const min = Math.min(...curve);
const max = Math.max(...curve);
const range = max - min || 1;
ctx.strokeStyle = '#5a9';
ctx.lineWidth = 2;
ctx.beginPath();
curve.forEach((v: number, i: number) => {
const x = (i / (curve.length - 1)) * (w - 20) + 10;
const y = h - 20 - ((v - min) / range) * (h - 40);
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
});
ctx.stroke();
});
},
});

View File

@@ -0,0 +1,16 @@
<view class="page" wx:if="{{!loading}}">
<view class="section card">
<view class="row wrap">
<risk-card title="胜率" value="{{stats.win_rate}}%" />
<risk-card title="平均赔率" value="{{stats.avg_odds}}" />
<risk-card title="盈亏比" value="{{stats.profit_factor}}" />
<risk-card title="最大回撤" value="{{stats.max_drawdown}}%" />
<risk-card title="风险评分" value="{{stats.risk_score}}" />
</view>
</view>
<view class="section card">
<view class="card-title">权益曲线</view>
<canvas type="2d" id="chart" class="chart" style="width:{{w}}px;height:200px;"></canvas>
</view>
</view>
<view class="loading" wx:if="{{loading}}">加载中...</view>

View File

@@ -0,0 +1,5 @@
.page { padding: 20rpx; }
.row.wrap { display: flex; flex-wrap: wrap; gap: 16rpx; }
.card-title { color: #333; font-size: 28rpx; margin-bottom: 24rpx; }
.chart { width: 100%; background: #f8f8f8; border-radius: 12rpx; }
.loading { padding: 80rpx; text-align: center; color: #888; }