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. 17
      src/views/option/kline.vue

2
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

32
src/views/contract/handicap.vue

@ -67,7 +67,8 @@
<div style="width: 200px;">
<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;">
{{ newPriceObj.price }}
<!-- {{ newPriceObj.price }} -->
{{ price1 }}
</div>
</div>
<div class="w-14/24 text-right">
@ -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"

25
src/views/contract/index.vue

@ -20,7 +20,7 @@
decreace2: activeContract.increase < 0,
increase: activeContract.increase >= 0
}">
{{ activeContract.price }}
{{ price1 }}
</div>
<!-- <div class="title mb-1 text-secondary">
{{ $t("contract.h6") }}
@ -107,7 +107,7 @@
</div>
</div>
<div class="text-right width-32">
{{ item.price }}
{{ item.symbol == activeSymbol ? price1 : item.price }}
</div>
<div class="text-right width-32" :class="item.increase < 0 ? 'decreace' : 'increase'">
{{ item.increaseStr }}
@ -137,6 +137,7 @@
v-if="activeContract.pair_name"
:contract="true"
:wsUrl="wsUrl"
:newPriceObj1="newPriceObj"
/>
<!-- 交易 -->
<exchange-store
@ -256,7 +257,9 @@ export default {
currentIcon: '',
filterCoin: "",
contractListFilter: [],
Liste:[]
Liste:[],
price1:0,
intervalId:''
};
},
computed: {
@ -326,8 +329,7 @@ export default {
if(item.symbol==this.activeContract.symbol) item.realtimePrice=this.activeContract.price
})
});
this.startWatchingPrice();
},
//
mounted: function () {
@ -335,7 +337,19 @@ export default {
this.holdPosition();
}, 2000)
},
beforeDestroy() {
this.stopWatchingPrice(); //
},
methods: {
startWatchingPrice(){
this.intervalId = setInterval(() => {
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;

17
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: {
@ -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);

Loading…
Cancel
Save