| | |
| | | <div class="pl-30 pr-30"> |
| | | <div class="flex justify-start pt-45 before"> |
| | | <div class="flex items-center "> |
| | | <img src="@/assets/image/icon_back_1.png" class="w-35 h-35 back" alt="" @click="jump()"> |
| | | <img src="@/assets/theme/dark/image/black-convert.png" alt="convert-img" class="w-35 h-35" @click="onSidebar"> |
| | | <img src="@/assets/image/icon_back.png" class="w-35 h-35 back" alt="" @click="jump()"> |
| | | <img src="@/assets/theme/dark/image/black-convert.png" alt="convert-img" class="w-35 h-35" |
| | | @click="onSidebar"> |
| | | <div class="flex pl-21 textColor" @click="onSidebar"> |
| | | <div class="font-35">{{ symbolName.toUpperCase() || '--' }}</div> |
| | | <div class="ml-15 font-28">{{ title }}</div> |
| | | </div> |
| | | <div class="pl-10 w-160 font-28" :class="{ 'text-green': range > 0, 'text-red': range <= 0 }">{{ range > 0 ? |
| | | '+' : '' }}{{ range || '--' }}%</div> |
| | | <div class="pl-10 w-160 font-28" :class="{ 'text-green': range > 0, 'text-red': range <= 0 }">{{ range || |
| | | '--' }}%</div> |
| | | <!-- 右上角小图标 --> |
| | | <img src="@/assets/image/kline.png" class="w-44 h-44 right" alt="" @click="klineJump()"> |
| | | <img src="../../../assets/image/public/record.png" alt="record-img" class="w-64 h-35 pr-30 record-img" |
| | | @click="goHistory" /> |
| | | </div> |
| | | <!-- <div class="flex items-center"> |
| | | <img src="../../assets/image/public/k-line.png" alt="line-img" class="w-38 h-35" |
| | | @click="jump" /> |
| | | </div> --> |
| | | </div> |
| | | <!-- v-if="!selectIndex==2" --> |
| | | <div class="flex justify-between pt-34"> |
| | | <button class="tabBtn w-368 h-74 lh-74 border-none rounded" |
| | | <!-- <button class="tabBtn w-368 h-74 lh-74 border-none rounded" |
| | | :class="selectIndex == 1 ? 'select-active' : 'no-select'" @click="changeTab(1)"> |
| | | {{ $t('永续合约') }}</button> |
| | | <button class="tabBtn w-368 h-74 lh-74 border-none rounded" |
| | | {{ $t('永续合约') }}</button> --> |
| | | <!-- <button class="tabBtn w-368 h-74 lh-74 border-none rounded" |
| | | :class="selectIndex == 2 ? 'select-one-active' : 'no-select'" @click="changeTab(2)"> |
| | | {{ queryType == 'cryptos' ? $t('交割合约') : $t('期货交易') }}</button> |
| | | {{ queryType == 'cryptos' ? $t('交割合约') : $t('货币交易') }}</button> --> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | <div class="pl-42 border-b-color pt-48 pb-48"> |
| | | <div class="textColor"> |
| | | <span class="font-bold font-45 mr-12">{{ title }} {{ $t('合约') }}</span> |
| | | <span class="font-30">/{{ queryType == 'cryptos' ? 'USDT' : 'USD'}} </span> |
| | | <span class="font-30">/{{ 'USD' }} </span> |
| | | </div> |
| | | </div> |
| | | <div class="pl-42 pr-40 font-28"> |
| | |
| | | <div class="flex justify-between mb-50" v-for="item in list" :key="item.name" @click="onRoute(item)"> |
| | | <div> |
| | | <div class="textColor font-28">{{ item.name }}</div> |
| | | <div class="text-grey mt-10 font-28">{{ selectIndex == 1 ? $t('永续') : $t('交割') }}</div> |
| | | <!-- <div class="text-grey mt-10 font-28">{{ selectIndex == 1 ? $t('永续') : $t('交割') }}</div> --> |
| | | </div> |
| | | <div class="text-right"> |
| | | <div class="textColor font-28">{{ item.close }}</div> |
| | | <div class="mt-10 font-28" :class="item.change_ratio > 0 ? 'text-green' : 'text-red'">{{ item.change_ratio |
| | | }}%</div> |
| | | <div class="mt-10 font-28" :class="item.change_ratio_str > 0 ? 'text-green' : 'text-red'">{{ |
| | | item.change_ratio_str |
| | | }}%</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | import { Popup } from "vant"; |
| | | import { mapGetters } from "vuex"; |
| | | import { _getHomeList } from "@/service/home.api"; |
| | | import { useQuotesStore } from '@/store/quotes.store'; |
| | | import { THEME } from '@/config/theme' |
| | | import { setStorage } from '@/utils/utis' |
| | | import { setStorage, getStorage } from '@/utils/utis' |
| | | import { _getCoinList } from '@/service/quotes.api'; |
| | | export default { |
| | | name: "contractHeader", |
| | | props: { |
| | |
| | | }, |
| | | computed: { |
| | | ...mapGetters({ coinList: 'home/coinList' }), |
| | | ...mapGetters({ |
| | | myCoinList: 'qoutes/coinList' |
| | | }), |
| | | title() { |
| | | return [this.$t('永续'), this.$t('交割')][this.selectIndex - 1] |
| | | } |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | goHistory() { |
| | | if (this.$store.state.user.userInfo.token) { |
| | | let type = 'cryptos' |
| | | if (this.$route.query.type) { |
| | | type = this.$route.query.type |
| | | } |
| | | const url = this.topIndex / 1 === 1 ? '/cryptos/perpetualHistory' : '/cryptos/deliveryContractHistory' |
| | | this.$router.push({ |
| | | path: url, query: { symbol: this.symbol, type: type } |
| | | }); |
| | | } else { |
| | | this.$router.push('/login') |
| | | } |
| | | |
| | | }, |
| | | onRoute(item) { |
| | | if (this.$route.params.symbol !== item.symbol) { |
| | | this.$router.push(`/cryptos/perpetualContract/${item.symbol}?type=${this.queryType}`) |
| | | this.$router.push(`/cryptos/perpetualContract/${item.symbol}?selectIndex=${this.selectIndex}`) |
| | | // debugger |
| | | this.$emit('update-coin', item.symbol) |
| | | setStorage('symbol', item.symbol) |
| | | this.$forceUpdate() |
| | | } |
| | | this.show = false |
| | | }, |
| | | onSidebar() { // 侧边栏打开 |
| | | this.coins = this.coinList.map(item => item.symbol) |
| | | async onSidebar() { // 侧边栏打开 |
| | | // console.log('侧边栏打开: ', this.selectIndex) |
| | | // if (this.selectIndex == 2) { |
| | | // 优先用本地缓存的 coins |
| | | let arr = getStorage('qoutes') |
| | | let coninArr = '' |
| | | console.log('arr:', arr) |
| | | |
| | | if (arr && arr.length) { |
| | | // 如果本地有 coins,优先用本地 |
| | | arr.forEach(item => { |
| | | coninArr += item.symbol + ',' |
| | | }) |
| | | } else { |
| | | // 如果本地没有 coins,拉取接口 |
| | | const quotesData = await _getCoinList() |
| | | console.log('quotesData:', quotesData) |
| | | quotesData.forEach(item => { |
| | | coninArr += item.symbol + ',' |
| | | }) |
| | | setStorage('qoutes', { coins: quotesData }) // 存到本地 |
| | | } |
| | | this.coins = coninArr |
| | | // const quotesData = JSON.parse(localStorage.getItem('qoutes')); |
| | | // this.coins = quotesData.coins || []; |
| | | // this.coins = quotesData.coins.map(item => item.symbol) |
| | | // } else { |
| | | // this.coins = this.coinList.map(item => item.symbol); |
| | | // } |
| | | |
| | | // quotesStore.coins |
| | | |
| | | console.log(this.coins, 11111) |
| | | this.show = true |
| | | this.fetchList() |
| | | }, |
| | | fetchList() { // 获取行情 |
| | | _getHomeList(this.coins.join(',')).then(list => { |
| | | _getHomeList(this.coins).then(list => { |
| | | // console.log(list) |
| | | this.list = list |
| | | if (this.timeout) { |
| | |
| | | this.fetchList() |
| | | }, 1000) |
| | | }) |
| | | |
| | | }, |
| | | onClose() { |
| | | if (this.timeout) { |
| | |
| | | } |
| | | }, |
| | | jump() { |
| | | if (this.$route.query?.from === 'trade') { |
| | | this.$router.push('/trade/index?tabActive=1') |
| | | return |
| | | } |
| | | if (this.$route.query.type == 'indices') { |
| | | this.$router.push('/quotes/index') |
| | | } else if (this.$route.query.type == 'US-stocks') { |
| | | this.$router.push('/quotes/index?tabActive=3') |
| | | } else { |
| | | this.$router.push('/quotes/index?tabActive=1') |
| | | } |
| | | this.$router.go(-1) |
| | | // if (this.$route.query?.from === 'trade') { |
| | | // this.$router.push('/trade/index?tabActive=1') |
| | | // return |
| | | // } |
| | | // if (this.$route.query.type == 'indices') { |
| | | // this.$router.push('/quotes/index') |
| | | // } else if (this.$route.query.type == 'US-stocks') { |
| | | // this.$router.push('/quotes/index?tabActive=3') |
| | | // } else { |
| | | // this.$router.push('/quotes/index?tabActive=1') |
| | | // } |
| | | }, |
| | | klineJump() { |
| | | this.$router.push(`/cryptos/trendDetails/${this.symbol}?type=${this.queryType}`) |
| | | this.$router.push(`/cryptos/trendDetails/${this.symbol}?type=${this.queryType}&selectIndex=${this.selectIndex}`) |
| | | }, |
| | | changeTab(index) { |
| | | this.$emit('tab', index) |
| | |
| | | |
| | | .select-one-active { |
| | | background-color: $red; |
| | | color: $text_color; |
| | | color: #fff; |
| | | border: none; |
| | | } |
| | | |