reprotManage_xyq_detail.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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 rel="stylesheet" href="../css/reset.css" />
  8. <link rel="stylesheet" href="../css/mui.min.css" />
  9. <link rel="stylesheet" href="../css/common.css" />
  10. <script src="../js/base.js" type="text/javascript" charset="utf-8"></script>
  11. <style type="text/css">
  12. .mui-content,
  13. body,
  14. html {
  15. background: #fff;
  16. }
  17. .mui-content{
  18. padding-bottom: 60px;
  19. }
  20. .echartsBox {
  21. height: 3.3rem;
  22. }
  23. .innerDiv {
  24. padding: .3rem;
  25. }
  26. .equipInfo>ul>li {
  27. line-height: 50px;
  28. overflow: hidden;
  29. }
  30. .equipInfo {
  31. margin: .2rem .3rem 0;
  32. }
  33. .equipInfo>ul>li>img {
  34. width: 41px;
  35. height: 41px;
  36. }
  37. .titleItem {
  38. margin-left: .4rem;
  39. color: #999;
  40. letter-spacing: .03rem;
  41. }
  42. .rightVal {
  43. float: right;
  44. height: 50px;
  45. line-height: 50px;
  46. }
  47. #operationBtns {
  48. position: fixed;
  49. left: 0;
  50. right: 0;
  51. bottom: 0;
  52. height: 50px;
  53. box-shadow: 1px 1px 4px #bfbfbf;
  54. background: #fff;
  55. }
  56. #operationBtns>div {
  57. width: 100%;
  58. height: 100%;
  59. text-align: center;
  60. }
  61. #operationBtns>div>span {
  62. width: 40%;
  63. display: inline-block;
  64. height: 40px;
  65. line-height: 40px;
  66. margin-top: 5px;
  67. color: #999;
  68. }
  69. #operationBtns>div .mui-icon {
  70. vertical-align: middle;
  71. }
  72. </style>
  73. </head>
  74. <body>
  75. <header class="mui-bar mui-bar-nav">
  76. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  77. <h1 class="mui-title">详情</h1>
  78. </header>
  79. <div class="mui-content">
  80. <div class="innerDiv">
  81. <div class="echartsBox">
  82. <div id="main" style="height:100%"></div>
  83. </div>
  84. <div class="equipInfo">
  85. <ul>
  86. <li>
  87. <img src="../images/xyqIcon1.png" />
  88. <span class="titleItem">设备ID</span>
  89. <span class="rightVal" id="equip_id"></span>
  90. </li>
  91. <li>
  92. <img src="../images/xyqIcon2.png" />
  93. <span class="titleItem">设备位置</span>
  94. <span class="rightVal" id="addr"></span>
  95. </li>
  96. <li>
  97. <img src="../images/xyqIcon3.png" />
  98. <span class="titleItem">环境温度</span>
  99. <span class="rightVal" id="tem"></span>
  100. </li>
  101. <li>
  102. <img src="../images/xyqIcon4.png" />
  103. <span class="titleItem">环境湿度</span>
  104. <span class="rightVal" id="hum"></span>
  105. </li>
  106. <li>
  107. <img src="../images/xyqIcon5.png" />
  108. <span class="titleItem">监测害虫名称</span>
  109. <span class="rightVal" id="pest"></span>
  110. </li>
  111. <li>
  112. <img src="../images/xyqIcon6.png" />
  113. <span class="titleItem">监测害虫数量</span>
  114. <span class="rightVal" id="pestnum"></span>
  115. </li>
  116. <li>
  117. <img src="../images/xyqIcon7.png" />
  118. <span class="titleItem">上报时间</span>
  119. <span class="rightVal" id="uplTime"></span>
  120. </li>
  121. </ul>
  122. </div>
  123. </div>
  124. <div id="operationBtns">
  125. <div id="">
  126. <span id="lookPicture">
  127. <span class="mui-icon mui-icon-image"></span> 查看图片
  128. </span>
  129. <span id="lookRecord">
  130. <span class="mui-icon mui-icon-list"></span> 历史记录
  131. </span>
  132. </div>
  133. </div>
  134. </div>
  135. <script src="../js/jquery-2.1.0.js"></script>
  136. <script src="../js/mui.min.js"></script>
  137. <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
  138. <script type="text/javascript">
  139. mui.init()
  140. var equipId;
  141. var dat;
  142. mui.plusReady(function() {
  143. var self = plus.webview.currentWebview();
  144. equipId = self.equipId;
  145. dat = JSON.parse(self.dat);
  146. fullData(dat);
  147. requestData();
  148. })
  149. function fullData(dat) {
  150. $('#equip_id').html(dat.equip_id)
  151. $('#addr').html(dat.addr)
  152. $('#tem').html(dat.tem + ' °C')
  153. $('#hum').html(dat.hum + ' RH')
  154. $('#pest').html(dat.pest)
  155. $('#pestnum').html(dat.pestnum + ' 只')
  156. $('#uplTime').html(dat.upl_time)
  157. }
  158. // 路径配置
  159. require.config({
  160. paths: {
  161. echarts: 'http://echarts.baidu.com/build/dist'
  162. }
  163. });
  164. // 使用
  165. require(
  166. [
  167. 'echarts',
  168. 'echarts/chart/line' // 使用柱状图就加载bar模块,按需加载
  169. ],
  170. function(ec) {
  171. // 基于准备好的dom,初始化echarts图表
  172. var myChart = ec.init(document.getElementById('main'));
  173. // 为echarts对象加载数据
  174. myChart.setOption(echartOption([], [], []));
  175. }
  176. );
  177. //echart option
  178. function echartOption(legend, upTime, series) {
  179. var array = [];
  180. array.push(legend);
  181. return option = {
  182. tooltip: {
  183. show: true,
  184. trigger: 'axis',
  185. },
  186. legend: {
  187. data: legend
  188. },
  189. grid: {
  190. x: '40px',
  191. y: '40px',
  192. x2: '10px',
  193. x2: '10px',
  194. borderWidth: 0,
  195. borderColor: 'rgba(0,0,0,0)'
  196. },
  197. dataZoom: {
  198. show: true,
  199. // backgroundColor:''
  200. },
  201. xAxis: [{
  202. axisLine: { // 坐标轴线
  203. // show: false, // 默认显示,属性show控制显示与否
  204. },
  205. type: 'category',
  206. data: upTime,
  207. splitLine: {    
  208. show: false  
  209. },
  210. // axisLabel: {
  211. // textStyle: {
  212. // color: '#fff', //坐标值得具体的颜色
  213. //
  214. // }
  215. // }
  216. }
  217. ],
  218. yAxis: [{
  219. type: 'value',
  220. axisLine: { // 坐标轴线
  221. show: false, // 默认显示,属性show控制显示与否
  222. },
  223. axisLabel: {
  224. textStyle: {
  225. // color: '#fff', //坐标值得具体的颜色
  226. }
  227. }
  228. }],
  229. // series: [{
  230. // "name": legend,
  231. // "type": "line",
  232. // itemStyle: {
  233. // normal: {
  234. // color: '#61ecff',
  235. // lineStyle: {
  236. // color: '#61ecff'
  237. // }
  238. // }
  239. // },
  240. // "data": seriesDat
  241. // }]
  242. series: series
  243. };
  244. }
  245. function requestData() {
  246. mui.ajax('http://120.27.222.26/xyq_report_detail_chart', {
  247. data: {
  248. req: 'data',
  249. id: equipId,
  250. },
  251. dataType: 'json', //服务器返回json格式数据
  252. type: 'post', //HTTP请求类型
  253. timeout: 100000, //超时时间设置为10秒;
  254. beforeSend: function() {
  255. plus.nativeUI.showWaiting('请求中...');
  256. },
  257. complete: function() {
  258. plus.nativeUI.closeWaiting();
  259. },
  260. success: function(data) {
  261. collectData(data)
  262. },
  263. error: function(xhr, type, errorThrown) {
  264. $('#currEquipId').hide();
  265. $('.detialBox').hide();
  266. $('#reloadEquip').hide();
  267. mui.toast('数据请求失败');
  268. }
  269. })
  270. }
  271. var color = ['#5689f2', '#00c1de', '#db1f59', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800'];
  272. function collectData(dat) {
  273. var at = [],
  274. ah = [],
  275. pestnum = [],
  276. time = [],
  277. legend = ['环境温度', '环境湿度', ''];
  278. var allVal = [];
  279. if(dat.length) {
  280. legend = ['环境温度', '环境湿度', dat[0].pest];
  281. for(var i = 0; i < dat.length; i++) {
  282. at.unshift(dat[i].at);
  283. ah.unshift(dat[i].ah);
  284. pestnum.unshift(dat[i].pestnum);
  285. time.unshift(dat[i].upl_time);
  286. if(i == dat.length - 1) {
  287. allVal.push(at)
  288. allVal.push(ah)
  289. allVal.push(pestnum);
  290. var seriesArr = [];
  291. for(var j = 0; j < allVal.length; j++) {
  292. var jsonStr = {
  293. "name": legend[j],
  294. "type": "line",
  295. itemStyle: {
  296. normal: {
  297. color: color[j],
  298. shadowBlur: 1,
  299. shadowColor: color[j],
  300. borderColor: color[j],
  301. borderWidth: 2,
  302. backgroundColor: 'transparent'
  303. }
  304. },
  305. areaStyle: {
  306. normal: {
  307. color: color[j],
  308. }
  309. },
  310. "data": allVal[j]
  311. }
  312. seriesArr.push(jsonStr);
  313. if(j == allVal.length - 1) {
  314. // 非入口或再次使用,图表已被加载注册
  315. var echarts = require('echarts').init(document.getElementById('main'));
  316. echarts.setOption(echartOption(legend, time, seriesArr));
  317. }
  318. }
  319. }
  320. }
  321. } else {
  322. // 非入口或再次使用,图表已被加载注册
  323. var echarts = require('echarts').init(document.getElementById('main'));
  324. var seriesArr = {
  325. "name": [],
  326. "type": "line",
  327. itemStyle: {
  328. normal: {
  329. color: color[j],
  330. shadowBlur: 1,
  331. shadowColor: color[j],
  332. borderColor: color[j],
  333. borderWidth: 2,
  334. backgroundColor: 'transparent'
  335. }
  336. },
  337. "data": []
  338. }
  339. echarts.setOption(echartOption([], [], [seriesArr]));
  340. }
  341. }
  342. $('#lookPicture').on('tap',function(){
  343. mui.openWindow({
  344. url: 'reprotManage_xyq_imglist.html',
  345. id: 'reprotManage_xyq_imglist',
  346. extras: {
  347. 'equipId': equipId,
  348. },
  349. })
  350. })
  351. $('#lookRecord').on('tap',function(){
  352. mui.openWindow({
  353. url: 'reprotManage_xyq_recordlist.html',
  354. id: 'reprotManage_xyq_recordlist',
  355. extras: {
  356. 'equipId': equipId,
  357. },
  358. })
  359. })
  360. </script>
  361. </body>
  362. </html>