123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <html>
- <head>
- <title>screen_weather</title>
- <style type="text/css">
- *{margin: 0;padding: 0px;}
- </style>
- </head>
- <body>
- <div style="width: 128px;height: 256px;background: #000;padding-left: 4px;padding-top: 7px;">
- <p style="margin-bottom: 5px;"><span style='line-height:15px;color:#fff;' id="time">2019-05-31 15:28:08</span></p>
- <p style='font-size:14px;color:#fff;line-height:19px;height: 20px;'>
- <span>温度:</span><span class="c" style="margin-left: 19px;">28.2</span>(°C)<br />
- <span>湿度:</span><span class="t" style="margin-left: 19px;">37.2</span>(RH)<br />
- <span>PM10:</span><span class="pm10" style="margin-left: 10px;">37</span>(μg/m³)<br />
- <span>PM2.5:</span><span class="pm25" style="margin-left: 7px;">32</span>(μg/m³)<br />
- <span>光照度:</span><span class="ill" style="margin-left: 5px;">86412</span>(lux)<br />
- <span>噪声:</span><span class="db" style="margin-left: 19px;">63.3</span>(db)
- </p>
- </div>
- </body>
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
- <script type="text/javascript">
-
-
- $(function(){
- var time = document.getElementById('time');
- time.innerHTML = get_time();
- function get_time() {
- var myDate = new Date();
- var year = myDate.getFullYear();
- var month = myDate.getMonth() + 1;
- month = month < 10 ? '0'+month : month;
- var day = myDate.getDate();
- day = day < 10 ? '0'+day : day;
- var h = myDate.getHours();
- h = h < 10 ? '0'+h : h;
- var m = myDate.getMinutes();
- m = m < 10 ? '0'+m : m;
- var s = myDate.getSeconds();
- s = s < 10 ? '0'+s : s;
- return year+'-'+month+'-'+day+' '+h+':'+m+':'+s;
- }
- var t1=window.setInterval(refreshCount, 1000);
- function refreshCount() {
- $('#time').text(get_time());
- }
-
- var t2=window.setInterval(get_data, 60000);
- function get_data() {
- $.post('/api/common/screen_weather',{weatherId:<?php echo $weatherId?>},function(data){
- if (data.code == '0000') {
- $('.c').text(data.data.temperature);
- $('.t').text(data.data.humidity);
- $('.pm10').text(data.data.PM10);
- $('.pm25').text(data.data.PM25);
- $('.ill').text(data.data.illumination);
- $('.db').text(data.data.noise);
- }
- },'json');
- }
- $.post('/api/common/screen_weather',{weatherId:<?php echo $weatherId?>},function(data){
- if (data.code == '0000') {
- $('.c').text(data.data.temperature);
- $('.t').text(data.data.humidity);
- $('.pm10').text(data.data.PM10);
- $('.pm25').text(data.data.PM25);
- $('.ill').text(data.data.illumination);
- $('.db').text(data.data.noise);
- }
- },'json');
- })
- // ajax({
- // url:'/api/common/screen_weather',
- // type:'POST',
- // dataType:'json',
- // data:{weatherId:"27"},
- // success:function(response,xml){
- // //请求成功后执行的代码
- // },
- // error:function(status){
- // //失败后执行的代码
- // }
- // });
- // function ajax(options){
- // options=options||{};
- // // optoins.type=(options.type||'GET').toUpperCase();
- // options.dataType=options.dataType||'json';
- // params=formatParams(options.data);
- // //创建-第一步
- // var xhr;
- // //非IE6
- // if(window.XMLHttpRequest){
- // xhr=new XMLHttpRequest();
- // }else{
- // //ie6及其以下版本浏览器
- // xhr=ActiveXObject('Microsoft.XMLHTTP');
- // }
- // //接收-第三步
- // xhr.onreadystatechange=function(){
- // if(xhr.readyState==4){
- // var status=xhr.status;
- // if(status>=200&&status<300){
- // options.success&&options.success(xhr.responseText,xhr.responseXML);
- // }else{
- // options.error&&options.error(status);
- // }
- // }
- // }
- // //连接和发送-第二步
- // if(options.type=='GET'){
- // xhr.open('GET',options.url+'?'+params,true);
- // xhr.send(null);
- // }else if(options.type=='POST'){
- // xhr.open('POST',options.url,true);
- // //设置表单提交时的内容类型
- // xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- // xhr.send(params);
- // }
- // }
- // //格式化参数
- // function formatParams(data){
- // var arr=[];
- // for(var name in data){
- // arr.push(encodeURIComponent(name)+'='+encodeURIComponent(data[name]));
- // }
- // arr.push(('v='Math.random()).replace('.',''));
- // return arr.join('&');
- // }
-
- </script>
- </html>
|