reprotManage_qxz_detail.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
  8. <link href="../css/mui.min.css" rel="stylesheet" />
  9. <link rel="stylesheet" href="../css/reset.css" />
  10. <!--<link rel="stylesheet" href="../css/iconfont.css" />-->
  11. <link rel="stylesheet" href="../css/mobiscroll.custom-3.0.0-beta6.min.css">
  12. <link href="../css/common.css" rel="stylesheet" />
  13. <link href="../css/swiper.min.css" rel="stylesheet" />
  14. <style type="text/css">
  15. body,.qxzCategory{
  16. background: #7432fe;
  17. }
  18. .mui-bar-nav{
  19. box-shadow: 0 1px 6px #21b2e7;
  20. }
  21. .echart{
  22. background: linear-gradient(#21b2e7,#7600ff);
  23. }
  24. /**/
  25. .swiper-slide{
  26. height: 190px;
  27. }
  28. .swiper-slide >div{
  29. /*margin-top: 5px;*/
  30. height: 190px;
  31. text-align: center;
  32. border-radius:0 0 20px 20px;
  33. padding-bottom: 20px;
  34. color: #dbdbdb;
  35. font-size: 14px;
  36. }
  37. .swiper-slide >div >img{
  38. width: 40%;
  39. margin: 20px 0 40px;
  40. }
  41. .swiper-slide >div .newVal{
  42. font-size: 20px;
  43. }
  44. .slideActiveBj >div{
  45. background: #15a1ea;
  46. background: #24b2e7;
  47. }
  48. .swiper-button-next, .swiper-button-prev{
  49. width: 14px;
  50. height: 23px;
  51. background-size: cover;
  52. }
  53. .fl{
  54. float: left;
  55. }
  56. .fr{
  57. float: right;
  58. }
  59. .currTime{
  60. background: #7432fe;
  61. background: #24b2e7;
  62. color: #fff;
  63. line-height: 33px;
  64. font-size: 14px;
  65. }
  66. </style>
  67. </head>
  68. <body>
  69. <header class="mui-bar mui-bar-nav">
  70. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  71. <h1 class="mui-title" id="title">气象站数据详情</h1>
  72. <a class="mui-icon mui-icon-search mui-pull-right" id="date"></a>
  73. <!--<a class="headRightIcon fa fa-search mui-pull-right" id="reloadEquip">查询</a>-->
  74. </header>
  75. <div class="mui-content">
  76. <div class="echart">
  77. <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
  78. <div id="main" style="height:400px"></div>
  79. <div id="contentMain" style="height:400px"></div>
  80. </div>
  81. <div class="clearfix currTime">
  82. <div class="fl" id="gatherTime">采集时间:</div>
  83. <div class="fr" id="lookmore">更多>> </div>
  84. </div>
  85. <div class="qxzCategory">
  86. <div class="swiper-container">
  87. <div class="swiper-wrapper" id="swiperWrapper">
  88. <!--<div class="swiper-slide">
  89. <div>
  90. <img src="../images/dev/icon_106.png"/>
  91. <div class="">434</div>
  92. <div class="">二氧化碳(PPM)</div>
  93. </div>
  94. </div>
  95. <div class="swiper-slide">Slide 2</div>
  96. <div class="swiper-slide">Slide 3</div>
  97. <div class="swiper-slide">Slide 4</div>
  98. <div class="swiper-slide">Slide 5</div>
  99. <div class="swiper-slide">Slide 6</div>
  100. <div class="swiper-slide">Slide 7</div>-->
  101. </div>
  102. <!-- 如果需要导航按钮 -->
  103. <div class="swiper-button-prev"></div>
  104. <div class="swiper-button-next"></div>
  105. </div>
  106. </div>
  107. <div class="calendarBox" style="display:none">
  108. <p>开始时间:<input id="start" placeholder="Please Select ..." readonly /></p>
  109. <p>结束时间:<input id="end" placeholder="Please Select ..." readonly /></p>
  110. </div>
  111. </div>
  112. <script src="../js/mui.min.js"></script>
  113. <script src="../js/jquery-2.1.0.js"></script>
  114. <script src="../js/common.js"></script>
  115. <script src="../js/swiper.js"></script>
  116. <script src="../js/mobiscroll.custom-3.0.0-beta6.min.js" type="text/javascript" charset="utf-8"></script>
  117. <!-- ECharts单文件引入 -->
  118. <script src="../js/echarts.js"></script>
  119. <!-- <script src="http://echarts.baidu.com/build/dist/echarts.js"></script> -->
  120. <script type="text/javascript">
  121. // 路径配置
  122. // require.config({
  123. // paths: {
  124. // echarts: 'http://echarts.baidu.com/build/dist'
  125. // }
  126. // });
  127. // 使用
  128. // require(
  129. // [
  130. // 'echarts',
  131. // 'echarts/chart/line' // 使用柱状图就加载bar模块,按需加载
  132. // ],
  133. // function (ec) {
  134. // // 基于准备好的dom,初始化echarts图表
  135. // var myChart = ec.init(document.getElementById('main'));
  136. // // 为echarts对象加载数据
  137. // myChart.setOption(echartOption());
  138. // }
  139. // );
  140. var lineChart = echarts.init(document.getElementById('main'));
  141. var lineOption = echartOption();
  142. setTimeout(function() {
  143. lineChart.setOption(lineOption);
  144. })
  145. //echart option
  146. function echartOption(legend,upTime,seriesDat){
  147. var array = [];
  148. array.push(legend);
  149. return option = {
  150. tooltip: {
  151. trigger: 'axis',
  152. formatter: function(params) {
  153. var returnData = '';
  154. var time = '';
  155. for(var g in params) {
  156. time = params[g].axisValue;
  157. returnData += params[g].seriesName + ':' + params[g].value + '';
  158. }
  159. return time + '<br/>' + returnData;
  160. }
  161. },
  162. legend: {
  163. data:array
  164. },
  165. grid:{
  166. x:'40px',
  167. y:'40px',
  168. x2:'10px',
  169. x2:'10px',
  170. borderWidth:0,
  171. borderColor:'rgba(0,0,0,0)'
  172. },
  173. dataZoom : {
  174. type: 'inside',
  175. show : true,
  176. // backgroundColor:''
  177. },
  178. xAxis : [
  179. {
  180. axisLine: { // 坐标轴线
  181. show: false, // 默认显示,属性show控制显示与否
  182. },
  183. type : 'category',
  184. data : upTime,
  185. splitLine:{
  186.     show:false
  187.    },
  188. axisLabel: {
  189. textStyle: {
  190. color: '#fff',//坐标值得具体的颜色
  191. }
  192. }
  193. }
  194. ],
  195. yAxis : [
  196. {
  197. type : 'value',
  198. axisLine: { // 坐标轴线
  199. show: false, // 默认显示,属性show控制显示与否
  200. },
  201. axisLabel: {
  202. textStyle: {
  203. color: '#fff',//坐标值得具体的颜色
  204. }
  205. }
  206. }
  207. ],
  208. series : [
  209. {
  210. "name":legend,
  211. "type":"line",
  212. itemStyle : {
  213. normal : {
  214. color:'#61ecff',
  215. lineStyle:{
  216. color:'#61ecff'
  217. }
  218. }
  219. },
  220. "data":seriesDat
  221. }
  222. ]
  223. };
  224. }
  225. var equipId;
  226. mui.plusReady(function() {
  227. var self = plus.webview.currentWebview();
  228. equipId = self.equipId;
  229. $('#currEquipId').html('ID:'+equipId);
  230. requestData('','');
  231. //list详情
  232. document.getElementById('lookmore').addEventListener('tap',function(){
  233. mui.openWindow({
  234. url:'qxz_detail_list.html',
  235. id:'qxz_detail_list',
  236. extras: {
  237. equipId: equipId,
  238. // equipName:equipName
  239. }
  240. })
  241. })
  242. //日历
  243. mobiscroll.settings = {
  244. theme: 'ios'
  245. ,lang: 'zh',
  246. };
  247. $('#date').mobiscroll().range({
  248. startInput: '#start',
  249. endInput: '#end',
  250. onSet: function (event, inst) {
  251. var start = getYMDHMS(inst.getVal()[0]);
  252. var end = getYMDHMS(inst.getVal()[1]);
  253. //请求图表数据:
  254. requestData(start,end);
  255. },
  256. });
  257. function getYMDHMS(time) {
  258. var time = new Date(time);
  259. var year = time.getFullYear(),
  260. month = time.getMonth() + 1,
  261. date = time.getDate();
  262. if (month < 10) { month = '0' + month; }
  263. if (date < 10) { date = '0' + date; }
  264. return year+'/'+ month+'/'+ date //不想
  265. }
  266. })
  267. function requestData(begin,end) {
  268. mui.ajax('http://120.27.222.26/qxz_data_chart', {
  269. data: {
  270. 'e_id': equipId,
  271. 'begin': begin,
  272. 'end': end,
  273. },
  274. dataType: 'json', //服务器返回json格式数据
  275. type: 'post', //HTTP请求类型
  276. timeout: 100000, //超时时间设置为10秒;
  277. beforeSend: function() {
  278. plus.nativeUI.showWaiting('请求中...');
  279. },
  280. complete: function() {
  281. plus.nativeUI.closeWaiting();
  282. },
  283. success: function(data) {
  284. collectData(data)
  285. },
  286. error: function(xhr, type, errorThrown) {
  287. $('#currEquipId').hide();
  288. $('.detialBox').hide();
  289. $('#reloadEquip').hide();
  290. mui.toast('数据请求失败');
  291. }
  292. })
  293. }
  294. // 折线图处理
  295. var upTime;
  296. var kindCount;
  297. var seriesDat;
  298. var legend; //几条折线
  299. var allUnit; //单位
  300. var newVal; //最新一条值
  301. var icon;//图标
  302. function collectData(data) {
  303. var dat = data.data;
  304. var conf = data.conf;
  305. if (dat.length) {
  306. upTime = []; //
  307. kindCount = 0;
  308. seriesDat = [];
  309. legend = []; //几条折线
  310. allUnit = []; //单位
  311. txtUnit = [];
  312. newVal = []; //最新一条值
  313. icon = [];
  314. kindEkey = [];//通道号
  315. confLen = Object.keys(conf).length;
  316. for(var i = 1; i<=confLen;i++){
  317. kindCount++;
  318. var ekey = 'e'+ i;
  319. if(conf[ekey]){
  320. legend.push(ekey+conf[ekey].split('#')[0]);
  321. allUnit.push(conf[ekey].split('#')[1]);
  322. txtUnit.push(conf[ekey].split('#')[0]);
  323. kindEkey.push(ekey);
  324. seriesDat.push([])
  325. }
  326. if(i == confLen){
  327. for(var j = 0; j < dat.length;j++){
  328. upTime.unshift(dat[j].time);
  329. if(j == 0){
  330. for(var z = 0;z < kindEkey.length;z++){
  331. icon.push(dat[j].dat[kindEkey[z]].split('#')[1]);
  332. if(dat[j].dat[kindEkey[z]].split('#')[0] == -99.99){
  333. newVal.push('N/A');
  334. }else{
  335. newVal.push(dat[j].dat[kindEkey[z]].split('#')[0]);
  336. }
  337. }
  338. }
  339. for(var z = 0;z < kindEkey.length;z++){
  340. if(dat[j].dat[kindEkey[z]].split('#')[0] == -99.99){
  341. seriesDat[z].unshift('N/A');
  342. }else{
  343. seriesDat[z].unshift(dat[j].dat[kindEkey[z]].split('#')[0]);
  344. }
  345. }
  346. if(j == dat.length-1){
  347. $('#gatherTime').html('采集时间:'+upTime[upTime.length-1])
  348. var html = '';
  349. for(var s = 0; s<legend.length;s++){
  350. html += '<div class="swiper-slide"><div><img src="../images/dev/icon_'+icon[s]+'.png"/>'+
  351. '<div class="newVal">'+newVal[s]+'</div><div class="">'+txtUnit[s]+'('+allUnit[s]+')</div></div></div>';
  352. if(s == legend.length-1){
  353. $('#swiperWrapper').html(html);
  354. var mySwiper = new Swiper ('.swiper-container', {
  355. slidesPerView: 3,
  356. spaceBetween: 30,
  357. pagination: {
  358. el: '.swiper-pagination',
  359. clickable: true,
  360. },
  361. // 如果需要前进后退按钮
  362. navigation: {
  363. nextEl: '.swiper-button-next',
  364. prevEl: '.swiper-button-prev',
  365. },
  366. on:{
  367. tap: function(event){
  368. if(this.clickedIndex != undefined){
  369. echartChange(this.clickedIndex);
  370. }
  371. },
  372. slideNextTransitionEnd: function(){
  373. echartChange(this.activeIndex);
  374. },
  375. slidePrevTransitionEnd: function(){
  376. echartChange(this.activeIndex);
  377. },
  378. },
  379. })
  380. }
  381. }
  382. echartChange(0)
  383. }
  384. }
  385. }
  386. }
  387. } else {
  388. $('#swiperWrapper').html('');
  389. // 非入口或再次使用,图表已被加载注册
  390. var lineOption = echartOption([],[],[])
  391. lineChart.setOption(lineOption);
  392. var html = '<div style="text-align:center"> <span style="position: absolute;top: 40%;left: 0;right: 0;color:#868686; font-size: 20px;">暂无数据</span></div>'
  393. $('#main').hide();
  394. $('#contentMain').show();
  395. $('#contentMain').html(html);
  396. // document.getElementById('main').removeAttribute('_echarts_instance_')
  397. }
  398. }
  399. function echartChange(num){
  400. $('.swiper-wrapper .swiper-slide').removeClass('slideActiveBj');
  401. $('.swiper-wrapper .swiper-slide').eq(num).addClass('slideActiveBj');
  402. // 非入口或再次使用,图表已被加载注册
  403. var lineOption = echartOption(legend[num],upTime,seriesDat[num])
  404. lineChart.setOption(lineOption);
  405. $('#main').show();
  406. $('#contentMain').hide();
  407. // var echarts = require('echarts').init(document.getElementById('main'));
  408. // echarts.setOption(echartOption(legend[num],upTime,seriesDat[num]));
  409. }
  410. </script>
  411. </body>
  412. </html>