交易所前端蓝色ui, 4.5 jiem
lxf
2025-04-18 66a33e936d39ec4db7fdffed5d646e044ccc43e9
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<template>
  <div class="contract">
    <div class="flex justify-between box-border px-30 mt-43">
      <div @click="onTap(0)" :class="{ active: tapIndex === 0 }"
        class=" w-370 h-75 lh-75 rounded-lg font-27 text-center mr-20">{{ $t('永续合约') }}</div>
      <div @click="onTap(1)" :class="{ active: tapIndex === 1 }" class=" w-370 h-75 lh-75 rounded-lg font-27 text-center">
        {{ $t('交割合约') }}</div>
    </div>
    <div>
      <div class="box-border px-30 mt-42">
        <div class="flex justify-between text-grey relative">
          <div class="flex">
            <span class="text-grey font-30">{{ $t('总资产') }}(USDT)</span>
            <div @click.stop="changeEyes">
              <img :src="require('../../assets/image/assets-center/eye-open.png')" class="w-32 h-18" v-show="!eyetel" />
              <img :src="require('../../assets/image/assets-center/eye-close.png')" class="w-32 h-18" v-show="eyetel" />
            </div>
          </div>
          <div class="right-clock">
            <img @click="goHistory" :src="require('../../assets/image/assets-center/Subtract.png')" class="w-44 h-38" />
          </div>
        </div>
        <div class="font-700 font-66 mt-18 textColor" v-if="!eyetel">
          {{ tapIndex === 0 ? funds.money_contract : funds.money_futures }}
          <span class="font-39 text-grey">≈{{ currency.currency_symbol }}{{ funds.money_contract ? (((tapIndex === 0 ?
            funds.money_contract :
            funds.money_futures) * currency.rate).toFixed(2)) : ' --' }}</span>
        </div>
        <div class="font-70 font-66 mt-18 textColor" v-else>******** </div>
        <div class="flex font-26 lh-32 mb-35 mt-40">
          <div class="flex flex-col ">
            <div>{{ tapIndex === 0 ? $t('保证金余额') : $t('全部未实现盈亏') }}(USDT)</div>
            <template v-if="!eyetel">
              <div class="font-40 mt-17 mb-9 textColor">{{ tapIndex === 0 ? funds.money_contract_deposit :
                funds.money_futures_profit }}</div>
              <div>≈{{ currency.currency_symbol }}{{ funds.money_contract_deposit ? (((tapIndex === 0 ?
                funds.money_contract_deposit :
                funds.money_futures_profit) * currency.rate).toFixed(2)) : ' --' }}</div>
            </template>
            <template v-else>
              <div class="font-40 mt-17 mb-9 textColor">*********</div>
            </template>
          </div>
          <div class="flex flex-col ml-110">
            <div>{{ $t('钱包余额(USDT)') }}</div>
            <template v-if="!eyetel">
              <div class="font-40 mt-17 mb-9 textColor">{{ funds.money_wallet }}</div>
              <div>≈{{ currency.currency_symbol }}{{ funds.money_wallet ? (funds.money_wallet * currency.rate).toFixed(2)
                :
                ' --' }}</div>
            </template>
            <template v-else>
              <div class="font-40 mt-17 mb-9 textColor">*********</div>
            </template>
          </div>
        </div>
        <div v-if="tapIndex === 0" class="flex flex-col lh-32 mb-35 ">
          <template v-if="!eyetel">
            <div>{{ $t('全部未实现盈亏') }}(USDT)</div>
            <div class="font-40 mt-17 mb-9 textColor">{{ funds.money_contract_profit }}</div>
            <div>≈{{ currency.currency_symbol }}{{ funds.money_contract_profit ? (funds.money_contract_profit *
              currency.rate).toFixed(2) : ' --' }}</div>
          </template>
          <template v-else>
            <div class="font-40 mt-17 mb-9 textColor">*********</div>
          </template>
        </div>
      </div>
      <div class="w-full h-13 contBackground"></div>
      <!--永续合约持有仓位-->
      <div class="px-30">
        <template v-if="tapIndex === 0">
          <PerpetualPositionList :list-data="orderHold" @sell="onRecall"></PerpetualPositionList>
        </template>
        <!--交割合约持有仓位-->
        <template v-else>
          <futrue-hold-list :list-data="futrueHold" />
        </template>
      </div>
    </div>
  </div>
