lxf
2025-07-08 b37eef5a0807a8f5688e2112591cb80a3ba333e4
src/components/Transform/list-quotation/index.vue
@@ -1,27 +1,42 @@
<template>
  <div class="list-quatation">
    <ex-tabs @tabs="onTabs"></ex-tabs>
    <!-- <ex-tabs @tabs="onTabs"></ex-tabs> -->
    <van-list>
      <van-cell>
      <!-- <van-cell>
        <div class="flex items-center w-full text-grey font-26">
          <p class="left text-left">
            <span>{{ $t('交易对') }}
              <!--                      <img src="./icon-sort.png" alt="icon" class="w-13 h-22"/>-->
            </span>
          </p>
          <p class="mid text-right">
            {{ $t('最新价') }}
            <!--                  <img src="./icon-sort.png" alt="icon" class="w-13 h-22 ml-5"/>-->
          </p>
          <p class="right text-right">
            {{ active == 3 ? $t('成交额') : $t('24h涨跌幅') }}
            <!--                  <img src="./icon-sort.png" alt="icon" class="w-13 h-22 ml-5"/>-->
          </p>
        </div>
      </van-cell>
      </van-cell> -->
      <!-- 热门 -->
      <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-100 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-100 box-border top-25 rounded-11 leading-28" style="z-index:999;margin-top: 0.8rem;" v-show="isTopShow">
            <div @click="changeType('币币交易', 1)">{{ $t('币币交易') }}</div>
            <div @click="changeType('外汇交割', 2)">{{ $t('外汇交割') }}</div>
            <!-- <div>期貨</div>
            <div>收藏</div> -->
          </div>
        </div>
      </div>
      <transition-group :name="type" tag="div">
        <div v-if="active == 0" :key="active">
          <van-cell v-for="item in listData" :key="item.id">
          <van-cell v-for="item in listData" :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
@@ -29,11 +44,11 @@
                  alt="logo" class="w-72 h-72 rounded-full 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.symbol_data && item.symbol_data.toUpperCase() || '--'
                    <span class="textColor font-600 font-30">{{ item.name || '--'
                    }}</span>
                    <span class="font-24 text-grey" style="position: relative; top: 1px">
                    <!-- <span class="font-24 text-grey" style="position: relative; top: 1px">
                      /USDT
                    </span>
                    </span> -->
                    <!-- <span class="font-24 text-grey" style="position: relative; top: 1px">
                      {{ item.name && item.name.replace(item.symbol.toUpperCase(), '') || '--' }}</span> -->
                  </span>
@@ -42,15 +57,15 @@
              </li>
              <li class="flex flex-col items-end mid">
                <p class="textColor font-32 font-600">{{ item.close || '--' }}</p>
                <p class="font-24 text-grey">{{ currency.currency_symbol }}
                <!-- <p class="font-24 text-grey">{{ currency.currency_symbol }}
                  {{ item.close && item.symbol_data.toUpperCase() == 'SHIB' ? (item.close * currency.rate).toFixed(8) : (item.close *
                    currency.rate).toFixed(2) || '--' }}</p>
                    currency.rate).toFixed(2) || '--' }}</p> -->
              </li>
              <li class="right flex items-center justify-end">
                <p class="w-153 font-31 h-71 bg-green text-white border-0 text-center btn" v-if="item.change_ratio > 0">
                  +{{ item.change_ratio || (item.change_ratio === 0 ? 0 : '--') }}%</p>
                <p class="w-153 font-31 h-71 bg-green text-white border-0 text-center btn" v-if="item.change_ratio_str > 0">
                  {{ (item.change_ratio_str === 0 ? 0 : item.change_ratio_str) }}%</p>
                <p class="w-153 font-31 h-71 bg-red text-white border-0 text-center btn" v-else>
                  {{ item.change_ratio || (item.change_ratio === 0 ? 0 : '--') }}%</p>
                  {{ (item.change_ratio_str === 0 ? 0 : item.change_ratio_str) }}%</p>
              </li>
            </ul>
          </van-cell>
