import { Api_getQuotationNew } from "@/api/index.js" export const gerCurrencyMarket = (callback) => { const rq = (callback) => { Api_getQuotationNew().then(res => { // if (res && res.length > 0) { // let newArr = res.find((item) => item.name == 'USDT').quotation || []; // if (!state.currencyVal || !state.currencyVal?.currency_id) { // state.currencyVal = newArr[0]; // } // // 首页推荐 // if (newArr && newArr.length > 0) { // const nums = newArr.length > 3 ? 3 : newArr.length; // state.usdtList = newArr.slice(0, nums); // } else { // state.usdtList = [] // } // // 自选 // state.optional = newArr.slice(0, 6) // // 全部 // state.marketAll = newArr // } callback(new Date()) }).catch(err => { // if (state.currencySuspend && data?.noRefresh) { // console.log(11111 , state.currencySuspend , data?.noRefresh) // rq() // } }).finally(() => { setTimeout(() => { rq() // noRefresh : 是否不刷新,true 不会继续调用 // if (state.currencySuspend && !data?.noRefresh) { // console.log(22222 , state.currencySuspend , data?.noRefresh) // rq() // } }, 3000) }) } rq(callback) } // export default class currencyMarket { // ​ // constructor() { // ​ // this.socket = null;​ // this.typeName = null;​ // this.onopen = (() => { // ​ // console.log(`open ${this.typeName} websocket`);​​ // })​ this.onmessage = (e => { // ​ //处理各种推送消息 // ​​})​ this.onerror = (e => { // ​ // console.warn(`${this.typeName}websocket服务已断开,正在重连`);​ // console.error("error " + e);​​ // })​ this.onclose = (() => { // ​ // console.warn("close websocket");​ // console.warn(`${this.typeName}websocket服务已断开,正在重连`);​​ // })​ this.initWs();​ // } // ​ initWs() { // ​ // console.warn(`初始化${this.typeName}websocket连接`);​ // this.socket = new WebSocket(this.url); // 创建连接并注册响应函数 // ​ // this.socket.onopen = () => { // ​ // this.onopen();​ // };​ // this.socket.onclose = () => { // ​ // this.onclose();​ // this.socket = null; // 清理 // ​ // stopWebsocket();​ // };​ // this.socket.onerror = (e) => { // ​ // this.onerror(e);​ // stopWebsocket();​ // }​ // this.socket.onmessage = (e) => { // ​ // this.onmessage(e);​ // };​ // } // ​ reConnect(that) { // ​ // if (that.isReconnect) return;​ // that.isReconnect = true;​ //没连接上会一直重连,设置延迟避免请求过多 // ​ // setTimeout(() => { // ​ // that.initWs();​ // that.isReconnect = false;​ // }, 2000);​ // } // }