10.10综合交易所原始源码_移动端
1
admin
2026-01-06 03043192ddf00f9a36b7454799a9152cd1b50a0b
src/views/quotes/UsStockMore.vue
@@ -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++
  })
}