lxf
2025-07-08 b37eef5a0807a8f5688e2112591cb80a3ba333e4
style
10 files modified
144 ■■■■ changed files
.gitignore 1 ●●●● patch | view | raw | blame | history
src/components/Transform/contract-header/index.vue 39 ●●●● patch | view | raw | blame | history
src/components/Transform/list-quotation/index.vue 8 ●●●● patch | view | raw | blame | history
src/components/Transform/trade-head/index.vue 33 ●●●● patch | view | raw | blame | history
src/config/index.js 7 ●●●●● patch | view | raw | blame | history
src/views/cryptos/PerpetualContract/index.vue 4 ●●●● patch | view | raw | blame | history
src/views/cryptos/Trade/index.vue 2 ●●● patch | view | raw | blame | history
src/views/cryptos/TrendDetails/index.vue 6 ●●●● patch | view | raw | blame | history
src/views/cryptos/index.vue 34 ●●●●● patch | view | raw | blame | history
src/views/news/index.vue 10 ●●●● patch | view | raw | blame | history
.gitignore
@@ -3,6 +3,7 @@
bower_components/
.pnp/
.pnp.js
*.zip
# 测试相关
coverage/
src/components/Transform/contract-header/index.vue
@@ -60,7 +60,7 @@
          </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 class="mt-10 font-28" :class="item.change_ratio_str > 0 ? 'text-green' : 'text-red'">{{ item.change_ratio_str
            }}%</div>
          </div>
        </div>