</template>
 
<script>
import Axios from "@/API/assets";
import { mapGetters } from "vuex";
import PerpetualPositionList from '../perpetual-position-list/index.vue';
import futrueHoldList from '@/page/deliveryContract/hold.vue'
import { _futrueOrderList, _orderListHold } from "@/API/trade.api";
export default {
  name: "contract",
  components: {
    PerpetualPositionList,
    futrueHoldList
  },
  data() {
    return {
      orderHold: [], // 永续持有仓位
      futrueHold: [], // 交割持有仓位
      tapIndex: 0,
      eyetel: false,
      total: "",
      timer: null,
      timer2: null
    }
  },
  props: ['funds', 'index'],
  computed: {
    ...mapGetters('home', ['currency'])
  },
  watch: {
    index: {
      handler: function (val) {
        console.log(val)
        this.tapIndex = val / 1
      },
      immediate: true
    }
  },
  created() {
    this.fetch()
  },
  methods: {
    goHistory() {
      if (this.tapIndex === 0) {
        this.$router.push({ path: '/perpetualHistory', query: { goback: 1 } })
      } else {
        this.$router.push({ path: '/deliveryContractHistory', query: { goback: 1 } })
      }
    },
    onTap(index) {
      this.tapIndex = index
      this.fetch()
    },
    fetch() {
      this.clearTimer()
      if (this.tapIndex === 0) {
        this.fetchOrderListHold()
      } else {
        this.fetchFutrueHoldList()
      }
    },
    onRecall() { // 撤单or 平仓 evt
      // this.clearTimer()
      // this[this.curTab](this.symbol)
      // this.fetchOrderListHold()
    },
    clearTimer() {
      clearInterval(this.timer)
      clearInterval(this.timer2)
      this.timer = null
      this.timer2 = null
    },
    fetchOrderListHold() { // 获取永续当前持仓
      _orderListHold().then(data => {
        this.orderHold = data
      })
      this.timer = setInterval(() => {
        _orderListHold().then(data => {
          this.orderHold = data
        })
      }, 2000)
    },
    fetchFutrueHoldList() { // 获取交割当前持仓
      _futrueOrderList().then(data => {
        this.futrueHold = data
      })
      console.log('fetchFutrueHoldList')
      this.timer2 = setInterval(() => {
        _futrueOrderList().then(data => {
          this.futrueHold = data
        })
      }, 2000)
    },
    changeEyes() {
      console.log('666')
      this.eyetel = !this.eyetel;
    },
    getData() {
      Axios.GetAllAssets().then((res) => {
        if (res.code == 0) {
          this.total = res.data.total;
          this.status = res.data.status;
        }
      });
    },
  },
  beforeDestroy() {
    this.clearTimer()
  }
}
</script>
 
<style lang="scss" scoped>
.w-370 {
  border: 1px solid #EAEDF2;
  color: #868D9A;
}
 
.active {
  color: #FFFFFF;
 
  @include themify() {
    background: themed("btn_main");
  }
 
  @include themify() {
    border-color: themed("btn_main");
  }
}
 
.lh-32 {
  color: #848E9C;
}
 
.font-40 {
  font-weight: 700;
}
 
.cl {
  color: #333333;
  background: #EBECF0;
}
 
.mr-13 {
  font-weight: 600;
  color: #333333;
}
 
.col {
  color: #848E9C;
}
 
.num {
  font-weight: 600;
  color: #333333;
}
 
.font-4 {
  font-weight: 400;
  color: #333333;
}
 
.blue {
  color: #1D91FF;
}
 
.active_green {
  color: #2EBD85;
}
 
.active_red {
  color: #FF3E3E;
}
 
.active_tab1 {
  background: #FF3E3E;
  color: #FFFFFF;
}
 
.active_tab2 {
  background: #2EBD85;
  color: #FFFFFF;
}
 
.font-6 {
  font-weight: 600;
}
</style>