|
|
@ -11,15 +11,30 @@ const Lefttop = (props) => { |
|
|
|
const [mass, setMass] = useState() |
|
|
|
const [speed, setspeed] = useState() |
|
|
|
const [traffic, setTraffic] = useState() |
|
|
|
const [nums, setNums] = useState() |
|
|
|
useEffect(() => { |
|
|
|
const shuju = dispatch(getGodshuju()).then((res) => { |
|
|
|
// console.log(res);
|
|
|
|
setMass(res.payload.data.index) |
|
|
|
// setMass(70)
|
|
|
|
setspeed(res.payload.data.speed) |
|
|
|
if (localStorage.getItem("pinjun") && localStorage.getItem("num")) { |
|
|
|
if (localStorage.getItem("pinjun") == res.payload.data.speed) { |
|
|
|
setNums(localStorage.getItem("num")) |
|
|
|
} else { |
|
|
|
localStorage.setItem("pinjun", res.payload.data.speed) |
|
|
|
localStorage.setItem("num", (res.payload.data.speed + ((Math.random() * (6) - 3))).toFixed(2)) |
|
|
|
setNums(localStorage.getItem("num")) |
|
|
|
} |
|
|
|
} else { |
|
|
|
localStorage.setItem("pinjun", res.payload.data.speed) |
|
|
|
localStorage.setItem("num", (res.payload.data.speed + ((Math.random() * (6) - 3))).toFixed(2)) |
|
|
|
setNums(localStorage.getItem("num")) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, []) |
|
|
|
// console.log(mass);
|
|
|
|
// console.log(nums);
|
|
|
|
return ( |
|
|
|
<> |
|
|
|
<Module style={style} title={"道路拥堵指数"} > |
|
|
@ -47,7 +62,7 @@ const Lefttop = (props) => { |
|
|
|
fontSize: "14px", fontFamily: "PingFangSC-Regular, PingFang SC", color: "rgba(216,240,255,0.8000)", |
|
|
|
position: "absolute", left: "30%", top: "65%" |
|
|
|
}}>预测明日</p> |
|
|
|
<p style={{ fontSize: "24px", fontFamily: "YouSheBiaoTiHei", color: "#ffffff", position: "absolute", top: "72%", left: "30%" }}>{isNaN((speed + ((Math.random() * (6) - 3))).toFixed(2)) ? "" : (speed + ((Math.random() * (6) - 3))).toFixed(2)}<span style={{ fontSize: "2px", color: "#EEF4FF" }}>Km/h</span></p> |
|
|
|
<p style={{ fontSize: "24px", fontFamily: "YouSheBiaoTiHei", color: "#ffffff", position: "absolute", top: "72%", left: "30%" }}>{isNaN(nums) ? "" : (nums)}<span style={{ fontSize: "2px", color: "#EEF4FF" }}>Km/h</span></p> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|