<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.a{
z-index: 1;
position: relative;
height: 810px;
width: 455px;
margin: auto;
border-radius: 10px;
left: -1px;
top: -814px;
}
.b{
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
background-color: rgba(255, 255, 255, 0.5);
height: 80px;
}
.c{
border-radius: 20px;
background-color: rgba(255, 255, 255, 0.5);
height: 80px;
position: relative;
top: 370px;
}
.d{
background-color: rgba(255, 255, 255, 0.5);
height: 100px;
border-radius: 20px;
position: relative;
top: 390px;
}
.e{
height: 150px;
position: relative;
top: 390px;
}
.f{
height: 40px;
width: 100px;
position: relative;
top: 20px;
left: 70px;
}
.h{
height: 55px;
font-size: 40px;
padding-left: 10px;
}
.i{
padding-left: 10px;
}
.g{
border-top-left-radius: 10px;
border-top-right-radius: 10px;
background-color: rgba(0, 0, 0, 0.2);
color: white;
}
.ff{
float: left;
margin-left: 34px;
font-size: 13px;
}
.gg{
float: left;
margin-left: 28px;
font-size: 12px;
}
.z{
height: 25px;
}
.one{
float: left;
width: 30px;
height: 30px;
background-color: pink;
margin:0px 15px 0 15px;
background: url(2.png) no-repeat;
background-size: 150px 90px;
position: relative;
left: 22px;
top: 6px;
background-position: top 0px left 0px;
}
.two{
float: left;
width: 30px;
height: 30px;
background-color: pink;
margin: 0px 15px 0 15px;
background: url(2.png) no-repeat;
background-size: 150px 90px;
position: relative;
left: 28px;
top: 6px;
}
.three{
float: left;
width: 30px;
height: 30px;
background-color: pink;
margin: 0px 15px 0 15px;
background: url(2.png) no-repeat;
background-size: 150px 90px;
position: relative;
left: 42px;
top: 6px;
}
.four{
float: left;
width: 30px;
height: 30px;
background-color: pink;
margin: 0px 15px 0 15px;
background: url(2.png) no-repeat;
background-size: 150px 90px;
position: relative;
left: 54px;
top: 6px;
}
.fever{
float: left;
width: 30px;
height: 30px;
background-color: pink;
margin: 0px 15px 0 15px;
background: url(2.png) no-repeat;
background-size: 150px 90px;
position: relative;
left: 67px;
top: 6px;
}
.six{
float: left;
width: 30px;
height: 30px;
background-color: pink;
margin: 0px 15px 0 15px;
background: url(2.png) no-repeat;
background-size: 150px 90px;
position: relative;
left: 77px;
top: 6px;
}
video{
width: 455px;
position: relative;
z-index: 0;
border-radius: 10px;
left: 715px;
}
.cc{
position: relative;
top: 0px;
float: left;
margin: 15px;
font-size: 12px;
}
.ca{
position: relative;
top: 0px;
float: left;
margin: 15px;
font-size: 12px;
}
</style>
</head>
<body>
<video autoplay loop muted src="晴.mp4"></video>
<div class="a">
<!-- 整体框架 -->
<div>
<!-- 电量 -->
<div class="g"></div>
</div>
<div class="b">
<div class="f">
<table>
<tr>
<td style="font-size: 20px;">潍坊</td>
</tr>
</table>
<div style="position: relative;bottom:0px;font-size: 10px;left: 3px;color: rgb(129, 126, 126);">刚刚更新</div>
</div>
<img src="6.png" style="height: 30px;width: 30px;position: relative;bottom:13px;left: 20px;">
<!-- 表头 -->
</div >
<div class="c">
<div class="h"></div>
<div class="i"></div>
<!-- 温度+天气状况 -->
</div>
<div class="d">
<div class="j">
<div class="ff">今天</div>
<div class="ff"></div>
<div class="ff"></div>
<div class="ff"></div>
<div class="ff"></div>
<div class="ff"></div>
</div>
<div>
<div class="gg"></div>
<div class="gg" style="margin-left: 20px;"></div>
<div class="gg" style="margin-left: 26px;"></div>
<div class="gg" style="margin-left: 28px;"></div>
<div class="gg" style="margin-left: 30px;"></div>
<div class="gg" style="margin-left: 26px;"></div>
</div>
<div class="z">
<div class="one"></div>
<div class="two" style="left: 28px;top: 6px;"></div>
<div class="two" style="left: 42px;top: 6px;"></div>
<div class="two" style="left: 54px;top: 6px;"></div>
<div class="two" style="left: 67px;top: 6px;"></div>
<div class="two" style="left: 77px;top: 6px;"></div>
</div>
<div>
<div class="ca" style="left: -353px;top: 21px; width: 50px;text-align: center;"></div>
<div class="cc" style="left: 72px;top: -25px;width: 50px;text-align: center;"></div>
<div class="cc" style="left: 66px;top: -26px;width: 50px;text-align: center;"></div>
<div class="cc" style="left: 59px;top: -27px;width: 50px;text-align: center;"></div>
<div class="cc" style="left: 51px;top: -27px;width: 50px;text-align: center;"></div>
<div class="cc" style="left: 44px;top: -27px;width: 50px;text-align: center;"></div>
</div>
<!-- 预计五天天气状况 -->
</div>
</div>
<script>
// 左上角的时间
var time= function(){
var date =new Date();
var h =date.getHours();
h=h<10?'0'+h:h;
var m=date.getMinutes();00
m=m<10?'0'+m:m;
document.querySelector('.g').innerHTML=h+':'+m;
}
time();
setInterval('time()',1000)
var txt =null
var index='潍坊';
function changeTotext(obj){
var tdValue = obj.innerText;
obj.innerText = "";
txt = document.createElement("input");
txt.type = "text";
txt.value = tdValue;
txt.id = "_text_000000000_";
txt.setAttribute("className","text");
obj.appendChild(txt);
txt.select();
txt.style.position='relative'
txt.style.width='60px'
txt.style.height='20px'
txt.style.fontSize='20px'
txt.style.right='3px'
}
function cancel(obj){
var txtValue = document.getElementById("_text_000000000_").value;
document.querySelector('td').innerText=txtValue;
x(txtValue)
}
document.ondblclick = function(){
if (event.srcElement.tagName.toLowerCase() == "td"){
changeTotext(event.srcElement);
}
txt.onblur=function(){
if (event.srcElement.tagName.toLowerCase() == "input"){
cancel(event.srcElement);
txt.remove()
}
}
}
// 日期
var riqi =document.querySelectorAll('.ff')
for(var i=1;i<riqi.length;i++){
var xing =''
var week = new Date().getDay()+i
if (week == 0||week==7||week==14) {
xing = "星期日";
} else if (week == 1||week==8) {
xing = "星期一";
} else if (week == 2||week==9) {
xing = "星期二";
} else if (week == 3||week==10) {
xing = "星期三";
} else if (week == 4||week==11) {
xing = "星期四";
} else if (week == 5||week==12) {
xing = "星期五";
} else if (week == 6||week==13) {
xing = "星期六";
}
riqi[i].innerText=xing
}
var ri =document.querySelectorAll('.gg')
for(var i=0;i<ri.length;i++){
var xing =''
var m = new Date().getMonth()+1
var r =new Date().getDate()+i
ri[i].innerText=m+"月"+r+"日"
}
//天气
var one =document.querySelector('.one')
var two =document.querySelectorAll('.two')
var x =function(index){
var xhr = new XMLHttpRequest();
xhr.open("GET","http://www.wfweilan.com/weather.php?city="+index+"&key=09eb64a25b800ea00545eddd15665656")
xhr.send()
xhr.onreadystatechange=function(){
if(xhr.readyState==4 && xhr.status==200){
data = JSON.parse(xhr.responseText);
console.log(data);
document.querySelector('.h').innerText=data.result.realtime.temperature+'\°'
document.querySelector('.i').innerText="风向:"+data.result.realtime.direct+"\xa0\xa0\xa0\xa0\xa0风力:"+data.result.realtime.power
var cc=document.querySelectorAll('.cc')
document.querySelector(".ca").innerHTML=data.result.realtime.info
for(var i=0;i<cc.length;i++){
cc[i].innerHTML=data.result.future[i].weather
}
if(data.result.realtime.info=='晴') {
one.style.backgroundPosition='top 0px left -30px'
document.querySelector('video').setAttribute('src','晴.mp4')
} else if(data.result.realtime.info=='多云'){
one.style.backgroundPosition='top 0px left 0px'
document.querySelector('video').setAttribute('src','多云.mp4')
}else if(data.result.realtime.info=='阴天'){
document.querySelector('video').setAttribute('src','多云.mp4')
one.style.backgroundPosition='0px left -60px'
}else if(data.result.realtime.info=='小雨'){
document.querySelector('video').setAttribute('src','小雨.mp4')
one.style.backgroundPosition='top 0px left -93px'
}else if(data.result.realtime.info=='大雨'){
document.querySelector('video').setAttribute('src','雷雨.mp4')
one.style.backgroundPosition='top -34px left 0px'
}else if(data.result.realtime.info=='大雨'){
document.querySelector('video').setAttribute('src','小雨.mp4')
one.style.backgroundPosition='top -34px left 0px'
}else if(data.result.realtime.info=='雾'||data.result.realtime.info=='霾'){
one.style.backgroundPosition='top -34px left -57px'
}else if(data.result.realtime.info=='大雪'){
one.style.backgroundPosition='top -34px left -125px'
}else if(data.result.realtime.info.indexOf('雨转阴')){
document.querySelector('video').setAttribute('src','小雨.mp4')
one.style.backgroundPosition='top -34px left -30px'
}else if (data.result.realtime.info.indexOf('雨')){
document.querySelector('video').setAttribute('src','小雨.mp4')
one.style.backgroundPosition='top 0px left -93px'
}else if (data.result.realtime.info.indexOf('雪')){
one.style.backgroundPosition='top -34px left -94px'
}
for(var i=0;i<cc.length;i++){
if(data.result.future[i].weather=='晴'){
two[i].style.backgroundPosition='top 0px left -30px'
}else if(data.result.future[i].weather=='多云'){
two[i].style.backgroundPosition='top 0px left 0px'
}else if(data.result.future[i].weather=='阴天'){
two[i].style.backgroundPosition='0px left -60px'
}else if(data.result.future[i].weather=='小雨'){
two[i].style.backgroundPosition='top 0px left -93px'
}else if(data.result.future[i].weather=='大雨'){
two[i].style.backgroundPosition='top -34px left 0px'
}else if(data.result.future[i].weather=='大雨'){
two[i].style.backgroundPosition='top -34px left 0px'
}else if(data.result.future[i].weather=='雾'||data.result.future[i].weather=='霾'){
two[i].style.backgroundPosition='top -34px left -57px'
}else if(data.result.future[i].weather=='大雪'){
two[i].style.backgroundPosition='top -34px left -125px'
}else if(data.result.future[i].weather.indexOf('雨转阴')){
two[i].style.backgroundPosition='top -34px left -30px'
}else if (data.result.future[i].weather.indexOf('雨')){
two[i].style.backgroundPosition='top 0px left -93px'
}else if (data.result.future[i].weather.indexOf('雪')){
two[i].style.backgroundPosition='top -34px left -94px'
}
}
}
}
}
x("潍坊")
</script>
</body>
</html>