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
<template>
  <div class="list-quatation">
    <mg-tabs @tabs="onTabs"></mg-tabs>
    <van-list>
      <van-cell class="tab">
        <div class="flex items-center w-full text-grey text-26">
          <p class="left text-left">
            <span>{{ $t('名称代码') }}
            </span>
          </p>
          <p class="mid text-right">
            {{ $t('盘前涨跌幅') }}
          </p>
          <p class="right text-right">
            {{ $t('盘前价') }}
          </p>
        </div>
      </van-cell>
      <transition-group :name="type" tag="div">
        <div class="groupItem" :key="active">
          <van-cell v-for="item in showList" :key="item.id">
            <ul class="flex justify-evenly w-full items-center" @click="onItemClick(item)">
              <li class="flex items-center mid">
                <p class="flex flex-col items-start">
                  <span class="text-28 text-left text-color name"> {{ item.name || '--' }} </span>
                  <span class="flex text-24 flex items-center text-left leading-0.2 fullname">{{ item.symbolFullName ||
                    '--' }}</span>
                </p>
              </li>
              <li class="flex flex-col mid">
                <p class="w-40 text-32 h-18 text-color bg-green border-0 text-center" v-if="item.changeRatio > 0">
                  +{{ item.changeRatio }}%</p>
                <p class="w-40 text-32 h-18 text-color bg-red border-0 text-center btn" v-else>
                  {{ item.changeRatio || (item.changeRatio === 0 ? 0 : '--') }}%</p>
              </li>
              <li class="right flex items-center justify-end">
                <p class="text-color">
                  {{ item.close || '--' }}
                </p>
              </li>
            </ul>
          </van-cell>
        </div>
      </transition-group>
    </van-list>
  </div>
</template>
  
<script>
import { List, Cell } from 'vant'
import { mapGetters, mapActions } from 'vuex'
import { fixDate, setStorage } from "@/utils";
import MgTabs from "@/components/Transform/mg-tabs/index.vue";
import { HOST_URL } from '@/config'
import { SET_CURRENCY } from "@/store/const.store";
export default {
  name: 'MgQuotation',
  data() {
    return {
      fixDate,
      HOST_URL,
      active: 0,
      type: 'left' //left 从左往右 right 从有王座
    }
  },
  props: {
    showMore: {
      type: Boolean,
      default: true
    },
    listData: {
      type: Array,
      default() {
        return []
      }
    },
    tabActive: {
      type: Number,
      default: 0
    },
  },
  computed: {
    ...mapGetters({ currency: 'home/currency' }),
  },
  components: {
    [List.name]: List,
    [Cell.name]: Cell,
    MgTabs
  },
  mounted() {
    this.SET_CURRENCY()
  },
  methods: {
    ...mapActions('home', [SET_CURRENCY]),
    onItemClick(item) {
      if (this.tabActive == 2) { //现货
        this.$router.push({
          path: `/cryptos/trade/${item.symbol}`
        });
      } else {
        setStorage('symbol', item.symbol)
        this.$router.push({
          path: `/cryptos/perpetualContract/${item.symbol}`,
          query: { type: 'US-stocks' }
        });
      }
    },
    handleImage(url) {
      return new URL(url, import.meta.url).href
    },
    onTabs(val) {
      if (this.active < val) {
        this.type = 'right'
      } else {
        this.type = 'left'
      }
      this.active = val
      if (val == 0) {
        this.showList = [...this.listData];
      } else if (val == 1) {
        this.showList = [...this.listData].sort(this.compare("changeRatio", 'up'))
      } else if (val == 2) {
        this.showList = [...this.listData].sort(this.compare("changeRatio", 'down'))
      }
    },
    compare(p, type) { //这是比较函数
      return function (m, n) {
        var a = m[p];
        var b = n[p];
        if (a == b) {
          return
        }
        if (type == 'up') {
          return b - a; //升序
        } else if (type == 'down') {
          return a - b; //降序
        } else {
          return a - b;
        }
      }
    }
  },
  watch: {
    listData() {
      if (this.active == 0) {
        this.showList = [...this.listData];
      } else if (this.active == 1) {
        this.showList = [...this.listData].sort(this.compare("changeRatio", 'up'))
      } else if (this.active == 2) {
        this.showList = [...this.listData].sort(this.compare("changeRatio", 'down'))
      }
      this.$forceUpdate()
    }
  }
}
</script>
<style lang="scss" scoped>
.text-color {
  color: $text_color;
}
 
.left-enter-active,
.left-leave-active,
.right-enter-active,
.right-leave-active {
  will-change: transform;
  transition: all 250ms;
}
 
.left-leave-active,
.right-leave-active {
  display: none;
}
 
.left-enter {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}
 
.left-leave {
  opacity: 0;
  transform: translate3d(0%, 0, 0)
}
 
.right-enter {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}
 
.right-leave {
  opacity: 0;
  transform: translate3d(0%, 0, 0)
}
 
.btn {
  border-radius: 9px;
  line-height: 71px;
}
 
.left {
  flex: 1;
}
 
.mid {
  flex: 1;
  text-align: center;
}
 
.right {
  flex: 1;
  // margin-left: 38px;
}
 
.tab {
  background-color: $mainBgColor;
}
 
.groupItem {
  :deep(.van-cell) {
    height: 120px;
    background-color: $mainBgColor;
 
    ul {
      align-items: center;
      height: 100%;
    }
 
    li p {
      line-height: 34px;
    }
 
    .name,
    .fullname {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 260px;
    }
  }
 
  .bg-green {
    color: #06CDA5;
  }
 
  .bg-red {
    color: #F43368;
  }
 
 
}
 
:deep(.van-cell::after) {
  border-bottom: 1px solid $border_color !important;
}
</style>