| | |
| | | let newArr = JSON.parse(JSON.stringify(state.gasData)) |
| | | if(Array.isArray(newArr)){ |
| | | state.gasTotal = newArr.length |
| | | }else{ |
| | | state.gasTotal = 0 |
| | | } |
| | | const weather = newArr.map((item)=>{ |
| | | const weather = newArr.map((item)=>{ |
| | | return { |
| | | time: item.dataReceivingTime?item.dataReceivingTime.slice(11,19):'--', |
| | | temp: item.temp?item.temp:'--', |
| | |
| | | windDirection: item.windDirection?item.windDirection:'--', |
| | | pressure: item.pressure?item.pressure:'--' |
| | | } |
| | | }) |
| | | state.weatherData = [...weather].reverse().slice(0, 4); |
| | | }) |
| | | state.weatherData = [...weather].reverse().slice(0, 4); |
| | | }else{ |
| | | // state.gasTotal = 0 |
| | | getGasNdData() |
| | | } |
| | | for(let key in newArr[0]){ |
| | | if(newArr[0][key] == state.gasSearch && key.indexOf("gasName") !== -1){ |
| | | gasNum = key.substring(7) |
| | |
| | | } |
| | | state.socket.onclose=()=>{ |
| | | console.log("socket已经关闭") |
| | | getGasNdData() |
| | | getGasTlData() |
| | | getWindData() |
| | | } |
| | | } |
| | | } |