10.10综合交易所原始源码_移动端
admin
2026-01-06 04d8c6bfd48267c7b2eaccaa03170618d83e4cbd
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
<template>
  <div class="pb-fix">
    <van-loading color="#1194F7" class="loading-box" v-if="isLoading && isFirst" />
    <div class="container-box">
      <header class="header">
        <div class="icon-group">
          <div class="icon back" @click="onRoute('/quotes/index?tabActive=2')">
            <van-icon name="arrow-left" size="20" />
          </div>
          <div class="icon search" @click="onRoute('/foreign/search')">
            <img src="@/assets/image/optional/search.png" alt="">
          </div>
        </div>
        <div class="title">{{ t('Market') }}</div>
      </header>
      <div class="tabs flex">
        <div class="tab-item flex-1" v-for="(item, index) in tabList" @click="selectIndex(index, item)"
          :class="[tabIndex === index ? 'active' : '']" :key="item">
          {{ item.title }}
        </div>
      </div>
      <div class="symbol-table">
        <ul>
          <li v-for="(item, index) in listData" :key="item.symbol" @click="itemClick(item)">
            <div class="flex-l">
              <p>
                <span class="mr-1" :class="item.changeRatio > 0 ? 'text-up' : 'text-down'" v-if="item.netChange > 0">+{{
                  item.netChange }}</span>
                <span class="mr-1" :class="item.changeRatio > 0 ? 'text-up' : 'text-down'" v-else>{{ item.netChange
                }}</span>&nbsp;
                <span :class="item.changeRatio > 0 ? 'text-up' : 'text-down'">{{ `${item.changeRatio}%` }}</span>
              </p>
              <p>{{ item.symbol.toUpperCase() }}</p>
              <p class="gray-text">{{ item.current_time ? item.current_time.slice(11) : '-' }}</p>
            </div>
            <div class="flex-r">
              <div class="flex justify-end h-full flex-wrap">
                <div class="flex-r-item">
                  <p class="flex text-primary justify-end" :class="item.open < 1 ? 'text-up' : 'text-down'">
                    <span class="font-semibold text-lg">{{
                      item.open.toString().substr(0, item.open.toString().length
                        - 1)
                    }}</span>
                    <span class="text-xs">{{ item.open.toString().substr(item.open.toString().length - 1) }}</span>
                  </p>
                  <div class="text-gray">
                    <span class="mr-1.5">H: {{ item.high }}</span>
                  </div>
                </div>
                <div class="last flex-r-item">
                  <p class="flex text-primary justify-end" :class="item.close < 1 ? 'text-up' : 'text-down'">
                    <span class="font-semibold text-lg">{{
                      item.close.toString().substr(0, item.close.toString().length
                        - 1)
                    }}</span>
                    <span class="text-xs">{{ item.close.toString().substr(item.close.toString().length - 1) }}</span>
                  </p>
                  <div class="text-gray">
                    <span>L: {{ item.low }}</span>
                  </div>
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
 
<script setup>
import { ref, onMounted, onBeforeUnmount } from "vue";
import { _getRealtimeByType, _ItemUserOptionalItemAdd } from '@/service/quotes.api'
import { useQuotesStore } from '@/store/quotes.store'
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
 
const { t } = useI18n()
const router = useRouter()
const tabIndex = ref(0)
const listData = ref([])
const interval = ref(null)
const type = ref('forex') //默认查询外汇
const category = ref('forex') //默认查询外汇
const tabList = ref([
  { title: t('外汇'), category: "forex", type: "forex" },
  { title: t('大宗商品'), category: "commodities", type: "forex" },
  { title: t('指数'), category: "indices", type: "forex" },
  { title: t('加密货币'), category: "cryptos", type: "cryptos" },
])
const isLoading = ref(false)
const isFirst = ref(true)
 
onMounted(() => {
  fetchQuotes()
  interval.value = setInterval(() => {
    fetchQuotes()
  }, 3000)
})
 
onBeforeUnmount(() => {
  if (interval.value) {
    clearInterval(interval.value)
  }
})
 
const fetchQuotes = () => {
  isLoading.value = true
  _getRealtimeByType({
    type: type.value,
    category: category.value,
    pageNo: 1
  }).then(data => {
    isLoading.value = false
    isFirst.value = false
    listData.value = data
  }).catch((e) => {
    isLoading.value = false
    isFirst.value = true
    listData.value = []
  })
 
}
 
const itemClick = (item) => {
  router.push({ path: '/foreign/coinChart', query: { symbol: item.symbol } })
}
 
const onRoute = (path) => {
  router.push(path)
}
 
const selectIndex = (index, item) => {
  tabIndex.value = index
  type.value = item.type
  category.value = item.category
  fetchQuotes()
}
 
</script>
 
<style lang="scss" scoped>
:deep(.van-loading) {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
}
 
:deep(.van-nav-bar__title) {
  position: relative;
  top: 2px;
  max-width: 72%;
}
 
:deep(.van-nav-bar__title) {
  flex: 1;
}
 
:deep(.van-field__control) {
  font-size: 16px;
  font-weight: 500;
  caret-color: #3157BE;
}
 
.container-box {
  padding: 0 16px;
 
  .header {
    .title {
      margin: 30px 0;
      font-weight: 600;
      font-size: 31px;
      color: $text_color;
    }
 
    .icon-group {
      display: flex;
      justify-content: space-between;
 
      .icon {
        display: inline-block;
        width: 36px;
        height: 36px;
        padding: 8px;
      }
    }
  }
 
  .tabs {
    background-color: $US_tab_background;
    border-radius: 20px;
    height: 42px;
    line-height: 26px;
    color: #BBBCBD;
 
    .tab-item {
      margin: 4px;
      text-align: center;
      padding: 4px 6px;
      font-size: 14px;
      color: $text_color5;
      font-weight: 700;
    }
 
    .active {
      color: #FBFCFD !important;
      background: $blue;
      border-radius: 16px;
      background-size: cover;
    }
  }
 
  .symbol-table {
    li {
      margin-top: 20px;
      display: flex;
      font-weight: 600;
      font-size: 14px;
      line-height: 18px;
 
      .gray-text {
        color: #BCBDC2;
        font-size: 12px;
      }
 
      .flex-l {
        width: 130px;
      }
 
      .flex-r {
        flex: 1;
 
        .flex-r-item {
          flex: 1;
          align-self: center;
          text-align: right;
 
          .last-item {
            padding: 0 6px;
 
            p {
              text-align: right;
              width: 70px;
              height: 24px;
              line-height: 24px;
              border-radius: 4px;
              color: $text_color;
              font-weight: 600;
              font-size: 14px;
            }
          }
        }
 
        .last {}
      }
    }
  }
 
 
}
</style>