Initial commit
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -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 });
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
<button
|
||||
class="cooldown-btn"
|
||||
disabled="{{countdown > 0 || loading}}"
|
||||
loading="{{loading}}"
|
||||
bindtap="onTap"
|
||||
>
|
||||
{{countdown > 0 ? countdown + '秒' : (loading ? '提交中' : text)}}
|
||||
</button>
|
||||
@@ -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;
|
||||
}
|
||||
4
srde/miniprogram/components/risk-card/risk-card.json
Normal file
4
srde/miniprogram/components/risk-card/risk-card.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
7
srde/miniprogram/components/risk-card/risk-card.ts
Normal file
7
srde/miniprogram/components/risk-card/risk-card.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
Component({
|
||||
properties: {
|
||||
title: { type: String, value: '' },
|
||||
value: { type: String, value: '' },
|
||||
sub: { type: String, value: '' },
|
||||
},
|
||||
});
|
||||
5
srde/miniprogram/components/risk-card/risk-card.wxml
Normal file
5
srde/miniprogram/components/risk-card/risk-card.wxml
Normal 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>
|
||||
14
srde/miniprogram/components/risk-card/risk-card.wxss
Normal file
14
srde/miniprogram/components/risk-card/risk-card.wxss
Normal 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;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
19
srde/miniprogram/components/status-badge/status-badge.ts
Normal file
19
srde/miniprogram/components/status-badge/status-badge.ts
Normal 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 });
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
<view class="badge status-{{status}}">{{text || (status === 'tradable' ? '可交易' : (status === 'compressed' ? '风险压缩' : '锁仓'))}}</view>
|
||||
@@ -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; }
|
||||
4
srde/miniprogram/components/trade-item/trade-item.json
Normal file
4
srde/miniprogram/components/trade-item/trade-item.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
18
srde/miniprogram/components/trade-item/trade-item.ts
Normal file
18
srde/miniprogram/components/trade-item/trade-item.ts
Normal 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}` });
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
14
srde/miniprogram/components/trade-item/trade-item.wxml
Normal file
14
srde/miniprogram/components/trade-item/trade-item.wxml
Normal 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>
|
||||
9
srde/miniprogram/components/trade-item/trade-item.wxss
Normal file
9
srde/miniprogram/components/trade-item/trade-item.wxss
Normal 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; }
|
||||
Reference in New Issue
Block a user