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,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,22 @@
Component({
properties: {
text: { type: String, value: '确认' },
duration: { type: Number, value: 3 },
},
data: { countdown: 0, loading: false },
methods: {
onTap() {
if (this.data.countdown > 0 || this.data.loading) return;
this.setData({ countdown: this.properties.duration });
const t = setInterval(() => {
const n = this.data.countdown - 1;
this.setData({ countdown: n });
if (n <= 0) clearInterval(t);
}, 1000);
this.triggerEvent('confirm');
},
setLoading(v: boolean) {
this.setData({ loading: v });
},
},
});

View File

@@ -0,0 +1,8 @@
<button
class="cooldown-btn"
disabled="{{countdown > 0 || loading}}"
loading="{{loading}}"
bindtap="onTap"
>
{{countdown > 0 ? countdown + '秒' : (loading ? '提交中' : text)}}
</button>

View File

@@ -0,0 +1,12 @@
.cooldown-btn {
width: 100%;
padding: 28rpx;
border-radius: 16rpx;
font-size: 32rpx;
background: #5a9;
color: #fff;
border: none;
}
.cooldown-btn[disabled] {
background: #888;
}

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,7 @@
Component({
properties: {
title: { type: String, value: '' },
value: { type: String, value: '' },
sub: { type: String, value: '' },
},
});

View File

@@ -0,0 +1,5 @@
<view class="risk-card card">
<view class="card-title">{{title}}</view>
<view class="value">{{value}}</view>
<view class="sub" wx:if="{{sub}}">{{sub}}</view>
</view>

View File

@@ -0,0 +1,14 @@
.risk-card {
flex: 1;
min-width: 0;
}
.risk-card .value {
font-size: 36rpx;
font-weight: 600;
color: #333;
}
.risk-card .sub {
font-size: 24rpx;
color: #888;
margin-top: 8rpx;
}

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,19 @@
const STATUS_TEXT: Record<string, string> = {
tradable: '可交易',
compressed: '风险压缩',
locked: '锁仓',
};
Component({
properties: {
status: { type: String, value: 'tradable' },
text: { type: String, value: '' },
},
lifetimes: {
attached() {
const s = this.properties.status;
const t = this.properties.text || STATUS_TEXT[s] || s;
this.setData({ text: t });
},
},
});

View File

@@ -0,0 +1 @@
<view class="badge status-{{status}}">{{text || (status === 'tradable' ? '可交易' : (status === 'compressed' ? '风险压缩' : '锁仓'))}}</view>

View File

@@ -0,0 +1,9 @@
.badge {
display: inline-block;
padding: 8rpx 20rpx;
border-radius: 24rpx;
font-size: 24rpx;
}
.status-tradable { background: rgba(85,170,153,0.2); color: #5a9; }
.status-compressed { background: rgba(187,153,85,0.2); color: #b95; }
.status-locked { background: rgba(170,68,68,0.2); color: #a44; }

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,18 @@
Component({
properties: {
id: String,
symbol: String,
direction: String,
entry_price: [String, Number],
status: String,
position_size: [String, Number],
pnl: Number,
},
methods: {
onTap() {
if (this.data.id) {
wx.navigateTo({ url: `/pages/trade-detail/trade-detail?id=${this.data.id}` });
}
},
},
});

View File

@@ -0,0 +1,14 @@
<view class="trade-item card" bindtap="onTap">
<view class="row">
<text class="symbol">{{symbol}}</text>
<text class="dir {{direction}}">{{direction === 'long' ? '多' : '空'}}</text>
</view>
<view class="row sub">
<text>入场 {{entry_price}}</text>
<text class="status-{{status}}">{{status === 'open' ? '持仓' : '已平'}}</text>
</view>
<view class="row sub" wx:if="{{pnl !== undefined}}">
<text>盈亏</text>
<text class="{{pnl >= 0 ? 'profit' : 'loss'}}">{{pnl >= 0 ? '+' : ''}}{{pnl}}</text>
</view>
</view>

View File

@@ -0,0 +1,9 @@
.trade-item { cursor: pointer; }
.trade-item .row { display: flex; justify-content: space-between; margin-bottom: 8rpx; }
.trade-item .symbol { font-weight: 600; color: #333; }
.trade-item .dir { font-size: 24rpx; }
.trade-item .dir.long { color: #5a9; }
.trade-item .dir.short { color: #95a; }
.trade-item .sub { font-size: 24rpx; color: #888; }
.trade-item .profit { color: #5a9; }
.trade-item .loss { color: #a44; }