dcc
2024-06-13 3616db170333df7d668c97323344335b52c4153c
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
<template>
  <div class="ticker-top-box">
    <div class="ticker-item ml-41">
      <span
        :class="[
          'label',
          'fs-16',
          pageData?.change_ratio > 0 ? 'color-up' : 'color-down',
        ]"
        >{{ pageData?.close }}</span
      >
      <span class="value">${{ pageData?.close }}</span>
    </div>
    <div class="ticker-item ml-41">
      <span class="label">{{ t("message.home.24xiaoshizhangdie") }}</span
      ><span
        :class="[
          'value',
          pageData?.change_ratio > 0 ? 'color-up' : 'color-down',
        ]"
        >{{ pageData?.change_ratio > 0 ? "+" : ""
        }}{{ pageData?.change_ratio }}%</span
      >
    </div>
    <div class="ticker-item ml-41">
      <span class="label">24h{{ t("message.home.zuigao") }}</span>
      <span class="value">{{ pageData?.high }}</span>
    </div>
    <div class="ticker-item ml-41">
      <span class="label">24h{{ t("message.home.zuidi") }}</span>
      <span class="value">{{ pageData?.low }}</span>
    </div>
    <div class="ticker-item ml-41">
      <span class="label"
        >24h{{ t("message.home.liang") }}({{ getAmountUnit }})</span
      >
 
      <span class="value">{{ getAmount }} </span>
    </div>
    <div class="ticker-item ml-41">
      <span class="label"
        >24h{{ t("message.home.e") }}({{
          t(`${unitMap.volumn[pageType]}`)
        }})</span
      ><span class="value">{{ getVolume }}</span>
    </div>
  </div>
</template>
<script setup>
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const props = defineProps({
  pageData: {
    type: Object,
    default: {},
  },
  pageType: {
    type: String,
    default: "etf",
  },
});
 
const unitMap = {
  amount: {
    etf: "message.home.wangu",
    usStocks: "message.home.wangu",
    twStocks: "message.home.wangu",
    cnStocks: "message.home.wangu",
    hkStocks: "message.home.wangu",
    coin: "",
    forex: "",
  }, //成交量,数字货币和外汇用当前币种
  volumn: {
    etf: "message.home.wan",
    usStocks: "message.home.wan",
    cnStocks: "message.home.wan",
    hkStocks: "message.home.wan",
    twStocks: "message.home.wan",
    forex: "USD",
    coin: "USDT",
  }, //成交额
};
 
const getAmountUnit = computed(() => {
  if (props.pageType === "coin") {
    return props.pageData?.symbol_data.toUpperCase();
  }
  if (["usStocks", "etf"].includes(props.pageType)) {
    return t(`${unitMap.amount[props.pageType]}`);
  }
  // etf
  return props.pageData?.symbol.toUpperCase();
});
 
const getVolume = computed(() => {
  const volume = props.pageData?.volume;
 
  if (volume) {
    const val = ["usStocks", "etf"].includes(props.pageType)
      ? volume / 10000
      : volume;
    return Number(val).toFixed(4);
  }
  return "--";
});
 
const getAmount = computed(() => {
  const amount = props.pageData?.amount;
  if (amount) {
    const val = ["usStocks", "etf"].includes(props.pageType)
      ? amount / 10000
      : amount;
    return Number(val).toFixed(4);
  }
  return "--";
});
</script>
<style>
/* TODO  */
 
.trade-header-box .ticker-xl-box .ticker-top-box .ml-41 {
  margin-left: 41px;
}
</style>