| | |
| | | <div class="flex items-center"> |
| | | <!-- 没有切换模式的 --> |
| | | |
| | | <img v-if="isReturn" src="@/assets/image/icon_back_1.png" @click="backPath()" class="w-40 h-40 back mr-50" |
| | | <img v-if="isReturn" src="@/assets/image/icon_back.png" @click="backPath()" class="w-40 h-40 back mr-50" |
| | | alt=""> |
| | | <template v-if="!isChange"> |
| | | <img src="../../../assets/theme/dark/image/black-convert.png" alt="convert-img" class="w-35 h-35" |
| | |
| | | <!-- 在切换模式下 --> |
| | | <template v-if="isChange"> |
| | | <template v-if="isNight"> |
| | | <img src="../../../assets/image/icon_back_1.png" class="w-40 h-40 back mr-50" alt="" @click="backPath()"> |
| | | <img src="../../../assets/image/icon_back.png" class="w-40 h-40 back mr-50" alt="" @click="backPath()"> |
| | | <img src="./white-convert.png" alt="convert-img" class="w-35 h-35" @click="onSidebar" /> |
| | | </template> |
| | | <template v-else> |
| | |
| | | v-if="isCollect" /> |
| | | <img v-else src="../../../assets/image/icon-star.png" class="w-30 h-30 mr-10 ml-20" @click="openCurrency" /> |
| | | </div> |
| | | <img v-if="isTrade" src="../../../assets/image/kline.png" class="w-44 h-44 right" alt="" |
| | | @click="$router.push(`/cryptos/trendDetails/${symbol}?kineType=trade`)"> |
| | | <img src="../../../assets/image/public/record.png" alt="record-img" class="w-44 h-44 " |
| | | @click="goHistory" /> |
| | | |
| | | <!-- <img v-if="isTrade" src="../../../assets/image/kline.png" class="w-44 h-44 right" alt="" |
| | | @click="$router.push(`/cryptos/trendDetails/${symbol}?kineType=trade`)"> --> |
| | | </div> |
| | | </div> |
| | | <!-- 左侧边弹出菜单 --> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { setStorage, handleImage } from '@/utils/utis.js' |
| | | import { getStorage, setStorage, handleImage } from '@/utils/utis.js' |
| | | import { Popup, showSuccessToast } from "vant"; |
| | | import { mapGetters } from "vuex"; |
| | | import { _getHomeList, _collect, _deleteCollect, _checkIsInCollect } from "@/service/home.api"; |
| | |
| | | import { useRouter } from "vue-router"; |
| | | import addCurrency from '@/components/add-currency/index.vue' |
| | | import { _isItemHasAdd, _isItemHasAddGlobal } from '@/service/quotes.api' |
| | | import {_getCoinList} from '@/service/quotes.api' |
| | | const router = useRouter() |
| | | export default { |
| | | name: "contractHeader", |
| | |
| | | } |
| | | this.show = false |
| | | }, |
| | | onSidebar() { // 侧边栏打开 |
| | | goHistory() { |
| | | if (this.$store.state.user.userInfo.token) { |
| | | let type = 'cryptos' |
| | | if (this.$route.query.type) { |
| | | type = this.$route.query.type |
| | | } |
| | | this.$router.push(`/cryptos/tradeRecord/${this.symbol}/?type=forex`) |
| | | } else { |
| | | this.$router.push('/login') |
| | | } |
| | | }, |
| | | async onSidebar() { // 侧边栏打开 |
| | | // console.log(this.userInfo) |
| | | this.coins = this.coinList.map(item => item.symbol) |
| | | // 优先用本地缓存的 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 |
| | | // this.coins = this.coinList.map(item => item.symbol) |
| | | 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.$emit('changeNight', !this.isNight) |
| | | }, |
| | | backPath() { |
| | | if (this.$route.query?.from === 'trade') { |
| | | this.$router.push('/trade/index?tabActive=1') |
| | | } else if (this.$route.query.isOptional == 1) { |
| | | this.$router.push('/optional/index') |
| | | } |
| | | this.$router.go(-1) |
| | | // if (this.$route.query?.from === 'trade') { |
| | | // this.$router.push('/trade/index?tabActive=1') |
| | | // } else if (this.$route.query.isOptional == 1) { |
| | | // this.$router.push('/optional/index') |
| | | // } |
| | | // else if (this.$route.query.isOptional == 2){ |
| | | // this.$router.push('/optional/search') |
| | | // } |
| | | else { |
| | | this.$router.push('/quotes/index?tabActive=1') |
| | | } |
| | | // else { |
| | | // this.$router.push('/quotes/index?tabActive=1') |
| | | // } |
| | | }, |
| | | //打开自选弹窗 |
| | | openCurrency() { |