lxf
2025-07-16 8588fe30f17d0d28190a279aab8675de0dbf1a5b
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
<template>
  <div class="list-quatation">
    <van-list>
      <!-- 热门 -->
      <div class="flex items-end justify-between" style="margin: 14px 0;">
        <div class="block text-22 font-medium">{{ t('Market') }}</div>
        <div class="relative text-13" @click="toggleDropdown">
          <div class="flex px-20 justify-between rounded-full bg-black text-white min-w-140 box-border">
            <div class="block">{{ t(topTitle) }}</div>
            <van-icon name="play" style="align-content:center;transform: rotate(90deg);" />
          </div>
          <div
            class="px-16 py-20 bg-black text-white flex flex-col absolute min-w-140 box-border top-25 rounded-11 leading-28"
            style="z-index:999;margin-top: 0.8rem;" v-show="isTopShow">
            <div @click="changeType(t('货币兑换'), 2)">{{ t('货币兑换') }}</div>
            <div @click="changeType(t('外汇交易'), 1)">{{ t('外汇交易') }}</div>
          </div>
        </div>
      </div>
 
 
      <transition-group :name="type" tag="div">
        <div>
          <van-cell v-for="item in showList" :key="item.id" style="background-color: #f0f0f0;margin-bottom: 10px;">
            <ul class="flex justify-between w-full items-center" @click="onItemClick(item)">
              <li class="flex items-center left">
                <img
                  :src="item.symbol ? `${HOST_URL}/symbol/${item.symbol_data}.png` : handleImage('@/assets/loading-default.png')"
                  alt="logo" class="w-72 h-72 mr-16" />
                <p class="flex flex-col">
                  <span class="flex items-end font-32 flex items-center">
                    <span class="textColor font-600 font-30">{{ item.name || '--'
                    }}</span>
                  </span>
                  <span class="font-24 text-grey text-left">{{ (item.amount * 1).toFixed(2) }}</span>
                </p>
              </li>
              <li class="flex flex-col items-end mid">
                <p class="textColor font-32 font-600">{{ item.close || '--' }}</p>
              </li>
              <li class="right flex items-center justify-end">
                <p class="w-153 font-31 h-71 text-white border-0 text-center btn"
                  :class="item.change_ratio > 0 ? 'bg-green' : 'bg-red'">
                  {{ item.change_ratio === 0 ? 0 : item.change_ratio }}%
                </p>
              </li>
            </ul>
          </van-cell>
        </div>
      </transition-group>
    </van-list>
  </div>
</template>
<script setup>
import { ref, computed, onMounted, watch } from 'vue';
import { useStore } from 'vuex';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { List, Cell, Icon } from 'vant';
import { fixDate, setStorage } from "@/utils";
import ExTabs from "@/components/Transform/ex-tabs/index.vue";
import { HOST_URL } from '@/config';
import { SET_CURRENCY } from "@/store/const.store";
 
// 状态定义
const isTopShow = ref(false);
const topTitle = ref('');
const topValue = ref(2);
const type = ref('left');
const active = ref(0);
const showList = ref([]);
 
// 依赖注入
const store = useStore();
const { t } = useI18n();
const router = useRouter();
 
// Props定义
const props = defineProps({
  showMore: {
    type: Boolean,
    default: true
  },
  listData: {
    type: Array,
    default: () => []
  },
  tabActive: {
    type: Number,
    default: 0
  }
});
 
// Emits定义
const emit = defineEmits(['onfetchQList']);
 
// 计算属性
const currency = computed(() => store.getters['home/currency']);
 
// 生命周期
onMounted(() => {
  topTitle.value = t('货币兑换');
  store.dispatch('home/' + SET_CURRENCY);
  showList.value = [...props.listData];
});
 
// 方法定义
const changeType = (tit, val) => {
  topTitle.value = tit;
  topValue.value = val;
  emit('onfetchQList', val);
};
 
const toggleDropdown = () => {
  isTopShow.value = !isTopShow.value;
};
 
const onItemClick = (item) => {
  setStorage('symbol', item.symbol);
  if (topValue.value === 2) {
    router.push({
      path: `/cryptos/perpetualContract/${item.symbol}`,
      query: { selectIndex: 2 }
    });
  } else {
    router.push({
      path: `/cryptos/trade/${item.symbol}`
    });
  }
};
 
const handleImage = (url) => {
  return new URL(url, import.meta.url).href;
};
 
const onTabs = (val) => {
  type.value = active.value < val ? 'right' : 'left';
  active.value = val;
  sortListData(val);
};
 
const compare = (p, sortType) => {
  return (m, n) => {
    const a = m[p];
    const b = n[p];
    if (a === b) return 0;
    return sortType === 'up' ? b - a : a - b;
  };
};
 
const sortListData = (val) => {
  switch(val) {
    case 0:
      showList.value = [...props.listData];
      break;
    case 1:
      showList.value = [...props.listData].sort(compare('change_ratio_str', 'up'));
      break;
    case 2:
      showList.value = [...props.listData].sort(compare('change_ratio_str', 'down'));
      break;
    case 3:
      showList.value = [...props.listData].sort(compare('volume', 'up'));
      break;
  }
};
 
// 监听器
watch(
  () => props.listData,
  () => {
    sortListData(active.value);
  },
  { deep: true }
);
</script>
<style lang="scss" scoped>
@import "@/assets/init.scss";
@import '@/assets/css/deepseek_css_20250625_30ff932.css';
 
#cryptos {
 
  .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 {
    width: 382px
  }
 
  .mid {
    width: 185px;
  }
 
  .right {
    width: 182px;
    margin-left: 38px;
  }
 
}
 
.textColor {
  color: #242629;
}
 
.text-grey {
  // color: #8c8c8c;
}
 
#cryptos .list-quatation .van-cell {
  padding: 24px !important;
  border-radius: 1rem;
}
 
.list-quatation {
  margin: 0 20px;
}
</style>