1
jhzh
2024-08-14 6824e6511b7553aa465dab4017a953c977ae0d02
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
270
271
272
273
274
275
276
277
278
<template>
  <div class="position">
    <div class="position-padding" v-for="item in listData" :key="item.order_no">
      <div class="position-tag">
        <div
          class="position-tag-style"
          :class="item.direction === 'buy' ? 'green' : 'red'"
        >
          {{ item.direction === "buy" ? $t("开多") : $t("开空") }}
        </div>
        <div class="position-tag-title textColor">
          {{ item.name }} {{ $t("交割") }}
        </div>
        <div class="position-tag-title2">{{ $t("全仓") }}</div>
        <img
          class="position-tag-img"
          src="../../assets/image/deliveryContract/Group1042.png"
        />
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("数量") }}</span>
        <span class="position-text2 textColor">{{ item.volume }}</span>
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("方向") }}</span>
        <span
          class="position-text2"
          :class="item.direction === 'buy' ? 'color-green' : 'color-red'"
        >
          {{ item.direction === "buy" ? $t("开多") : $t("开空") }}</span
        >
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("交割时间") }}</span>
        <span class="position-text2 textColor">{{
          item.time_num + item.time_unit
        }}</span>
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("购买价") }}(USDT)</span>
        <span class="position-text2 textColor">{{ item.open_price }}</span>
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("结算价") }}(USDT)</span>
        <span class="position-text2 textColor">{{ item.close_price }}</span>
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("盈亏") }}</span>
        <span
          class="position-text2"
          :class="item.profit > 0 ? 'color-green' : 'color-red'"
        >
          {{ item.profit > 0 ? "+" + item.profit : item.profit }}
        </span>
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("到期时间") }}</span>
        <span class="position-text2 textColor">{{ getnewtime(item.close_time) }}</span>
      </div>
      <div class="position-div1">
        <span class="position-text1">{{ $t("操作") }}</span>
        <span class="position-text2 colorMain" @click="onDetail(item)">{{
          $t("详情")
        }}</span>
      </div>
      <div
        style="margin-top: 33px; width: 100%; height: 1px; float: left"
        class="bgDark"
      ></div>
    </div>
    <div
      class="text-grey text-center py-300"
      v-if="!listData.length && $route.name == 'perpetualContract'"
    >
      {{ $t("您目前没有持仓") }}
    </div>
    <van-popup v-model="show">
      <popup-delivery
        showBtns
        :detailData="detailData"
        :key="detailData.order_no"
        @close="show = false"
        :disabled="true"
      />
    </van-popup>
  </div>
</template>
<script>
import { Tab, Tabs, Popup } from "vant";
import PopupDelivery from "@/components/popup-delivery";
export default {
  data() {
    return {
      active: 2,
      show: false,
      detailData: {},
    };
  },
  props: {
    listData: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  components: {
    [Tab.name]: Tab,
    [Tabs.name]: Tabs,
    [Popup.name]: Popup,
    PopupDelivery,
  },
  methods: {
    onDetail(item) {
      // 详细界面 
      this.show = true;
      this.detailData = item;
    },
    getnewtime(e){
// 给定的时间字符串 (中国时间)
const inputDateStr = e;
 
// 创建一个 Date 对象,注意这里输入的时间是 CST,实际上是 UTC+8
const inputDate = new Date(inputDateStr + ' UTC+0800');
 
// 转换为韩国时间 (KST),KST = UTC + 9 小时
const kstDate = new Date(inputDate.getTime() + 1 * 60 * 60 * 1000); // 8小时 + 1小时 = 9小时
 
// 获取年、月、日、小时、分钟和秒
const year = inputDate.getFullYear();
const month = inputDate.getMonth() + 1; // getMonth() 返回 0 到 11,需要加 1
const day = inputDate.getDate();
const hours = inputDate.getHours(); // 小时部分
const minutes = inputDate.getMinutes(); // 分钟部分
const seconds = inputDate.getSeconds(); // 秒部分
 
// 格式化时间为“年-月-日 小时:分钟:秒”格式
const formattedDate = `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
const formattedTime = `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
              return formattedDate +' '+ formattedTime
    }
  },
  mounted(){
      
  },
};
</script>
<style lang="scss" scoped>
.position {
  width: 100%;
  overflow: auto;
 
  .position-tab-flex {
    width: 100%;
    display: flex;
 
    .position-tab {
      flex: 1;
    }
 
    .position-tab-icon {
      width: 38px;
      height: 38px;
      margin-right: 30px;
      margin-top: 22px;
    }
  }
 
  .position-padding {
    //border-bottom: 1px solid #F2F4F9;
    padding: 42px 40px 0 40px;
    box-sizing: border-box;
    width: 100%;
    overflow: auto;
 
    .position-tag {
      display: flex;
      align-items: center;
 
      .position-tag-style {
        padding: 11px 28px;
        margin-right: 22px;
        font-style: normal;
        font-weight: 400;
        font-size: 26.4981px;
        color: #ffffff;
      }
 
      .position-tag-title {
        font-style: normal;
        font-weight: 600;
        font-size: 30.9145px;
        margin-right: 13px;
      }
 
      .position-tag-title2 {
        font-style: normal;
        font-weight: 400;
        font-size: 30.9145px;
        color: #848e9c;
      }
 
      .position-tag-img {
        margin-left: 11px;
        width: 40px;
        height: 31px;
      }
    }
 
    .red {
      background: #f6465d;
      border-radius: 6.6266px;
    }
 
    .green {
      background: #5eba89;
      border-radius: 6.62453px;
    }
 
    .position-div1 {
      margin-top: 33px;
      width: 100%;
      float: left;
 
      .position-text1 {
        float: left;
        font-style: normal;
        font-weight: 400;
        font-size: 30px;
        color: #848e9c;
      }
 
      .position-text2 {
        float: right;
        font-style: normal;
        font-weight: 400;
        font-size: 30px;
      }
 
      .position-text3 {
        font-style: normal;
        font-weight: 400;
        font-size: 30px;
      }
    }
  }
 
  .color-red {
    color: #f6465d !important;
  }
 
  .color-green {
    color: #5eba89 !important;
  }
 
  .color-blue {
    color: #1d91ff !important;
  }
}
 
.textColor {
  @include themify() {
    color: themed("text_color");
  }
}
 
.border-b-color {
  @include themify() {
    border-bottom: 1px solid themed("border_color");
  }
}
 
.bgDark {
  @include themify() {
    background: themed("border_color");
  }
}
</style>