From a943191d485a4b299e940d67e272fd51f0961759 Mon Sep 17 00:00:00 2001 From: liaoxinyu Date: Fri, 30 Aug 2024 09:45:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=88=E7=BA=A6=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE=E6=94=B9k?= =?UTF-8?q?=E7=BA=BF=E4=B8=8D=E8=83=BD=E4=B8=80=E7=9B=B4=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/server/index.js | 2 +- src/views/contract/handicap.vue | 32 +++++++++++++++++++++++++------- src/views/contract/index.vue | 25 +++++++++++++++++++------ src/views/option/kline.vue | 21 ++++++++++++++------- 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/src/api/server/index.js b/src/api/server/index.js index d169e94..54cc982 100644 --- a/src/api/server/index.js +++ b/src/api/server/index.js @@ -57,7 +57,7 @@ const headers = Object.assign({ Object.assign(settings, { // api请求根地址 打包使用完整地址 调试使用本地服务器代理 避免跨域 - baseURL: process.env.NODE_ENV == 'production' ? 'https://seee.btcaholic.com/api/' : '/api/', + baseURL: process.env.NODE_ENV == 'production' ? 'https://seee.btcaholic.com/api/' : 'https://seee.btcaholic.com/api/', // baseURL: 'https://djs.jedcoin.com/api/', // 加载超时限定5s diff --git a/src/views/contract/handicap.vue b/src/views/contract/handicap.vue index f162f84..794e713 100644 --- a/src/views/contract/handicap.vue +++ b/src/views/contract/handicap.vue @@ -67,7 +67,8 @@
{{ $t("contract.g3") }}
- {{ newPriceObj.price }} + + {{ price1 }}
@@ -134,6 +135,8 @@ export default { buyList: [], tradeList: [], newPriceObj: {}, + price1:0, + intervalId:'' }; }, props: { @@ -193,15 +196,29 @@ export default { this.getMarketInfo(); this.linkSocket(); } - bus.$on('collapse', msg => { - this.newPriceObj.price =this.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3); - this.$emit("input", this.newPriceObj); - }); + this.startWatchingPrice() + // bus.$on('collapse', msg => { + // console.log(msg,'111'); + // this.newPriceObj.price = this.symbol=='BTC'? (msg.close).toFixed(1) : (msg.close).toFixed(3); + // this.$emit("input", this.newPriceObj); + // }); }, + beforeDestroy() { + this.stopWatchingPrice(); // 组件销毁时停止监听 + }, // 获取盘口 methods: { parseTime: date.parseTime, omitTo: math.omitTo, + startWatchingPrice(){ + this.intervalId = setInterval(() => { + let newPrice = localStorage.getItem('price'); + this.price1 = newPrice; + }, 100); // 每秒检查一次 + }, + stopWatchingPrice() { + clearInterval(this.intervalId); // 清除定时器 + }, getMarketInfo() { let data = { symbol: this.symbol @@ -262,8 +279,9 @@ export default { } else if (sub == this.msg.trade) { this.tradeList.unshift(data); this.tradeList.pop(); - // this.newPriceObj = data; - // this.$emit("input", this.newPriceObj); + this.newPriceObj = data; + localStorage.setItem("price",this.newPriceObj.price) + this.$emit("input", this.newPriceObj); } else if (type == "ping" ||cmd == "ping") { this.ws.send({ cmd: "pong" diff --git a/src/views/contract/index.vue b/src/views/contract/index.vue index 84f5553..4180f6e 100644 --- a/src/views/contract/index.vue +++ b/src/views/contract/index.vue @@ -20,7 +20,7 @@ decreace2: activeContract.increase < 0, increase: activeContract.increase >= 0 }"> - {{ activeContract.price }} + {{ price1 }}
{ + let newPrice = localStorage.getItem('price'); + this.price1 = newPrice; + }, 100); // 每秒检查一次 + }, + stopWatchingPrice() { + clearInterval(this.intervalId); // 清除定时器 + }, ispopover1(item){ this.activeSymbol=item; // this.$refs.popover.showPopper = false; @@ -349,7 +363,6 @@ export default { }); this.ws.on("message", res => { let { data, sub,cmd } = res; - if (sub == msg) { if( data.symbol=='BTC' )(data.price).toFixed(1) this.contractList = data; diff --git a/src/views/option/kline.vue b/src/views/option/kline.vue index 70264a6..a53122f 100644 --- a/src/views/option/kline.vue +++ b/src/views/option/kline.vue @@ -42,6 +42,11 @@ export default { type: String, required: false, }, + newPriceObj: { + default: () => {}, + type: Object, + required: false + }, }, watch: { activeCoin(n, o) { @@ -64,7 +69,7 @@ export default { if (n != o && o) { this.unsub(this.ajaxTv.getSymbol(o), this.timer); } - }, + } }, computed: { lang() { @@ -122,7 +127,8 @@ data() { sub: "", isCreateSocket: false, page: {}, - tt:undefined + tt:undefined, + price:0 }; }, methods: { @@ -222,8 +228,8 @@ methods: { let jiya = window.pako.inflate(u8) let str = this.Uint8ArrayToString(jiya); return JSON.parse(str); - }, - Uint8ArrayToString(fileData) { + }, + Uint8ArrayToString(fileData) { var dataString = ""; for (var i = 0; i < fileData.length; i++) { dataString += String.fromCharCode(fileData[i]); @@ -240,13 +246,13 @@ methods: { ) { // handleClick this.page[this.symbol] = this.page[this.symbol] || 1; - let page = this.page[this.symbol] > 3 ? 3 : this.page[this.symbol]; + let page = this.page[this.symbol] > 50 ? 50 : this.page[this.symbol]; let data = { symbol: this.ajaxTv.getSymbol(symbolInfo.name), period: this.resolution(resolution), form: rangeStartDate, to: rangeEndDate, - size: page * 200, + size: page * 400, zip: 1, }; @@ -270,10 +276,11 @@ methods: { let arr = this.unzip(res.data).map((item) => { return this.getMap(item); }); + // console.log(arr); this.page[this.symbol]++; onLoadedCallback(arr); setTimeout(() => { - if (this.page[this.symbol] > 3) { + if (this.page[this.symbol] > 50) { onLoadedCallback([]); } }, 60);