reprotManage_qxz_detailOld.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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>
  80. <div class="clearfix currTime">
  81. <div class="fl" id="gatherTime">采集时间:2019-15-13 12:26:54</div>
  82. <div class="fr" id="lookmore">更多>> </div>
  83. </div>
  84. <div class="qxzCategory">
  85. <div class="swiper-container">
  86. <div class="swiper-wrapper" id="swiperWrapper">
  87. <!--<div class="swiper-slide">
  88. <div>
  89. <img src="../images/dev/icon_106.png"/>
  90. <div class="">434</div>
  91. <div class="">二氧化碳(PPM)</div>
  92. </div>
  93. </div>
  94. <div class="swiper-slide">Slide 2</div>
  95. <div class="swiper-slide">Slide 3</div>
  96. <div class="swiper-slide">Slide 4</div>
  97. <div class="swiper-slide">Slide 5</div>
  98. <div class="swiper-slide">Slide 6</div>
  99. <div class="swiper-slide">Slide 7</div>-->
  100. </div>
  101. <!-- 如果需要导航按钮 -->
  102. <div class="swiper-button-prev"></div>
  103. <div class="swiper-button-next"></div>
  104. </div>
  105. </div>
  106. <div class="calendarBox" style="display:none">
  107. <p>开始时间:<input id="start" placeholder="Please Select ..." readonly /></p>
  108. <p>结束时间:<input id="end" placeholder="Please Select ..." readonly /></p>
  109. </div>
  110. </div>
  111. <script src="../js/mui.min.js"></script>
  112. <script src="../js/jquery-2.1.0.js"></script>
  113. <script src="../js/common.js"></script>
  114. <script src="../js/swiper.js"></script>
  115. <script src="../js/mobiscroll.custom-3.0.0-beta6.min.js" type="text/javascript" charset="utf-8"></script>
  116. <!-- ECharts单文件引入 -->
  117. <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
  118. <script type="text/javascript">
  119. // 路径配置
  120. require.config({
  121. paths: {
  122. echarts: 'http://echarts.baidu.com/build/dist'
  123. }
  124. });
  125. // 使用
  126. require(
  127. [
  128. 'echarts',
  129. 'echarts/chart/line' // 使用柱状图就加载bar模块,按需加载
  130. ],
  131. function (ec) {
  132. // 基于准备好的dom,初始化echarts图表
  133. var myChart = ec.init(document.getElementById('main'));
  134. // 为echarts对象加载数据
  135. myChart.setOption(echartOption());
  136. }
  137. );
  138. //echart option
  139. function echartOption(legend,upTime,seriesDat){
  140. var array = [];
  141. array.push(legend);
  142. return option = {
  143. tooltip: {
  144. show: true
  145. },
  146. legend: {
  147. data:array
  148. },
  149. grid:{
  150. x:'40px',
  151. y:'40px',
  152. x2:'10px',
  153. x2:'10px',
  154. borderWidth:0,
  155. borderColor:'rgba(0,0,0,0)'
  156. },
  157. dataZoom : {
  158. show : true,
  159. // backgroundColor:''
  160. },
  161. xAxis : [
  162. {
  163. axisLine: { // 坐标轴线
  164. show: false, // 默认显示,属性show控制显示与否
  165. },
  166. type : 'category',
  167. data : upTime,
  168. splitLine:{
  169.     show:false
  170.    },
  171. axisLabel: {
  172. textStyle: {
  173. color: '#fff',//坐标值得具体的颜色
  174. }
  175. }
  176. }
  177. ],
  178. yAxis : [
  179. {
  180. type : 'value',
  181. axisLine: { // 坐标轴线
  182. show: false, // 默认显示,属性show控制显示与否
  183. },
  184. axisLabel: {
  185. textStyle: {
  186. color: '#fff',//坐标值得具体的颜色
  187. }
  188. }
  189. }
  190. ],
  191. series : [
  192. {
  193. "name":legend,
  194. "type":"line",
  195. itemStyle : {
  196. normal : {
  197. color:'#61ecff',
  198. lineStyle:{
  199. color:'#61ecff'
  200. }
  201. }
  202. },
  203. "data":seriesDat
  204. }
  205. ]
  206. };
  207. }
  208. var equipId;
  209. mui.plusReady(function() {
  210. var self = plus.webview.currentWebview();
  211. equipId = self.equipId;
  212. $('#currEquipId').html('ID:'+equipId);
  213. requestData('','');
  214. //list详情
  215. document.getElementById('lookmore').addEventListener('tap',function(){
  216. mui.openWindow({
  217. url:'qxz_detail_list.html',
  218. id:'qxz_detail_list',
  219. extras: {
  220. equipId: equipId,
  221. // equipName:equipName
  222. }
  223. })
  224. })
  225. //日历
  226. mobiscroll.settings = {
  227. theme: 'ios'
  228. ,lang: 'zh',
  229. };
  230. $('#date').mobiscroll().range({
  231. startInput: '#start',
  232. endInput: '#end',
  233. onSet: function (event, inst) {
  234. var start = getYMDHMS(inst.getVal()[0]);
  235. var end = getYMDHMS(inst.getVal()[1]);
  236. //请求图表数据:
  237. requestData(start,end);
  238. },
  239. });
  240. function getYMDHMS(time) {
  241. var time = new Date(time);
  242. var year = time.getFullYear(),
  243. month = time.getMonth() + 1,
  244. date = time.getDate();
  245. if (month < 10) { month = '0' + month; }
  246. if (date < 10) { date = '0' + date; }
  247. return year+'/'+ month+'/'+ date //不想
  248. }
  249. })
  250. function requestData(begin,end) {
  251. mui.ajax('http://120.27.222.26/qxz_report_detail_chart', {
  252. data: {
  253. id: equipId,
  254. begin: begin,
  255. end: end,
  256. },
  257. dataType: 'json', //服务器返回json格式数据
  258. type: 'post', //HTTP请求类型
  259. timeout: 100000, //超时时间设置为10秒;
  260. beforeSend: function() {
  261. plus.nativeUI.showWaiting('请求中...');
  262. },
  263. complete: function() {
  264. plus.nativeUI.closeWaiting();
  265. },
  266. success: function(data) {
  267. collectData(data.dat)
  268. },
  269. error: function(xhr, type, errorThrown) {
  270. $('#currEquipId').hide();
  271. $('.detialBox').hide();
  272. $('#reloadEquip').hide();
  273. mui.toast('数据请求失败');
  274. }
  275. })
  276. }
  277. // 折线图处理
  278. var upTime;
  279. var kindCount;
  280. var seriesDat;
  281. var legend; //几条折线
  282. var allUnit; //单位
  283. var newVal; //最新一条值
  284. var icon;//图标
  285. function collectData(dat) {
  286. if (dat.length) {
  287. upTime = []; //
  288. kindCount = dat[0].e_len;
  289. seriesDat = [];
  290. legend = []; //几条折线
  291. allUnit = []; //单位
  292. txtUnit = [];
  293. newVal = []; //最新一条值
  294. icon = [];
  295. for (var i = 0; i < dat.length; i++) {
  296. upTime.unshift(dat[i].upl_time);
  297. for (var j = 0; j < dat[i].unit.length; j++) {
  298. if(i == 0){
  299. legend.push(dat[0].unit[j][3]+dat[0].unit[j][1]);
  300. allUnit.push(dat[0].unit[j][2]);
  301. txtUnit.push(dat[0].unit[j][1]);
  302. newVal.push(dat[0].unit[j][0]);
  303. icon.push(dat[0].unit[j][4]);
  304. }
  305. if(seriesDat[j]){
  306. seriesDat[j].unshift(parseFloat(dat[i].unit[j][0]));
  307. }else{
  308. var arr = [];
  309. arr.unshift(parseFloat(dat[i].unit[j][0]));
  310. seriesDat[j] = arr;
  311. }
  312. }
  313. if(i == dat.length-1){
  314. console.log(JSON.stringify(upTime))
  315. console.log(JSON.stringify(kindCount))
  316. console.log(JSON.stringify(seriesDat))
  317. console.log(JSON.stringify(legend))
  318. console.log(JSON.stringify(allUnit))
  319. console.log(JSON.stringify(txtUnit))
  320. console.log(JSON.stringify(newVal))
  321. console.log(JSON.stringify(icon))
  322. $('#gatherTime').html('采集时间:'+upTime[upTime.length-1])
  323. var html = '';
  324. for(var s = 0; s<legend.length;s++){
  325. html += '<div class="swiper-slide"><div><img src="../images/dev/icon_'+icon[s]+'.png"/>'+
  326. '<div class="newVal">'+newVal[s]+'</div><div class="">'+txtUnit[s]+'('+allUnit[s]+')</div></div></div>';
  327. if(s == legend.length-1){
  328. $('#swiperWrapper').html(html);
  329. var mySwiper = new Swiper ('.swiper-container', {
  330. slidesPerView: 3,
  331. spaceBetween: 30,
  332. pagination: {
  333. el: '.swiper-pagination',
  334. clickable: true,
  335. },
  336. // 如果需要前进后退按钮
  337. navigation: {
  338. nextEl: '.swiper-button-next',
  339. prevEl: '.swiper-button-prev',
  340. },
  341. on:{
  342. tap: function(event){
  343. if(this.clickedIndex != undefined){
  344. echartChange(this.clickedIndex);
  345. }
  346. },
  347. slideNextTransitionEnd: function(){
  348. echartChange(this.activeIndex);
  349. },
  350. slidePrevTransitionEnd: function(){
  351. echartChange(this.activeIndex);
  352. },
  353. },
  354. })
  355. }
  356. }
  357. echartChange(0)
  358. }
  359. }
  360. } else {
  361. $('#swiperWrapper').html('');
  362. // 非入口或再次使用,图表已被加载注册
  363. var echarts = require('echarts').init(document.getElementById('main'));
  364. echarts.setOption(echartOption([],[],[]));
  365. }
  366. }
  367. function echartChange(num){
  368. $('.swiper-wrapper .swiper-slide').removeClass('slideActiveBj');
  369. $('.swiper-wrapper .swiper-slide').eq(num).addClass('slideActiveBj');
  370. // 非入口或再次使用,图表已被加载注册
  371. var echarts = require('echarts').init(document.getElementById('main'));
  372. echarts.setOption(echartOption(legend[num],upTime,seriesDat[num]));
  373. }
  374. </script>
  375. </body>
  376. </html>