10.10综合交易所原始源码_移动端
admin
2026-01-06 42faef34194c466f03e29d75a63ae502e4213044
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
    <div>
        <van-nav-bar :title="$t('closePosition')">
            <template #left>
            </template>
            <template #right>
                <van-icon class="cross-icon" name="cross" @click="$router.back()" />
            </template>
        </van-nav-bar>
        <div class="cell-item flex mt-20" v-if="dataInfo.item">
            <div class="cell-item-left flex-1">{{ t('Symbol') }}</div>
            <div class="cell-item-right">{{ dataInfo.item.symbol }}</div>
        </div>
        <div class="cell-item flex" v-if="dataInfo.item">
            <div class="cell-item-left flex-1">{{ t('position') }}</div>
            <div class="cell-item-right">
                {{ detail.volume / (detail.lever_rate ? detail.lever_rate : 1) }}*{{ detail.lever_rate ? detail.lever_rate :
                    1
                }}x
            </div>
        </div>
        <div class="cell-item flex" v-if="dataInfo.item">
            <div class="cell-item-left flex-1">{{ t('exchangeDirection') }}</div>
            <div class="cell-item-right">{{ dataInfo.item.direction == 'buy' ? $t('buy') : $t('sell') }}</div>
        </div>
        <div class="cell-item flex" v-if="dataInfo.item">
            <div class="cell-item-left flex-1">{{ t('执行点位') }}</div>
            <div class="cell-item-right">{{ detail.trade_avg_price }}</div>
        </div>
        <div class="cell-item flex" v-if="dataInfo.item">
            <!-- 实时点位取平仓价格字段,执行点位取建仓成本 -->
            <div class="cell-item-left flex-1">{{ t('实时点位') }}</div>
            <div class="cell-item-right">{{ detail.close_avg_price }}</div>
        </div>
        <div class="cell-item flex" v-if="dataInfo.item">
            <div class="cell-item-left flex-1">{{ t('盈利') }}</div>
            <div :class="{ 'cell-item-right': true, 'red': +detail.profit < 0, 'green': +detail.profit > 0 }">{{
                detail.profit }}</div>
        </div>
        <div class="fixed-bottom ">
            <van-button @click="$router.back()">{{ $t('Cancel') }}</van-button>
            <van-button type="primary" @click="cancelOrder">{{ $t('closePosition') }}</van-button>
        </div>
    </div>
</template>
<script setup>
import {
    _contractOrderClose,
    _orderHoldDetail
} from "@/service/trade.api.js";
import { onMounted, onBeforeUnmount, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router';
import {
    showToast
} from 'vant';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const router = useRouter()
const route = useRoute()
const year = ref('')
const detail = ref({})
const dataInfo = ref({})
const timer = ref(null)
 
onMounted(() => {
    let date = new Date()
    year.value = date.getFullYear()
    dataInfo.value = JSON.parse(route.query.checkInfo)
    fetchDetail(dataInfo.value.item.order_no);
    // timer.value = setInterval(()=>{
    //     fetchDetail(dataInfo.value.item.order_no);
    // },1000);  
 
})
 
onBeforeUnmount(() => {
    clearInterval(timer.value)
    timer.value = null
})
 
const cancelOrder = () => {
    let obj = {
        order_no: dataInfo.value.item.order_no
    }
    console.log(obj)
    _contractOrderClose(obj).then((res) => {
        showToast(t('SuccessfulOperation'))
        setTimeout(() => {
            router.back()
        }, 1000)
    })
}
 
const fetchDetail = (order_no) => {
    _orderHoldDetail(order_no).then(data => {
        detail.value = data
    })
}
</script>
<style lang="scss" scoped>
.green {
    color: $green !important;
}
 
.red {
    color: $red !important;
}
 
.cross-icon {
    font-size: 18px;
    color: #494A50;
}
 
.mt-20 {
    margin-top: 20px;
}
 
.cell-item {
    padding: 0 15px;
    height: 45px;
    align-items: center;
    justify-content: center;
 
    .cell-item-left {
        font-size: 16px;
        color: $text_color5;
    }
 
    .cell-item-right {
        font-size: 18px;
        color: #1F2025;
    }
}
 
.fixed-bottom {
    position: fixed;
    bottom: constant(safe-area-inset-bottom);
    bottom: env(safe-area-inset-bottom);
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid $border-grey;
    padding: 20px 15px;
}
 
:deep(.van-button--primary) {
    height: 50px;
    width: 165px;
    border-radius: 5px;
    background: $btn_main;
}
 
:deep(.van-button--default) {
    height: 50px;
    width: 165px;
    border-radius: 5px;
    border: 1px solid $btn_main;
    color: $active_line;
}
</style>