Browse Source

修改合约价格问题,修改k线不能一直加载数据问题

master
liaoxinyu 1 year ago
parent
commit
a943191d48
  1. 2
      src/api/server/index.js
  2. 32
      src/views/contract/handicap.vue
  3. 25
      src/views/contract/index.vue
  4. 21
      src/views/option/kline.vue

2
src/api/server/index.js

@ -57,7 +57,7 @@ const headers = Object.assign({
Object.assign(settings, { Object.assign(settings, {
// api请求根地址 打包使用完整地址 调试使用本地服务器代理 避免跨域 // 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/', // baseURL: 'https://djs.jedcoin.com/api/',
// 加载超时限定5s // 加载超时限定5s

32
src/views/contract/handicap.vue

@ -67,7 +67,8 @@
<div style="width: 200px;"> <div style="width: 200px;">
<div class="name fn-14 px-3" style="display: inline-block;">{{ $t("contract.g3") }}</div> <div class="name fn-14 px-3" style="display: inline-block;">{{ $t("contract.g3") }}</div>
<div class="num fn-20 increace" style="display: inline-block;"> <div class="num fn-20 increace" style="display: inline-block;">
{{ newPriceObj.price }} <!-- {{ newPriceObj.price }} -->
{{ price1 }}
</div> </div>
</div> </div>
<div class="w-14/24 text-right"> <div class="w-14/24 text-right">
@ -134,6 +135,8 @@ export default {
buyList: [], buyList: [],
tradeList: [], tradeList: [],
newPriceObj: {}, newPriceObj: {},
price1:0,
intervalId:''
}; };
}, },
props: { props: {
@ -193,15 +196,29 @@ export default {
this.getMarketInfo(); this.getMarketInfo();
this.linkSocket(); this.linkSocket();
} }
bus.$on('collapse', msg => { this.startWatchingPrice()
this.newPriceObj.price =this.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3); // bus.$on('collapse', msg => {
this.$emit("input", this.newPriceObj); // 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: { methods: {
parseTime: date.parseTime, parseTime: date.parseTime,
omitTo: math.omitTo, omitTo: math.omitTo,
startWatchingPrice(){
this.intervalId = setInterval(() => {
let newPrice = localStorage.getItem('price');
this.price1 = newPrice;
}, 100); //
},
stopWatchingPrice() {
clearInterval(this.intervalId); //
},
getMarketInfo() { getMarketInfo() {
let data = { let data = {
symbol: this.symbol symbol: this.symbol
@ -262,8 +279,9 @@ export default {
} else if (sub == this.msg.trade) { } else if (sub == this.msg.trade) {
this.tradeList.unshift(data); this.tradeList.unshift(data);
this.tradeList.pop(); this.tradeList.pop();
// this.newPriceObj = data; this.newPriceObj = data;
// this.$emit("input", this.newPriceObj); localStorage.setItem("price",this.newPriceObj.price)
this.$emit("input", this.newPriceObj);
} else if (type == "ping" ||cmd == "ping") { } else if (type == "ping" ||cmd == "ping") {
this.ws.send({ this.ws.send({
cmd: "pong" cmd: "pong"

25
src/views/contract/index.vue

@ -20,7 +20,7 @@
decreace2: activeContract.increase < 0, decreace2: activeContract.increase < 0,
increase: activeContract.increase >= 0 increase: activeContract.increase >= 0
}"> }">
{{ activeContract.price }} {{ price1 }}
</div> </div>
<!-- <div class="title mb-1 text-secondary"> <!-- <div class="title mb-1 text-secondary">
{{ $t("contract.h6") }} {{ $t("contract.h6") }}
@ -107,7 +107,7 @@
</div> </div>
</div> </div>
<div class="text-right width-32"> <div class="text-right width-32">
{{ item.price }} {{ item.symbol == activeSymbol ? price1 : item.price }}
</div> </div>
<div class="text-right width-32" :class="item.increase < 0 ? 'decreace' : 'increase'"> <div class="text-right width-32" :class="item.increase < 0 ? 'decreace' : 'increase'">
{{ item.increaseStr }} {{ item.increaseStr }}
@ -137,6 +137,7 @@
v-if="activeContract.pair_name" v-if="activeContract.pair_name"
:contract="true" :contract="true"
:wsUrl="wsUrl" :wsUrl="wsUrl"
:newPriceObj1="newPriceObj"
/> />
<!-- 交易 --> <!-- 交易 -->
<exchange-store <exchange-store
@ -256,7 +257,9 @@ export default {
currentIcon: '', currentIcon: '',
filterCoin: "", filterCoin: "",
contractListFilter: [], contractListFilter: [],
Liste:[] Liste:[],
price1:0,
intervalId:''
}; };
}, },
computed: { computed: {
@ -326,8 +329,7 @@ export default {
if(item.symbol==this.activeContract.symbol) item.realtimePrice=this.activeContract.price if(item.symbol==this.activeContract.symbol) item.realtimePrice=this.activeContract.price
}) })
}); });
this.startWatchingPrice();
}, },
// //
mounted: function () { mounted: function () {
@ -335,7 +337,19 @@ export default {
this.holdPosition(); this.holdPosition();
}, 2000) }, 2000)
}, },
beforeDestroy() {
this.stopWatchingPrice(); //
},
methods: { methods: {
startWatchingPrice(){
this.intervalId = setInterval(() => {
let newPrice = localStorage.getItem('price');
this.price1 = newPrice;
}, 100); //
},
stopWatchingPrice() {
clearInterval(this.intervalId); //
},
ispopover1(item){ ispopover1(item){
this.activeSymbol=item; this.activeSymbol=item;
// this.$refs.popover.showPopper = false; // this.$refs.popover.showPopper = false;
@ -349,7 +363,6 @@ export default {
}); });
this.ws.on("message", res => { this.ws.on("message", res => {
let { data, sub,cmd } = res; let { data, sub,cmd } = res;
if (sub == msg) { if (sub == msg) {
if( data.symbol=='BTC' )(data.price).toFixed(1) if( data.symbol=='BTC' )(data.price).toFixed(1)
this.contractList = data; this.contractList = data;

21
src/views/option/kline.vue

@ -42,6 +42,11 @@ export default {
type: String, type: String,
required: false, required: false,
}, },
newPriceObj: {
default: () => {},
type: Object,
required: false
},
}, },
watch: { watch: {
activeCoin(n, o) { activeCoin(n, o) {
@ -64,7 +69,7 @@ export default {
if (n != o && o) { if (n != o && o) {
this.unsub(this.ajaxTv.getSymbol(o), this.timer); this.unsub(this.ajaxTv.getSymbol(o), this.timer);
} }
}, }
}, },
computed: { computed: {
lang() { lang() {
@ -122,7 +127,8 @@ data() {
sub: "", sub: "",
isCreateSocket: false, isCreateSocket: false,
page: {}, page: {},
tt:undefined tt:undefined,
price:0
}; };
}, },
methods: { methods: {
@ -222,8 +228,8 @@ methods: {
let jiya = window.pako.inflate(u8) let jiya = window.pako.inflate(u8)
let str = this.Uint8ArrayToString(jiya); let str = this.Uint8ArrayToString(jiya);
return JSON.parse(str); return JSON.parse(str);
}, },
Uint8ArrayToString(fileData) { Uint8ArrayToString(fileData) {
var dataString = ""; var dataString = "";
for (var i = 0; i < fileData.length; i++) { for (var i = 0; i < fileData.length; i++) {
dataString += String.fromCharCode(fileData[i]); dataString += String.fromCharCode(fileData[i]);
@ -240,13 +246,13 @@ methods: {
) { ) {
// handleClick // handleClick
this.page[this.symbol] = this.page[this.symbol] || 1; 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 = { let data = {
symbol: this.ajaxTv.getSymbol(symbolInfo.name), symbol: this.ajaxTv.getSymbol(symbolInfo.name),
period: this.resolution(resolution), period: this.resolution(resolution),
form: rangeStartDate, form: rangeStartDate,
to: rangeEndDate, to: rangeEndDate,
size: page * 200, size: page * 400,
zip: 1, zip: 1,
}; };
@ -270,10 +276,11 @@ methods: {
let arr = this.unzip(res.data).map((item) => { let arr = this.unzip(res.data).map((item) => {
return this.getMap(item); return this.getMap(item);
}); });
// console.log(arr);
this.page[this.symbol]++; this.page[this.symbol]++;
onLoadedCallback(arr); onLoadedCallback(arr);
setTimeout(() => { setTimeout(() => {
if (this.page[this.symbol] > 3) { if (this.page[this.symbol] > 50) {
onLoadedCallback([]); onLoadedCallback([]);
} }
}, 60); }, 60);

Loading…
Cancel
Save