@@ -67,27 +82,27 @@
                    }}</span>
                    <!-- <span class="font-24 text-grey" style="position: relative; top: 1px">
                      {{ item.name && item.name.replace(item.symbol.toUpperCase(), '') || '--' }}</span> -->
                    <span class="font-24 text-grey" style="position: relative; top: 1px">
                    <!-- <span class="font-24 text-grey" style="position: relative; top: 1px">
                      /USDT
                    </span>
                    </span> -->
                  </span>
                  <span class="font-24 text-grey text-left">{{ $t('成交量') + ' ' + (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>
                <p class="font-24 text-grey">{{ currency.currency_symbol }} {{ item.close && item.symbol_data.toUpperCase() == 'SHIB' ? (item.close * currency.rate).toFixed(8) : (item.close *
                    currency.rate).toFixed(2) || '--' }}</p>
                <!-- <p class="font-24 text-grey">{{ currency.currency_symbol }} {{ item.close && item.symbol_data.toUpperCase() == 'SHIB' ? (item.close * currency.rate).toFixed(8) : (item.close *
                    currency.rate).toFixed(2) || '--' }}</p> -->
              </li>
              <li class="right flex items-center justify-end text-right">
                <div v-if="active == 3" class="textColor w-182 font-700 font-24">
                  {{ (item.volume * 1).toFixed(2) }}
                </div>
                <template v-else>
                  <p class="w-153 font-31 h-71 bg-green text-white border-0 text-center btn" v-if="item.change_ratio > 0">
                    +{{ item.change_ratio }}%</p>
                  <p class="w-153 font-31 h-71 bg-green text-white border-0 text-center btn" v-if="item.change_ratio_str > 0 || item.change_ratio > 0">
                    +{{ item.change_ratio_str }}%</p>
                  <p class="w-153 font-31 h-71 bg-red text-white border-0 text-center btn" v-else>
                    {{ item.change_ratio || (item.change_ratio === 0 ? 0 : '--') }}%</p>
                    {{ (item.change_ratio_str === 0 ? 0 : '--') }}%</p>
                </template>
              </li>
            </ul>
@@ -101,7 +116,6 @@
    </div> -->
  </div>
</template>
<script>
import { List, Cell } from 'vant'
import { mapGetters, mapActions } from 'vuex'
@@ -109,6 +123,8 @@
import ExTabs from "@/components/Transform/ex-tabs/index.vue";
import { HOST_URL } from '@/config'
import { SET_CURRENCY } from "@/store/const.store";
// import { useI18n } from "vue-i18n";
// const t = useI18n()
export default {
  name: 'ListQuotation',
  data() {
@@ -116,6 +132,9 @@
      fixDate,
      HOST_URL,
      active: 0,
      isTopShow: false,
      topTitle: '币币交易',
      topValue: 1,
      type: 'left' //left 从左往右 right 从有王座
    }
  },
@@ -148,17 +167,41 @@
  },
  methods: {
    ...mapActions('home', [SET_CURRENCY]),
    changeType(tit, val){
      this.topTitle = tit
      this.topValue = val
      this.$emit('onfetchQList', val)
    },
    toggleDropdown(){
      if(this.isTopShow){
        this.isTopShow = false
      }else{
        this.isTopShow = true
      }
    },
    onItemClick(item) {
      if (this.tabActive == 2) { //现货
      if (this.topValue == 2) { //现货
        setStorage('symbol', item.symbol)
        this.$router.push({
          path: `/cryptos/trade/${item.symbol}`
           path: `/cryptos/perpetualContract/${item.symbol}`,
           query: { selectIndex: 2 }
        });
      } else {
        setStorage('symbol', item.symbol)
        // /cryptos/perpetualContract/btcusdt?selectIndex=2
        this.$router.push({
          path: `/cryptos/perpetualContract/${item.symbol}`,
          query: { type: 'cryptos' }
          path:`/cryptos/trade/${item.symbol}`,
          // path: `/cryptos/perpetualContract/${item.symbol}`,
          // query: { selectIndex: 2 }
        });
        //  this.$router.push({
        //   path: `/foreign/deliveryContract/${item.symbol}`,
        //   query: { type: 'cryptos' }
        // });
        // this.$router.push({
        //   path: `/cryptos/perpetualContract/${item.symbol}`,
        //   query: { type: 'cryptos' }
        // });
      }
    },
    handleImage(url) {
@@ -174,9 +217,9 @@
      if (val == 0) {
        this.showList = [...this.listData];
      } else if (val == 1) {
        this.showList = [...this.listData].sort(this.compare("change_ratio", 'up'))
        this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'up'))
      } else if (val == 2) {
        this.showList = [...this.listData].sort(this.compare("change_ratio", 'down'))
        this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'down'))
      } else if (val == 3) {
        this.showList = [...this.listData].sort(this.compare("volume", 'up'))
      }
@@ -203,9 +246,9 @@
      if (this.active == 0) {
        this.showList = [...this.listData];
      } else if (this.active == 1) {
        this.showList = [...this.listData].sort(this.compare("change_ratio", 'up'))
        this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'up'))
      } else if (this.active == 2) {
        this.showList = [...this.listData].sort(this.compare("change_ratio", 'down'))
        this.showList = [...this.listData].sort(this.compare("change_ratio_str", 'down'))
      } else if (this.active == 3) {
        this.showList = [...this.listData].sort(this.compare("volume", 'up'))
      }
@@ -216,6 +259,7 @@
</script>
<style lang="scss" scoped>
@import "@/assets/init.scss";
@import '@/assets/css/deepseek_css_20250625_30ff932.css';
#cryptos {
@@ -271,4 +315,20 @@
  }
}
.textColor {
  color: #242629;
}
.text-grey{
  // color: #8c8c8c;
}
#cryptos .list-quatation .van-cell{
  padding: 24px !important;
  border-radius: 1rem;
}
.list-quatation{
  margin: 0 20px;
}
</style>