交易所前端蓝色ui 4.5 jiem
dcc
2024-06-07 4a31519bd6d5db765556664042fdc0a5dcc63cf0
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
<!-- 现货入口 -->
<template>
  <div class="spot-page">
    <div class="home-container">
      <!-- 上部分 -->
      <div class="trade-box">
        <div class="trade-box-wrapper">
          <!--左边 -->
          <div style="flex: 1">
            <!-- 头部 币种信息 -->
            <div
              :class="[isFullscreen ? 'trade-header-box-full' : '']"
              class="trade-header-box"
            >
              <div class="ticker-xl-box">
                <div class="watch-drop-box">
                  <span class="ticker-title" style="width: 259px">{{
                    pageData?.name
                  }}</span>
                </div>
                <div class="line"></div>
                <TopInfo :page-data="pageData" :page-type="pageType"></TopInfo>
              </div>
            </div>
            <!--下部分 订单簿+ 交易区 -->
            <div class="trade-panel-box">
              <div
                class="react-grid-layout layout-xl-box"
                style="display: flex"
              >
                <!--左边订单簿-->
                <OrderBook
                  style="width: 280px"
                  :page-data="pageData"
                  :changeClickData="handleChangeClickData"
                  :filterDown="filterDown"
                  :filterTop="filterDown"
                  :bigIndex="bigIndex"
                  :unit="unit"
                ></OrderBook>
                <!--中间-->
                <div style="flex: 1">
                  <!--上部分 图表+成分股+简况F10 -->
                  <div class="chart-wrapper" v-if="pageType === 'etf'">
                    <div
                      :class="`chart-item ${
                        chartIndex == 1 && 'chart-item-active'
                      }`"
                      @click="handleChartType(1)"
                    >
                      {{ $t("message.user.tubiao") }}
                    </div>
                    <div
                      :class="`chart-item ${
                        chartIndex == 2 && 'chart-item-active'
                      }`"
                      @click="handleChartType(2)"
                    >
                      {{ $t("message.user.chengfengu") }}
                    </div>
                    <div
                      :class="`chart-item ${
                        chartIndex == 3 && 'chart-item-active'
                      }`"
                      @click="handleChartType(3)"
                    >
                      {{ $t("message.user.jiankuangF10") }}
                    </div>
                  </div>
 
                  <!--中间 图表-->
                  <share-info
                    v-if="chartIndex == 2 && pageType === 'etf'"
                    @CurrencySort="CurrencySort"
                    style="height: 500px"
                  ></share-info>
                  <base-info
                    v-if="chartIndex == 3 && pageType === 'etf'"
                  ></base-info>
 
                  <div
                    v-if="chartIndex == 1"
                    class="kline-box comb-trade-kline-box"
                    style="z-index: 99; width: 100%"
                  >
                    <div class="kline-table">
                      <div class="chart-tr">
                        <div class="chart-td" id="parent_trade_k1">
                          <div class="chart-box">
                            <div class="chart-kline" id="trade_k1">
                              <div class="kline-wrap">
                                <!-- toolbar -->
                                <div
                                  :class="[
                                    isFullscreen
                                      ? 'k-toolbar-wrap-full'
                                      : 'k-toolbar-wrap ',
                                  ]"
                                >
                                  <div class="k-toolbar dark">
                                    <div class="k-toolbar-btn">
                                      <!-- 时间 -->
                                      <div class="k-toolbar-left">
                                        <div
                                          class="periods"
                                          v-if="mapIndex == 0"
                                        >
                                          <ul>
                                            <li
                                              v-for="(item, index) in kTimeArr"
                                              :key="index"
                                              :class="
                                                kTimeIndex == item.data
                                                  ? 'selected'
                                                  : ''
                                              "
                                              @click="changeKTime(item)"
                                            >
                                              {{ item.title }}
                                            </li>
                                            <li
                                              v-if="
                                                pageType == 'etf' ||
                                                pageType == 'usStocks'
                                              "
                                              class="kTimeDivider"
                                            ></li>
                                            <!-- 更多 -->
                                            <div
                                              v-if="
                                                pageType == 'etf' ||
                                                pageType == 'usStocks'
                                              "
                                            >
                                              <li
                                                v-for="(it, i) in kTimeArrMore"
                                                :key="i"
                                                :class="
                                                  kTimeIndex == it.data
                                                    ? 'selected'
                                                    : ''
                                                "
                                                @click="changeKTime(it)"
                                              >
                                                {{ it.title }}
                                              </li>
                                            </div>
                                          </ul>
                                        </div>
                                      </div>
                                      <!-- 切换 -->
                                      <div class="k-toolbar-right">
                                        <p
                                          class="status-info"
                                          v-if="
                                            symbolMarketInfo?.market?.status
                                          "
                                        >
                                          <span
                                            >{{
                                              symbolMarketInfo?.market
                                                ?.status &&
                                              $t(
                                                `message.jiaoyi.${symbolMarketInfo?.market?.status}`
                                              )
                                            }}&nbsp;</span
                                          >
                                          <span class="time">{{
                                            symbolMarketInfo?.market?.time_str
                                          }}</span
                                          >&nbsp;
                                          <span>{{
                                            symbolMarketInfo?.market
                                              ?.time_zone &&
                                            $t(
                                              `message.jiaoyi.${symbolMarketInfo?.market?.time_zone}`
                                            )
                                          }}</span>
                                        </p>
 
                                        <div class="toggle">
                                          <span
                                            style="margin-right: 5px"
                                            :class="
                                              mapIndex == index
                                                ? 'selected'
                                                : ''
                                            "
                                            v-for="(item, index) in mapClass"
                                            @click="tabMap(index)"
                                            :key="index"
                                            >{{ item }}</span
                                          >
                                          <div @click="fullScreen">
                                            <img
                                              style="width: 20px"
                                              src="@/assets/images/quotes/Group2892.png"
                                              alt=""
                                            />
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
 
                                <div class="kline-body-wrap" id="okline-wrap">
                                  <div
                                    id="kline-Box"
                                    v-loading="loading"
                                    element-loading-spinner="el-icon-loading"
                                    element-loading-background="rgba(0, 0, 0, 0.8)"
                                    :class="[
                                      'kline-closest-wrapper',
                                      isFullscreen ? 'fullscreen-box' : '',
                                    ]"
                                  >
                                    <kline-box
                                      v-if="mapIndex == 0"
                                      :isSpotGoods="true"
                                      :isFullscreen="isFullscreen"
                                      :data="KLInedata"
                                      :klineIndex="klineIndex"
                                    />
 
                                    <deep-chart
                                      :isSpotGoods="true"
                                      v-else-if="mapIndex == 1 && !isFullscreen"
                                      :deepBuy="deepBuy"
                                      :deepSell="deepSell"
                                    />
                                    <deep-chart-full-screen
                                      v-else-if="mapIndex == 1 && isFullscreen"
                                      :deepBuy="deepBuy"
                                      :deepSell="deepSell"
                                    />
                                    <div
                                      v-if="isShowLoading"
                                      class="kline-loading"
                                      style="
                                        width: 100%;
                                        height: 100%;
                                        position: absolute;
                                        background-color: #000000;
                                        top: 0%;
                                        left: 16px;
                                        z-index: 99;
                                      "
                                    >
                                      <div class="kline-loading-dot"></div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
 
                  <!--下部分 下单区-->
                  <div
                    v-if="!isFullscreen"
                    class="place-order-container-common place-order-xl-box"
                    :class="chartIndex == 1 ? 'mt-200' : ''"
                  >
                    <currencyTrade
                      @refresh="refreshApi"
                      :pageData="pageData"
                      :clickData="clickData"
                      :unit="unit"
                    />
                  </div>
                </div>
              </div>
            </div>
          </div>
          <!--右边-->
          <div style="width: 280px; border-left: 1px solid #24272c">
            <!-- 查询+最新成交 -->
            <makeADeal
              :style="{ display: isFullscreen ? 'none' : 'block' }"
              @checkCurrency="checkCurrency"
              @filterFun="filterFun"
              @CurrencySort="CurrencySort"
              @collectFun="collectFun"
              @deleteCollectFun="deleteCollectFun"
              :listData="left_List_Data"
              :AllListData="allListData"
              @searchFun="searchFun"
              :dealList="rightData"
              :unit="unit"
              @getSelectList="getSelectList"
            />
          </div>
        </div>
      </div>
      <!--下部分-持仓区 -->
      <spot-position
        :unit="unit"
        :paramsType="paramsType"
        ref="refresh"
        :style="{ display: isFullscreen ? 'none' : 'block' }"
      />
    </div>
    <!-- 底部 -->
    <!-- <quotes-state :style="{ display: isFullscreen ? 'none' : 'block' }" /> -->
    <kline-dialog
      ref="kline_dialog"
      :style="{ display: isFullscreen ? 'none' : 'block' }"
    />
  </div>
</template>
<script>
import Axios from "@/api/currency.js";
import AxiosKline from "@/api/kline.js";
import { WhrWebSocket } from "@/utils/WhrWebSocket";
import klineDialog from "@comTrade/klineDialog.vue";
import klineBox from "@comTrade/kline.vue";
import deepChart from "@comTrade/deepChart.vue";
import deepChartFullScreen from "@comTrade/deepChartFullScreen.vue";
import currencyTrade from "@comSpot/createOrder.vue"; //当前币种下单
import makeADeal from "@comSpot/MakeADeal/index.vue";
import SpotPosition from "@comSpot/SpotPosition/index.vue";
import quotesState from "@comSpot/QuotesState/index.vue";
import TopInfo from "@comSpot/TopInfo.vue";
import OrderBook from "@comSpot/OrderBook.vue";
import ShareInfo from "@comSpot/ShareInfo.vue";
import BaseInfo from "@comSpot/BaseInfo.vue";
import { mapState, mapActions, mapStores } from "pinia";
import { useUserStore } from "@/store/user";
import { useCurrencyStore } from "@/store/currency";
import { ElMessage } from "element-plus";
import ConfigURL from "@/config/index";
 
export default {
  name: "spot",
  errorCaptured(err, vm, info) {
    console.log(`错误捕获: ${err.toString()}\ninfo: ${info}`);
    return true; //当捕获一个来自子孙组件的错误时被调用,此钩子可以返回 false 以阻止该错误继续向上传播
  },
  props: {
    pageType: {
      type: String,
      default: "etf", //页面类型
    },
    paramsType: {
      type: String,
      default: "indices", //currencyDetails接口的传参
    },
    defaultSymbol: {
      type: String,
      default: "GlobalETF500", //默认的symbol
    },
  },
  data() {
    return {
      times: ["分时"],
      ConfigURL,
      host_url: "",
      isError: false,
      searcIndexhData: [],
      searchData: "",
      deep: undefined,
      deepBuy: [],
      deepSell: [],
      mapClass: [
        this.$t("message.jiaoyi.jibenban"),
        // this.$t("message.jiaoyi.shendutu"),
      ],
      mapIndex: 0,
      listData: [], //币种
      left_List_Data: [],
      currentTimer: undefined,
      lineTimer: undefined,
      pageTimer: undefined,
      pageData: {}, //页面数据
      Hotcurrency: [],
      tabArr: [
        this.$t("message.jiaoyi.quanbu"),
        this.$t("message.jiaoyi.remenbizhong"),
        this.$t("message.jiaoyi.zixuan"),
      ],
      Trade: undefined, //最新成交,websocket实例
      openTime: undefined, //ws实例
      symbolMarketInfo: {},
      rightData: [], //成交数据
      filterTop: [],
      filterDown: [],
      bigIndex: undefined,
      KLInedata: undefined,
      klineIndex: "", //面积图还是蜡烛图
      kParamsTime: "", // K线查询时间
      kTimeIndex: "", // 选中那个时间,etf默认1D,数字货币默认15min
      isShowLoading: true,
      unit: "USD",
 
      clickData: undefined,
 
      kTimeArrCoin: [
        { data: "minHour", title: this.$t("message.jiaoyi.fenshi") },
        { data: "1min", title: this.$t("message.jiaoyi.1fenzhong") },
        { data: "5min", title: this.$t("message.jiaoyi.5fenzhong") },
        { data: "15min", title: this.$t("message.jiaoyi.15fenzhong") },
        { data: "30min", title: this.$t("message.jiaoyi.30fenzhong") },
        { data: "60min", title: this.$t("message.jiaoyi.1xiaoshi") },
        { data: "4hour", title: this.$t("message.jiaoyi.4xiaoshi") },
        { data: "1day", title: this.$t("message.jiaoyi.1ri") },
        { data: "1week", title: this.$t("message.jiaoyi.1zhou") },
        { data: "1mon", title: this.$t("message.jiaoyi.1yue") },
      ],
      kTimeArrETF: [
        { data: "minHour", title: this.$t("message.jiaoyi.fenshi") },
        { data: "1day", title: this.$t("message.jiaoyi.1ri") },
        { data: "5day", title: this.$t("message.jiaoyi.5ri") },
        { data: "1week", title: this.$t("message.jiaoyi.1zhou") },
        { data: "1mon", title: this.$t("message.jiaoyi.1yue") },
        { data: "1quarter", title: this.$t("message.jiaoyi.season") },
        { data: "1year", title: this.$t("message.jiaoyi.year") },
      ],
      kTimeArrMore: [
        { data: "1min", title: this.$t("message.jiaoyi.1fenzhong") },
        { data: "5min", title: this.$t("message.jiaoyi.5fenzhong") },
        { data: "15min", title: this.$t("message.jiaoyi.15fenzhong") },
        { data: "30min", title: this.$t("message.jiaoyi.30fenzhong") },
        { data: "60min", title: this.$t("message.jiaoyi.60fenzhong") },
        { data: "120min", title: this.$t("message.jiaoyi.120fenzhong") },
      ],
      kTimeArr: [],
      allListData: [],
      collectList: [],
      sortIndex: 0,
      isFullscreen: false, //是否全屏
      loading: true,
      chartIndex: 1,
      isFilter: false,
      filterValue: "",
      searchValue: "",
    };
  },
  components: {
    klineBox,
    deepChart,
    klineDialog,
    currencyTrade,
    BaseInfo,
    ShareInfo,
    makeADeal,
    SpotPosition,
    quotesState,
    deepChartFullScreen,
    TopInfo,
    OrderBook,
  },
  computed: {
    ...mapState(useCurrencyStore, [
      "etfCurrency",
      "usStocksCurrency",
      "coinCurrency",
      "forexCurrency",
    ]),
    ...mapState(useUserStore, ["existToken"]),
  },
 
  // 监听路由名称的变化
  watch: {
    searchData(val) {
      if (val) {
        this.isError = true;
      } else {
        this.isError = false;
      }
    },
    etfCurrency(val, oldval) {
      if (this.pageType === "etf") {
        this.$nextTick(() => {
          this.updateCurrency(val, this.pageType);
        });
      }
    },
    usStocksCurrency(val, oldval) {
      if (this.pageType === "usStocks") {
        this.$nextTick(() => {
          this.updateCurrency(val, this.pageType);
        });
      }
    },
    coinCurrency(val, oldval) {
      if (this.pageType === "coin") {
        this.$nextTick(() => {
          this.updateCurrency(val, this.pageType);
        });
      }
    },
    forexCurrency(val, oldval) {
      if (this.pageType === "forex") {
        this.$nextTick(() => {
          this.updateCurrency(val, this.pageType);
        });
      }
    },
    KLInedata(val) {
      if (val.length > 0) {
        this.isShowLoading = false;
      }
    },
  },
  created() {
    this.host_url = window.location.hostname;
    this.getAllCurrency(); //获取市场的币种
    this.initWebSocket(); // 最新成交
  },
  mounted() {
    if (this.pageType === "forex" || this.pageType === "coin") {
      this.kTimeArr = this.kTimeArrCoin;
      this.kTimeIndex = "15min";
      this.kParamsTime = "15min";
    } else {
      this.kTimeArr = this.kTimeArrETF;
      this.kTimeIndex = "1day";
      this.kParamsTime = "1day";
    }
 
    // 外汇没有深度图
    if (this.pageType === "coin") {
      this.unit = "USDT";
      this.mapClass = [
        this.$t("message.jiaoyi.jibenban"),
        // this.$t("message.jiaoyi.shendutu"),
      ];
    }
 
    this.getAllSymbolData(); //http请求所有币种的数据
    if (this.existToken) {
      this.getItemOptionalList();
    }
    clearInterval(this.lineTimer);
    this.getKlineData();
    this.lineTimer = setInterval(() => {
      this.getKlineData();
    }, 1000);
  },
  unmounted() {
    clearInterval(this.currentTimer);
    clearInterval(this.lineTimer);
    this.Trade.close();
    this.deep.close();
    this.openTime.close();
  },
  methods: {
    ...mapActions(useCurrencyStore, ["updateCurrency"]),
    async getAllCurrency() {
      // let data = await Axios.getAllSymbolDetails({ type: this.paramsType });
      // if (data.code == "0") {
      //   this.updateCurrency(data.data, this.pageType);
      // }
    },
 
    // 切换图标
    handleChartType(val) {
      this.chartIndex = val;
    },
    //点击usft过滤
    filterFun(val) {
      this.isFilter = true;
      this.filterValue = val;
    },
    //刷新api
    refreshApi() {
      this.$refs.refresh.refreshApi();
    },
    //是否获取收藏列表
    getSelectList(val) {
      this.isCollectShow = val;
    },
    //切换币种
    checkCurrency(item) {
      this.clickData = item.close;
      this.tabItemLeft(item);
    },
    //收藏
    collectFun(item) {
      let obj = {
        symbol: item.symbol,
      };
      Axios.addItemUserOptiona(obj).then((res) => {
        if (res.code == "0") {
          ElMessage({
            message: this.$t("message.jiaoyi.shoucangchenggong"),
            type: "success",
          });
          item.isCollect = true;
          this.getItemOptionalList();
        }
      });
    },
    //取消收藏
    deleteCollectFun(item) {
      let obj = {
        symbol: item.symbol,
      };
      Axios.deleteItemUserOptiona(obj).then((res) => {
        if (res.code == "0") {
          ElMessage({
            message: this.$t("message.jiaoyi.quxiaoshoucangchenggong"),
            type: "success",
          });
          item.isCollect = false;
          this.getItemOptionalList();
        }
      });
    },
    //币种排序
    CurrencySort(obj) {
      this.sortIndex = obj;
    },
    //全屏
    fullScreen() {
      this.isFullscreen = !this.isFullscreen;
    },
    //币种搜索
    searchFun(val) {
      this.searchValue = val;
      this.left_List_Data = this.allListDataTwo.filter((item) => {
        return item.name.indexOf(this.searchValue.toUpperCase()) !== -1;
      });
    },
 
    //获取自选币种列表
    getItemOptionalList() {
      Axios.getItemOptionalStatus().then((res) => {
        this.collectList = res.data;
      });
    },
    //字母排序
    sortLetterList(propertyName) {
      return function sortList(object1, object2) {
        const value1 = object1[propertyName];
        const value2 = object2[propertyName];
        if (value2 < value1) {
          return 1;
        }
        if (value2 > value1) {
          return -1;
        }
        return 0;
      };
    },
    sortLetterTwoList(propertyName) {
      return function sortList(object1, object2) {
        const value1 = object1[propertyName];
        const value2 = object2[propertyName];
        if (value2 > value1) {
          return 1;
        }
        if (value2 < value1) {
          return -1;
        }
        return 0;
      };
    },
    //数字排序
    orderListAsc(filed, type = "asc") {
      return (a, b) => {
        if (type == "asc") return a[filed] > b[filed] ? 1 : -1;
        return a[filed] > b[filed] ? -1 : 1;
      };
    },
    addTime(item) {
      if (!this.times.includes(item)) {
        this.times.push(item);
      } else {
        const index = this.times.findIndex((el) => el === item);
        this.times.splice(index, 1);
      }
    },
    getAllSymbolData(val) {
      this.listData = this[`${this.pageType}Currency`]
        .map((val) => {
          return val?.symbol;
        })
        .join(","); //获取查询币种
      this.Hotcurrency = this[`${this.pageType}Currency`].filter((vals) => {
        return vals.isTop == "1";
      });
      clearInterval(this.currentTimer);
      const allCions = this.listData;
      this.getRealTimeData(allCions, val);
      this.currentTimer = setInterval(() => {
        this.getRealTimeData(allCions, val);
      }, 1000); //轮训pageData会变化
    },
    //  获取币种的实时数据
    getRealTimeData(val, search) {
      console.log('获取币种的实时数据',val)
      Axios.getRealtime({ symbol: 'btc,plcl,eth,bnb,ada,omg,xtz,sol,xrp,doge,' +
            'avax,link,ltc,algo,bch,luna,uni,icp,etc,fil,xlm,atom,matic,theta,' +
            'trx,ftt,bsv,eos,dai,comp,saga,prcl,tnsl' }).then((res) => {
        if (res.code == "0") {
          var data = res.data;
          const curCoin = this.$route.params.id || this.defaultSymbol;
          var filtersVal = data.filter((val) => val.symbol == curCoin);
          this.pageData = filtersVal[0]; //页面展示的数据
          this.allListData = data; //所有的交易对
          this.allListDataTwo = data; //热门搜索
          for (let i = 0; i < this.allListData.length; i++) {
            this.allListData[i].isCollect = false;
          }
          this.allListData.map((item1) => {
            // 收藏
            this.collectList.map((item2) => {
              if (item1.symbol == item2.symbol) {
                item1.isCollect = true;
              }
            });
          });
          for (let i = 0; i < this.allListDataTwo.length; i++) {
            this.allListData[i].isCollect = false;
          }
          this.allListDataTwo.map((item1) => {
            // 历史搜索
            this.collectList.map((item2) => {
              if (item1.symbol == item2.symbol) {
                item1.isCollect = true;
              }
            });
          });
          //是否过滤
          if (this.isFilter) {
            this.allListData = this.allListData.filter((item) => {
              return item.name.indexOf(this.filterValue.toUpperCase()) !== -1;
            });
          }
 
          if (this.sortIndex == 1) {
            //字母正序
            this.allListData = this.allListData.sort(
              this.sortLetterList("symbol")
            );
          }
          if (this.sortIndex == 2) {
            this.allListData = this.allListData.sort(
              this.sortLetterTwoList("symbol")
            );
          }
          if (this.sortIndex == 3) {
            this.allListData = this.allListData.sort(
              this.orderListAsc("close")
            );
          }
          if (this.sortIndex == 4) {
            this.allListData = this.allListData.sort(
              this.orderListAsc("close", "ask")
            );
          }
          if (this.sortIndex == 5) {
            this.allListData = this.allListData.sort(
              this.orderListAsc("change_ratio")
            );
          }
          if (this.sortIndex == 6) {
            this.allListData = this.allListData.sort(
              this.orderListAsc("change_ratio", "ask")
            );
          }
          if (this.isCollectShow) {
            //获取收藏列表
            this.allListData = this.allListData.filter((item) => {
              return item.isCollect;
            });
          }
        }
      });
    },
    search() {
      if (this.searchData) {
        if (this.listData.indexOf(this.searchData.toLowerCase()) == -1) {
          clearInterval(this.currentTimer);
          this.left_List_Data.length = 0;
        } else {
          this.getAllSymbolData(this.searchData.toLowerCase());
        }
      }
    },
    technoIndex() {
      this.$refs.kline_dialog.close();
    },
    tabMap(index) {
      this.mapIndex = index;
      this.loading = true;
    },
    // 币种信息头部
    tabItemLeft(item) {
      this.Trade.close();
      this.deep.close();
      this.openTime.close();
      this.initWebSocket(item.symbol);
      this.$router.push(`/${this.pageType}/spot/${item.symbol}`); //刷新页面
    },
    changeKTime(item) {
      this.loading = true;
      if (item.data != "minHour") {
        this.kParamsTime = item.data;
        this.klineIndex = "";
      } else {
        // 分时图,klineIndex为面积,参数kParamsTime不变保留上次的参数,this.kTimeIndex且为分时
        this.klineIndex = "minHour";
      }
      this.kTimeIndex = item.data; //
    },
    // 获取K线数据
    getKlineData() {
      let symbol = this.$route.params.id || this.defaultSymbol;
      AxiosKline.getKline({
        symbol: symbol,
        line: this.kParamsTime,
      }).then((res) => {
        if (this.mapIndex == 0) {
          setTimeout(() => {
            this.loading = false;
          }, 500);
        }
        if (res.code == "0") {
          this.KLInedata = res.data.map((val) => {
            return {
              close: val.close,
              high: val.high,
              low: val.low,
              open: val.open,
              timestamp: val.ts,
              volume: val.volume,
            };
          });
        }
      });
    },
 
    // 监听买卖数据=orderbook
    getTradeMessage({ data }) {
      if (data) {
        var TradeData = JSON.parse(data);
        console.log(TradeData,'TradeData')
        if (TradeData.code == "0") {
          this.rightData = TradeData.data.data;
 
          var filterData = this.rightData.map((val) => {
            return val.amount;
          });
          this.bigIndex = Math.max(...filterData);
          this.filterTop = this.rightData.filter((val) => {
            return val.direction == "buy";
          });
          this.filterDown = this.rightData.filter((val) => {
            return val.direction == "sell";
          });
          this.filterTop = this.filterTop.slice(0, 7);
          this.filterDown = this.filterDown.slice(0, 7);
        }
      }
    },
    // 监听买卖价格 数据
    getDeepMessage({ data }) {
      setTimeout(() => {
        this.loading = false;
      }, 500);
      var deepData = JSON.parse(data);
      if (deepData.code == "0") {
        this.deepBuy = deepData?.data?.bids;
        this.deepSell = deepData?.data?.asks;
      }
    },
    mathDatarandomFun(val) {
      var a = Number(val);
      var b = Math.round(Math.random() * 10) / 100;
      var data = math.format(a + b, 6);
      return data;
    },
    initWebSocket(val) {
      const paramVal = this.$route.params.id || this.defaultSymbol;
      const param = !val ? paramVal : val;
      this.Trade = new WhrWebSocket({
        path: `${ConfigURL.WS_URL}/2/${param}`,
        onmessage: this.getTradeMessage,
      });
      this.deep = new WhrWebSocket({
        path: `${ConfigURL.WS_URL}/3/${param}`,
        onmessage: this.getDeepMessage,
      });
      this.Trade.init();
      this.deep.init();
      this.openTime = new WhrWebSocket({
        path: `${ConfigURL.WS_URL}/1/${param}`,
        onmessage: this.getOpenTmeMessage,
      });
      this.openTime.init();
    },
    getOpenTmeMessage({ data }) {
      var openTimeData = JSON.parse(data);
      if (openTimeData.code == "0") {
        this.symbolMarketInfo = openTimeData.data[0];
      }
    },
 
    handleChangeClickData(val) {
      this.clickData = val;
    },
  },
};
</script>
 
<style>
@import url("@/assets/css/commonTrade/quotes.css");
 
.home-container {
  width: 100%;
  margin: 0 auto;
  border: 1px solid #24272c;
  border-bottom: none;
}
 
.trade-header-box {
  background: #171a1e !important;
  border-bottom: 1px solid #24272c !important;
}
 
.trade-header-box-full {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 65px;
  background: #171a1e;
  z-index: 3000000;
  padding: 10px 0;
}
 
.k-toolbar-wrap-full {
  position: fixed;
  top: 85px;
  left: 0;
  width: 100%;
  height: 32px;
  background: #171a1e;
  z-index: 30;
}
 
.line {
  width: 1px;
  height: 42px;
  margin: 0 20px;
  background: #24272c;
}
 
.fs-16 {
  font-size: 16px;
}
 
.drop-down-time {
  box-sizing: border-box;
  position: absolute;
  width: 300px;
  height: 220px;
  top: 33px;
  background: #1f2328;
  border: 1px solid #30353c;
  border-radius: 5px;
  z-index: 10;
  padding: 15px 12px;
  font-size: 12px;
  display: block;
}
.kTimeDivider {
  width: 1px;
  height: 30px;
  margin-right: 20px;
  background: #24272c;
}
 
.select-cycle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: #929aa5;
  margin-bottom: 5px;
}
 
.select-cycle span {
  cursor: pointer;
}
 
.is-cycle {
  color: #1d91ff !important;
}
 
.is-times {
  color: #1d91ff !important;
  background: #243046 !important;
}
 
.times {
  width: 100%;
  justify-content: space-between;
  flex-wrap: wrap;
}
 
.times span {
  cursor: pointer;
  margin-top: 10px;
  width: 60px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  background: #363b41;
  border-radius: 2px;
  color: #ffffff;
}
.status-info {
  padding: 4px 8px;
  border-radius: 4px;
  margin-right: 4px;
  background: #303133;
  color: #fff;
}
 
.value-select {
  position: absolute;
  top: 20px;
  z-index: 100;
}
 
.value-select p {
  width: 64px;
  height: 43px;
  background: #1f2328;
  border-radius: 3px;
  text-align: center;
  line-height: 43px;
}
 
.zhibiao {
  position: absolute;
  left: -60px;
  top: 30px;
  width: 380px;
  background: #1f2328;
  border-radius: 5px;
  z-index: 1000;
  flex-wrap: wrap;
}
 
.zhi-hd {
  padding: 26px 20px;
  font-size: 20px;
  color: #b3b5bd;
  display: flex;
  justify-content: space-between;
  width: 100%;
}
 
.zhi-search {
  width: 100%;
  padding: 10px 0;
  border-top: 1px solid rgb(54, 56, 65);
  border-bottom: 1px solid rgb(54, 56, 65);
}
 
::v-deep .zhi-search .el-input__inner {
  background: #1f2328;
  border-radius: 0;
  border: none;
}
 
.zhi-main {
  padding: 26px 20px;
  flex-wrap: wrap;
}
 
.jb-title {
  font-size: 12px !important;
  color: #797b85 !important;
}
 
.zhi-main p {
  width: 100%;
  color: #b3b5bd;
  font-size: 14px;
  margin: 10px 0;
}
 
.mt-200 {
  margin-top: 200px;
}
 
.react-grid-layout {
  height: 1055px;
}
 
.fullscreen-box {
  position: fixed !important;
  left: 0;
  top: 0;
  width: 100% !important;
  height: 100% !important;
}
 
::v-deep .el-loading-spinner i {
  color: #fff !important;
  font-size: 40px;
}
 
.chart-wrapper {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid #24272c;
}
 
.chart-item {
  cursor: pointer;
  background: #363b41;
  border-radius: 2px;
  color: #ccc;
  padding: 6px 18px;
  margin-left: 12px;
}
 
.chart-item-active {
  color: #1d91ff;
}
</style>