@@ -75,7 +75,8 @@
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: {
@@ -153,15 +154,35 @@
      }
      this.show = false
    },
    onSidebar() { // 侧边栏打开
    async onSidebar() { // 侧边栏打开
      // console.log('侧边栏打开: ', this.selectIndex)
      if (this.selectIndex == 2) {
        const quotesData = JSON.parse(localStorage.getItem('qoutes'));
        this.coins = quotesData.coins || [];
        this.coins = quotesData.coins.map(item => item.symbol)
      // 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 {
        this.coins = this.coinList.map(item => item.symbol);
        // 如果本地没有 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
@@ -170,7 +191,7 @@
      this.fetchList()
    },
    fetchList() { // 获取行情
      _getHomeList(this.coins.join(',')).then(list => {
      _getHomeList(this.coins).then(list => {
        // console.log(list)
        this.list = list
        if (this.timeout) {
src/components/Transform/list-quotation/index.vue
@@ -57,9 +57,9 @@
              </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_str > 0">
@@ -91,8 +91,8 @@
              </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">
src/components/Transform/trade-head/index.vue
@@ -69,8 +69,8 @@
            </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>
@@ -82,7 +82,7 @@
</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";
@@ -90,6 +90,7 @@
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",
@@ -222,14 +223,34 @@
      }
      this.show = false
    },
    onSidebar() { // 侧边栏打开
    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) {
src/config/index.js
@@ -42,7 +42,7 @@
// const ENV_PRO = 'qheufhj.site' //  app域名
// const ENV_PRO = window.location.hostname // 接口域名跟随 H5zhapi.coinbtcs.com
// const ENV_PRO = 'openapi.yanshiz.com' // 接口域名跟随 H5zhapi.coinbtcs.com
const ENV_PRO = '192.168.10.18:8086' // 接口域名跟随 H5zhapi.coinbtcs.com
const ENV_PRO = 'aa.yanshiz.com' // 接口域名跟随 H5zhapi.coinbtcs.com
let base_url = ''
let ws_url = ''
@@ -50,7 +50,7 @@
if (import.meta.env.MODE === 'development') {
    host_url = 'https://' + ENV_DEV
    base_url = 'https://' + ENV_DEV
    ws_url = 'ws://' + ENV_DEV + '/api/websocket'
    ws_url = 'wss://' + ENV_DEV + '/api/websocket'
} else {
    host_url = 'https://' + ENV_PRO
    base_url = 'https://' + ENV_PRO
@@ -59,7 +59,8 @@
export const BASE_URL = base_url
export const WS_URL = ws_url
export const IMG_PATH = host_url
export const HOST_URL = host_url
// export const HOST_URL = host_url
export const HOST_URL = 'https://forex.yanshiz.com'; // 静态资源地址
export default {
    sliderOptions: {
src/views/cryptos/PerpetualContract/index.vue
@@ -489,11 +489,11 @@
      })
    },
    handleQoutes(data) {
      // console.log('handleQoutes: ', data);
      console.log('handleQoutes: ', data);
      if (data && data.length) {
        const cur = data[0]
        this.price = cur.close
        this.range = cur.changeRatioStr + ''
        this.range = (cur.change_ratio_str || cur.changeRatioStr)
        this.quote = cur
        this.updateKey++
      }
src/views/cryptos/Trade/index.vue
@@ -378,7 +378,7 @@
      if (data && data.length) {
        const cur = data[0]
        this.price = cur.close
        this.range = cur.change_ratio + ''
        this.range = cur.change_ratio_str || cur.changeRatioStr
        this.quote = cur
        this.updateKey++
      }
src/views/cryptos/TrendDetails/index.vue
@@ -16,11 +16,11 @@
        <div class="data-index">
          <div class="flex flex-1 px-32 mt-40">
            <div class="flex flex-col font-22">
              <p class="font-70 font-600" :class="quote.change_ratio > 0 ? 'text-green' : 'text-red'">
              <p class="font-70 font-600" :class="quote.change_ratio_str > 0 ? 'text-green' : 'text-red'">
                {{ quote.close || '--' }}</p>
              <p class="font-22 mt-10">≈ {{ currency.currency_symbol }}{{ quote.close ? (quote.close *
                currency.rate).toFixed(2) : '--' }}
                <span :class="quote.change_ratio > 0 ? 'text-green' : 'text-red'">{{ quote.change_ratio
                <span :class="quote.change_ratio_str > 0 ? 'text-green' : 'text-red'">{{ quote.changeRatioStr
                  ||
                  '--' }}%</span>
              </p>
@@ -551,7 +551,7 @@
}
:deep(.van-tabs__nav) {
  background-color: $night !important;
  // background-color: $night !important;
}
@keyframes animate1 {
src/views/cryptos/index.vue
@@ -73,6 +73,7 @@
import { _getUnreadMsg } from '@/service/im.api'
import { _getNewsList1, _getPopupNews } from '@/service/user.api'
import { BASE_URL } from "@/config";
import { _getCoinList } from '@/service/quotes.api';
const THEME = 'dark'
export default {
  name: "HomePage",
@@ -135,22 +136,33 @@
    },
    async fetchQList(v) { // 获取行情
      let coninArr = ''
      if (v) { this.getVal = v }
      // if(this.getVal == 2) {
        let arr = getStorage('qoutes').coins
        arr.map((item) => {
      // if (v) { this.getVal = v }
      let arr = getStorage('qoutes')
      // 优先用本地缓存的 coins
      let coins = (arr && arr.coins && arr.coins.length) ? arr.coins : arr
      if (coins && coins.length) {
        // 如果本地有 coins,优先用本地
        coins.forEach(item => {
          coninArr += item.symbol + ','
        })
      //  }else{
        // coninArr = this.coinArr.join(',')
      // }
      } else {
        // 如果本地没有 coins,拉取接口
        const quotesData = await _getCoinList()
        if (quotesData && quotesData.coins && quotesData.coins.length) {
          quotesData.coins.forEach(item => {
            coninArr += item.symbol + ','
          })
        }
      }
      console.log('fetchQList', v, coninArr)
      // if()
      const list = await _getHomeList(coninArr).catch(() => {
        //TODO: 轮询
        // this.timeout = setTimeout(() => {
        //   this.fetchQList()
        // }, 1000)
        //请求失败时,1秒后重试
        this.timeout = setTimeout(() => {
          this.fetchQList()
        }, 1000)
      })
      if (!(list instanceof Array)) {
        return
src/views/news/index.vue
@@ -45,7 +45,7 @@
            </div>
          </div>
          <div class="flex justify-between">
            <div class="py-2 px-8 rounded-full text-13 font-medium bg-white">{{item.change_ratio}}</div>
            <div class="py-2 px-8 rounded-full text-13 font-medium bg-white">{{item.change_ratio_str}}</div>
            <span class="text-18">→</span>
          </div>
        </div>
@@ -63,7 +63,7 @@
      </div>
      <div class="text-center">{{t('理財')}}</div>
    </div>
    <div class="flex-1 flex flex-col items-center" @click="goToPage('/cryptos/trade/btcusdt')">
    <div class="flex-1 flex flex-col items-center" @click="goToPage('/cryptos/trade/USDSGD')">
      <div class="w-40 h-40 rounded-full flex items-center justify-center">
        <img class="w-33 h-33" src="@/assets/c.jpg" draggable="false">
      </div>
@@ -127,6 +127,8 @@
import { showToast } from 'vant'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import { _getCoinList } from '@/service/quotes.api'
import { setStorage } from '@/utils/index'
const router = useRouter()
const { t } = useI18n()
@@ -144,6 +146,10 @@
  console.log('user', user)
  username.value = user.userInfo?.username || ''
  usercode.value = user.userInfo?.usercode || ''
  // 如果本地没有 coins,拉取接口
  const quotesData = await _getCoinList()
  setStorage('qoutes', { coins: quotesData }) // 存到本地
})
const goToExplanation = () => {