Browse Source

体育对接实时链接

master
luyisha 3 years ago
parent
commit
a9657a9b18
  1. 11
      src/views/HomeView.vue
  2. 87
      src/views/TycView.vue

11
src/views/HomeView.vue

@ -142,7 +142,7 @@ import { numGrow,ecMaxVal,numberGrow} from '@/utils/comm';
// api // api
import * as homeApi from '@/api/home' import * as homeApi from '@/api/home'
let ws = null;
export default { export default {
name: 'HomeView', name: 'HomeView',
data() { data() {
@ -700,12 +700,12 @@ export default {
getsckdata(){ getsckdata(){
let that = this; let that = this;
// websocket // websocket
const ws = new WebSocket(publicConfig.WS_URL_ZL); ws = new WebSocket(publicConfig.WS_URL_ZL);
ws.onopen = function() { ws.onopen = function() {
console.log("ws connected success!") // console.log("ws connected success!")
}; };
ws.onclose = function(event) { ws.onclose = function(event) {
console.log('WebSocket连接已关闭'); // console.log('WebSocket');
}; };
ws.onmessage = (e)=> { ws.onmessage = (e)=> {
var jstr = JSON.parse(e.data); var jstr = JSON.parse(e.data);
@ -822,6 +822,9 @@ export default {
}); });
} }
},
beforeUnmount(){
ws.close();
} }
} }

87
src/views/TycView.vue

@ -402,6 +402,7 @@ import * as echarts from 'echarts';
import * as btApi from '../api/home' import * as btApi from '../api/home'
import { ecMaxVal,numGrow } from '@/utils/comm'; import { ecMaxVal,numGrow } from '@/utils/comm';
let ws = null;
export default { export default {
name: 'TycView', name: 'TycView',
data() { data() {
@ -431,6 +432,8 @@ export default {
this.cg_line() this.cg_line()
// //
this.getTdcg() this.getTdcg()
this.getsckdata()
}, },
methods: { methods: {
// 110,210,310 // 110,210,310
@ -495,7 +498,7 @@ export default {
}); });
// 2 // 2
}, },
// 24H // 24H
cgsf_line() { cgsf_line() {
var chartDom = document.getElementById('gcins_charts'); var chartDom = document.getElementById('gcins_charts');
var myChart = echarts.init(chartDom); var myChart = echarts.init(chartDom);
@ -625,19 +628,19 @@ export default {
] ]
} }
option && myChart.setOption(option); // option && myChart.setOption(option);
// //
setInterval(()=>{ // setInterval(()=>{
myChart.clear() myChart.clear()
option && myChart.setOption(option); option && myChart.setOption(option);
},4000); // },4000);
}, },
// //
getTdcg(){ getTdcg(){
let guids = "110|210|310" let guids = "110|210|310"
btApi.tdGroupRealTimeEnter({groupsId:guids}).then(res=>{ btApi.tdGroupRealTimeEnter({type:1}).then(res=>{
console.log(res) console.log(res)
const tmpdata = res.data.data const tmpdata = res.data.data
// X // X
@ -658,7 +661,7 @@ export default {
}) })
}, },
// // 线
cg_line() { cg_line() {
var chartDom = document.getElementById("gc_charts"); var chartDom = document.getElementById("gc_charts");
var myChart = echarts.init(chartDom); var myChart = echarts.init(chartDom);
@ -817,9 +820,81 @@ export default {
series: series, series: series,
} }
myChart.clear()
option && myChart.setOption(option); option && myChart.setOption(option);
}, },
getsckdata(){
let that = this;
// websocket
ws = new WebSocket(publicConfig.WS_URL_TY);
ws.onopen = function() {
// console.log("ws connected success!")
};
ws.onclose = function(event) {
// console.log('WebSocket');
};
ws.onmessage = (e)=> {
var jstr = JSON.parse(e.data);
if(!jstr){
return;
}
// 24
const vkdata = new Array;
vkdata.push({
xname: jstr.getPassHoursData.data.dkeys.slice(-8, jstr.getPassHoursData.data.dkeys.length),
xval: jstr.getPassHoursData.data.dvalue.slice(-8, jstr.getPassHoursData.data.dvalue.length)
})
that.ecbardata = vkdata;
that.cgsf_line();
// 线
function linedata(){
that.zxliddata=[];
that.rsqsDataName=[],that.rsqsDatas=[];
const tmpdata = jstr.toDayGroupsEnterNum.data;
tmpdata.forEach((item) => {
that.rsqsDataName.push(item.groupName);
that.rsqsDatas.push(item.list)
})
that.zxlindata = jstr.toDayGroupsEnterNum.data[0].list.dkeys;
that.rsqsDatas.forEach((item) => {
let rsqsData = []
Object.getOwnPropertyNames(item).forEach((value) => {
if(value=='dvalue'){
rsqsData = item[value];
}
});
that.zxliddata.push(rsqsData)
})
that.cg_line()
}
linedata();
//
function proportion(){
//
const tgdata = jstr.allGroupTimeNum.data.data.groupsData
that.cgdata = tgdata
// today in
// tgdata.forEach(item=>{
// that.tdnum += item.noRepeatInNum
// });
}
proportion();
//
const rtdata = jstr.allGroupNum.data
that.tdnum = rtdata.day.noRepeatInNum
that.wdnum = rtdata.week.noRepeatInNum
that.tmdata = rtdata.month.noRepeatInNum
that.tydata = rtdata.year.noRepeatInNum
}
}
}, },
beforeUnmount(){
// console.log('');
ws.close();
}
} }
</script> </script>
Loading…
Cancel
Save