10.10综合交易所原始源码_移动端
1
admin
2026-01-06 03043192ddf00f9a36b7454799a9152cd1b50a0b
src/views/quotes/UsStockMore.vue
@@ -61,7 +61,7 @@
    </div>
  </section>
</template>
<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { useRoute, useRouter } from 'vue-router';
@@ -80,16 +80,43 @@
const loading = ref(false);
const finished = ref(false);
const category = ref('')
const sockets = ref(null)
const pageNo = ref(1); // 初始页码
onMounted(async () => {
  typName.value = route.query.typName
  tabIndex.value = route.query.tabIndex
  category.value = route.query.category
})
onBeforeUnmount(() => {
  sockets.value && sockets.value.close()
})
// 去除字符串中的 % 符号
const removePercentSign = (str) => {
  if (typeof str === 'string' && str.includes('%')) {
    return str.replace(/%/g, '')
  }
  return str
}
const startStocksSocket = () => {
  sockets.value = new WebSocket(`wss://ws.sceazy.com/websocket-server`)
  sockets.value.onmessage = (evt) => {
    const { data } = evt
    const _data = JSON.parse(data)
    // 处理 pcp 值,去除 % 符号
    const pcpValue = removePercentSign(_data.pcp)
    let upData = list.value.find(item => item.pid == _data.pid);
    if (upData) {
      upData.changeRatio = pcpValue;
      upData.close = _data.last;
    }
  }
}
const getRealtimeByType = () => {
  _getRealtimeByType({
@@ -103,7 +130,7 @@
    if (data.length < 20) {
      finished.value = true
    }
    startStocksSocket()
    pageNo.value++
  })
}
@@ -113,12 +140,12 @@
}
const itemClick = (item) => {
  if(category.value){
  if (category.value) {
    router.push(`/quotes/usStockDetail?symbol=${item.symbol}&symbolType=${symbolType}&enName=${item.enName}&isMore=1&tabIndex=${tabIndex.value}&typName=${typName.value}&category=${category.value}`)
  }else{
  } else {
    router.push(`/quotes/usStockDetail?symbol=${item.symbol}&symbolType=${symbolType}&enName=${item.enName}&isMore=1&tabIndex=${tabIndex.value}&typName=${typName.value}`)
  }
}
const onRoute = (path) => {
@@ -126,9 +153,9 @@
}
const handleBack = () => {
  if(route.query?.tabIndex){
  if (route.query?.tabIndex) {
    router.push(`/quotes/index?tabActive=${route.query.tabIndex}`)
  }else {
  } else {
    onRoute('/quotes/index?tabActive=4')
  }
}