bigScreen.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. // 1框
  2. $.ajax({
  3. url: 'user_display',
  4. type: 'post',
  5. data: {},
  6. dataType: 'json',
  7. success: function (data) {
  8. console.log(data)
  9. fillBase(data)
  10. $('.exampleImg').attr('src', 'http://120.27.222.26/' + data.basephoto);
  11. $('#baseName').html(data.basename || '展示基地')
  12. //删除加载动画
  13. $('#load').fadeOut(6000)
  14. setTimeout(function () {
  15. $('#load').remove()
  16. }
  17. , 6000);
  18. },
  19. error: function (type) {
  20. console.log(type)
  21. }
  22. })
  23. // 填充基地信息+第一次设备数据请求
  24. function fillBase(data) {
  25. var cbdList = '', jkList = '', bzyList = '', qxzList = '';
  26. var cbdNum = 0, jkNum = 0, bzyNum = 0, qxzNum = 0;
  27. var dat = data.dat;
  28. for (var i = 0; i < dat.length; i++) {
  29. var id = dat[i].e_id.substring(dat[i].e_id.length - 8);
  30. if (dat[i].equip_type == 3) {
  31. cbdList += '<option value="' + dat[i].e_id + '">测报灯' + id + '</option>';
  32. cbdNum++;
  33. } else if (dat[i].equip_type == 5) {
  34. qxzList += '<option value="' + dat[i].e_id + '">环境监测' + id + '</option>';
  35. qxzNum++;
  36. } else if (dat[i].equip_type == 6) {
  37. jkList += '<option value="' + dat[i].e_id + '">监 控' + id + '</option>';
  38. jkNum++;
  39. } else if (dat[i].equip_type == 7) {
  40. bzyList += '<option value="' + dat[i].e_id + '">孢子仪' + id + '</option>';
  41. bzyNum++;
  42. }
  43. if (i == dat.length - 1) {
  44. $('#cbdList').html(cbdList).next().html(cbdNum + '台');
  45. $('#jkList').html(jkList).next().html(jkNum + '台');
  46. $('#bzyList').html(bzyList).next().html(bzyNum + '台');
  47. $('#qxzList').html(qxzList).next().html(qxzNum + '台');
  48. getCbdInfo($('#cbdList').val())
  49. if (fls.f) { //安装了flash
  50. $('.jkinner').show();
  51. $('.flashDownDiv').hide();
  52. getjkPath($('#jkList').val())
  53. } else {
  54. $('.jkinner').hide();
  55. $('.flashDownDiv').show();
  56. }
  57. getBzyInfo($('#bzyList').val())
  58. getQxzInfo($('#qxzList').val())
  59. // cbdchange
  60. $('#cbdList').on('change', function () {
  61. var id = $(this).val()
  62. layui.use('layer', function () {
  63. var layer = layui.layer;
  64. layer.confirm('是否切换当前测报灯设备', {
  65. title: false,
  66. closeBtn: 0,
  67. btn: ['确定', '取消'] //按钮
  68. }, function () {
  69. getCbdInfo(id);
  70. layer.close(layer.index)
  71. }, function () {
  72. });
  73. })
  74. })
  75. // jkchange
  76. $('#jkList').on('change', function () {
  77. var id = $(this).val()
  78. layui.use('layer', function () {
  79. var layer = layui.layer;
  80. layer.confirm('是否切换当前显示监控', {
  81. title: false,
  82. closeBtn: 0,
  83. btn: ['确定', '取消'] //按钮
  84. }, function () {
  85. getjkPath(id);
  86. layer.close(layer.index)
  87. }, function () {
  88. });
  89. })
  90. })
  91. // bzychange
  92. $('#bzyList').on('change', function () {
  93. var id = $(this).val()
  94. layui.use('layer', function () {
  95. var layer = layui.layer;
  96. layer.confirm('是否切换当前孢子仪设备', {
  97. title: false,
  98. closeBtn: 0,
  99. btn: ['确定', '取消'] //按钮
  100. }, function () {
  101. getBzyInfo(id);
  102. layer.close(layer.index)
  103. }, function () {
  104. });
  105. })
  106. })
  107. // qxzchange
  108. $('#qxzList').on('change', function () {
  109. var id = $(this).val()
  110. layui.use('layer', function () {
  111. var layer = layui.layer;
  112. layer.confirm('是否切换当前环境监测设备', {
  113. title: false,
  114. closeBtn: 0,
  115. btn: ['确定', '取消'] //按钮
  116. }, function () {
  117. getQxzInfo(id);
  118. layer.close(layer.index)
  119. }, function () {
  120. });
  121. })
  122. })
  123. // 查看设备分布
  124. $('.equipTotal').on('click',function(){
  125. var url = 'display_map?type='+$(this).attr('type');
  126. if($(this).attr('type') == 3 || $(this).attr('type') == 7 || $(this).attr('type') == 'all'){
  127. layui.use('layer', function () {
  128. var layer = layui.layer;
  129. layer.open({
  130. type: 2,
  131. title: '',
  132. shadeClose: true,
  133. shade: 0.5,
  134. area: ['1100px', '90%'],
  135. skin: 'layer-test', //自定义class
  136. content: url //iframe的url
  137. })
  138. })
  139. }else{
  140. layui.use('layer', function () {
  141. var layer = layui.layer;
  142. layer.msg('定位功能暂未开启', {time: 2000, icon:4});
  143. })
  144. }
  145. console.log($(this).attr('type'))
  146. })
  147. }
  148. }
  149. }
  150. // 2框
  151. var cbdPhotoList;
  152. function getCbdInfo(id) {
  153. $.ajax({
  154. url: 'cbd_display',
  155. type: 'post',
  156. data: {
  157. imei: id
  158. },
  159. dataType: 'json',
  160. success: function (data) {
  161. fillCbdData(data);
  162. fillCbdChart(data);
  163. fillCbdPhoto(data);
  164. cbdPhotoList = data.photolist
  165. },
  166. error: function (type) {
  167. $('#ts').html('--');
  168. $('#rps').html('--');
  169. $('#lps').html('--');
  170. $('#tps').html('--');
  171. $('#gs').html('--');
  172. $('#hs').html('--');
  173. $('#csq').html('--');
  174. }
  175. })
  176. }
  177. function fillCbdData(data) {
  178. var status = eval('(' + data.status + ')');
  179. var onoff = data.is_online ? '在线' : '离线';
  180. $('#onoff').html(onoff);
  181. var ts = status.ts ? '时控' : '光控';
  182. $('#ts').html(ts);
  183. var rps = status.rps ? '雨控' : '正常';
  184. $('#rps').html(rps);
  185. var lps = status.lps ? '黑夜' : '白天';
  186. $('#lps').html(lps);
  187. var tps = status.tps ? '温控' : '正常';
  188. $('#tps').html(tps);
  189. var gs = status.gs ? '落虫' : '排水';
  190. $('#gs').html(gs);
  191. var hs = status.hs ? '加热' : '正常';
  192. $('#hs').html(hs);
  193. $('#csq').html(status.csq);
  194. }
  195. // 3框
  196. var myChart = echarts.init(document.getElementById('echarts'));
  197. // 指定图表的配置项和数据
  198. option = {
  199. tooltip: {
  200. trigger: 'axis',
  201. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  202. type: 'line', // 默认为直线,可选为:'line' | 'shadow'
  203. lineStyle: { // 直线指示器样式设置
  204. color: '#fff',
  205. width: 2,
  206. type: 'solid'
  207. },
  208. shadowStyle: { // 阴影指示器样式设置
  209. width: 'auto', // 阴影大小
  210. color: 'rgba(150,150,150,0.3)' // 阴影颜色
  211. }
  212. },
  213. },
  214. legend: {
  215. data: ['温度', '湿度', '害虫数量'],
  216. x: 'right',
  217. textStyle: {//图例文字的样式
  218. color: '#ccc',
  219. fontSize: 12
  220. }
  221. },
  222. toolbox: {
  223. show: true,
  224. feature: {
  225. // mark: { show: true },
  226. // dataView: { show: true, readOnly: false },
  227. // magicType: { show: true, type: ['line', 'bar'] },
  228. // restore: { show: true },
  229. // saveAsImage: { show: true }
  230. }
  231. },
  232. grid: {
  233. x: '30',
  234. y: '30',
  235. x2: '30',
  236. y2: '30'
  237. },
  238. dataZoom: {
  239. show: false,
  240. realtime: true,
  241. dataBackgroundColor: 'rgba(144,197,237,0.2)'
  242. // fillerColor:'rgba(0,0,0,0)'
  243. },
  244. xAxis: {
  245. type: 'category',
  246. boundaryGap: false,
  247. data: [],
  248. axisLine: { lineStyle: { color: "#2b8dc2" } }
  249. },
  250. yAxis: {
  251. type: 'value',
  252. axisLine: { lineStyle: { color: "#2b8dc2" } },
  253. splitLine: { show: false }
  254. },
  255. // color: ['#2d92c6'],
  256. series: []
  257. };
  258. myChart.setOption(option);
  259. function fillCbdChart(data) {
  260. var pestlist = data.pestlist;
  261. var val = [];
  262. var time = [];
  263. var at = [], ah = [];
  264. if (pestlist.length) {
  265. for (var i = 0; i < pestlist.length; i++) {
  266. time.unshift(pestlist[i].time);
  267. at.unshift((pestlist[i].at / 10).toFixed(1));
  268. ah.unshift((pestlist[i].ah / 10).toFixed(1));
  269. var pestall = pestlist[i].pest.split('#');
  270. var num = 0;
  271. for (var z = 0; z < pestall.length; z++) {
  272. var pest = pestall[z].split(',');
  273. num += parseInt(pest[1]);
  274. if (z == pestall.length - 1) {
  275. val.unshift(num);
  276. }
  277. }
  278. if (i == pestlist.length - 1) {
  279. var allval = [];
  280. allval.push(at)
  281. allval.push(ah)
  282. allval.push(val)
  283. var color = ['green', 'yellow', 'red'];
  284. var legend = ['温度', '湿度', '害虫数量']
  285. myChart.clear();
  286. option.series = [];
  287. option.xAxis.data = time;
  288. for (s = 0; s < 3; s++) {
  289. option.series.unshift({
  290. name: legend[s],
  291. type: 'line',
  292. data: allval[s],
  293. smooth: true,
  294. itemStyle: {
  295. normal: {
  296. color: color[s],
  297. shadowBlur: 1,
  298. shadowColor: color[s],
  299. borderColor: color[s],
  300. borderWidth: 2,
  301. backgroundColor: 'transparent'
  302. }
  303. },
  304. areaStyle: {
  305. normal: {
  306. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  307. offset: 0,
  308. color: color[s]
  309. }, {
  310. offset: 1,
  311. color: 'rgba(255, 2555, 255, 0.2)'
  312. }]),
  313. }
  314. }
  315. });
  316. if (s == 2) {
  317. myChart.setOption(option);
  318. }
  319. }
  320. }
  321. }
  322. }else{
  323. myChart.setOption(option);
  324. }
  325. }
  326. // 4框
  327. // 判断是否启用flash
  328. function flashChecker() {
  329. var hasFlash = 0;     //是否安装了flash
  330. var flashVersion = 0;   //flash版本
  331. if (document.all) {
  332. var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  333. if (swf) {
  334. hasFlash = 1;
  335. VSwf = swf.GetVariable("$version");
  336. flashVersion = parseInt(VSwf.split(" ")[1].split(",")[0]);
  337. }
  338. } else {
  339. if (navigator.plugins && navigator.plugins.length > 0) {
  340. var swf = navigator.plugins["Shockwave Flash"];
  341. if (swf) {
  342. hasFlash = 1;
  343. var words = swf.description.split(" ");
  344. for (var i = 0; i < words.length; ++i) {
  345. if (isNaN(parseInt(words[i]))) {
  346. continue;
  347. }
  348. flashVersion = parseInt(words[i]);
  349. }
  350. }
  351. }
  352. }
  353. return {
  354. f: hasFlash,
  355. v: flashVersion
  356. };
  357. }
  358. var fls = flashChecker();
  359. function getcbdInfo(id) {
  360. $.ajax({
  361. url: 'user_display',
  362. type: 'post',
  363. data: {},
  364. dataType: 'json',
  365. success: function (data) {
  366. fillBase(data)
  367. },
  368. error: function (type) {
  369. console.log(type)
  370. }
  371. })
  372. }
  373. function getjkPath(id) {
  374. $.ajax({
  375. url: 'jk_view',
  376. type: 'get',
  377. data: {
  378. imei: id
  379. },
  380. dataType: 'json',
  381. success: function (data) {
  382. var dat = data[0].data[0];
  383. if (data[0].code == 200) {
  384. StartPlay(dat.deviceSerial, '', '', dat.rtmpHd, dat.hlsHd, dat.deviceSerial, '', '', null)
  385. }
  386. }
  387. })
  388. }
  389. //预览函数
  390. function StartPlay(id, connectionType, liveStatus, rtmp, hls, deviceSerial, cameraNo, title, obj) {
  391. var playHtml = "<video id='myPlayer' class='videoNum' poster='' controls playsinline webkit-playsinline autoplay style='width:100%;height: 100%;'>";
  392. playHtml += "<source src='" + rtmp + "' type='' />";
  393. playHtml += "</video>";
  394. var script = document.createElement("script");
  395. script.type = "text/javascript";
  396. script.appendChild(document.createTextNode(" new EZUIPlayer('myPlayer');"));
  397. $('.videobox').html(playHtml);
  398. $('body').append(script);
  399. }
  400. // 控制
  401. function configCamera(deviceSerial, ctrl, movenum) {
  402. var id = $('#jkList').val();
  403. if (!id) {
  404. layer.msg('暂无设备!')
  405. return;
  406. }
  407. $.ajax({
  408. url: 'jk_view',
  409. type: 'post',
  410. dataType: 'json',
  411. data: {
  412. id: id,
  413. ctrl: ctrl,
  414. movenum: movenum
  415. },
  416. success: function (data) {
  417. if (ctrl == 'takephoto') {
  418. layui.use('layer', function () {
  419. var layer = layui.layer;
  420. layer.open({
  421. title: '手动下载'
  422. , content: '<textarea readonly id="downpath">' + data.data.picUrl + '</textarea>'
  423. , btn: ['复制', '取消']
  424. , area: ['400px', '230px']
  425. , yes: function (index, layero) {
  426. //按钮【按钮一】的回调
  427. document.getElementById('downpath').select();
  428. layer.tips('手动复制,在浏览器打开,另存为', '#downpath', {
  429. tips: 2
  430. });
  431. return false;
  432. }
  433. , btn2: function (index, layero) {
  434. //按钮【按钮二】的回调
  435. //return false 开启该代码可禁止点击该按钮关闭
  436. }
  437. , btn3: function (index, layero) {
  438. }
  439. , cancel: function () {
  440. //右上角关闭回调
  441. //return false 开启该代码可禁止点击该按钮关闭
  442. }
  443. });
  444. });
  445. // window.open(data.data.picUrl)
  446. }
  447. }
  448. })
  449. }
  450. // 5框
  451. var bzyPhotoList;
  452. function getBzyInfo(id) {
  453. $.ajax({
  454. url: 'bzy_display',
  455. type: 'post',
  456. data: {
  457. imei: id
  458. },
  459. dataType: 'json',
  460. success: function (data) {
  461. bzyPhotoList = data.photolist
  462. fillBzyData(data)
  463. fillBzyPhoto(data)
  464. },
  465. error: function (type) {
  466. $('#ts').html('--');
  467. $('#rps').html('--');
  468. $('#lps').html('--');
  469. $('#tps').html('--');
  470. $('#gs').html('--');
  471. $('#hs').html('--');
  472. $('#csq').html('--');
  473. }
  474. })
  475. }
  476. function fillBzyData(data) {
  477. var status = eval('(' + data.status + ')');
  478. var onoff = data.is_online ? '在线' : '离线';
  479. $('#bzyonoff').html(onoff);
  480. var bzyswitch = status.on_off ? '开启' : '关闭';
  481. $('#bzyswitch').html(bzyswitch);
  482. var bzybat_sta = status.bat_sta ? '电量过低' : '正常';
  483. $('#bzybat_sta').html(bzybat_sta);
  484. var bzyusb_sta = status.usb_sta ? '异常' : '正常';
  485. $('#bzyusb_sta').html(bzyusb_sta);
  486. $('#bzyv_bat').html(parseFloat(status.v_bat).toFixed(2));
  487. $('#bzypre_temp').html(status.pre_temp);
  488. $('#bzycsq').html(status.csq);
  489. $('#bzydver').html(status.dver);
  490. var bzyrps = status.rps ? '雨控' : '正常';
  491. $('#bzyrps').html(bzyrps);
  492. }
  493. // 6框
  494. function fillBzyPhoto(data) {
  495. var photos = data.photolist;
  496. $('#bzyPhoto1').attr('src', 'http://120.27.222.26/bzy/' + photos[0]);
  497. $('#bzyPhoto2').attr('src', 'http://120.27.222.26/bzy/' + photos[1]);
  498. $('#bzyPhoto3').attr('src', 'http://120.27.222.26/bzy/' + photos[2]);
  499. }
  500. // 查看图片列表
  501. $('.bzyphotodiv').on('click', function () {
  502. var data = [];
  503. for (var i = 0; i < bzyPhotoList.length; i++) {
  504. var dat = {
  505. "src": "http://120.27.222.26/bzy/" + bzyPhotoList[i], //原图地址
  506. "thumb": "http://120.27.222.26/bzy/" + bzyPhotoList[i] //缩略图地址
  507. }
  508. data.push(dat);
  509. }
  510. layui.use('layer', function () {
  511. var layer = layui.layer;
  512. json = {
  513. "title": "", //相册标题
  514. "id": 123, //相册id
  515. "start": 0, //初始显示的图片序号,默认0
  516. "data": data
  517. }
  518. layer.photos({
  519. photos: json
  520. , anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  521. , shadeClose: false
  522. , shade: [0.8, '#393D49']
  523. , closeBtn: 1
  524. });
  525. });
  526. })
  527. // 查看图片列表
  528. $('.cbdphotodiv').on('click', function () {
  529. var data = [];
  530. for (var i = 0; i < cbdPhotoList.length; i++) {
  531. var dat = {
  532. "src": "http://120.27.222.26/" + cbdPhotoList[i], //原图地址
  533. "thumb": "http://120.27.222.26/" + cbdPhotoList[i] //缩略图地址
  534. }
  535. data.push(dat);
  536. }
  537. layui.use('layer', function () {
  538. var layer = layui.layer;
  539. json = {
  540. "title": "", //相册标题
  541. "id": 123, //相册id
  542. "start": 0, //初始显示的图片序号,默认0
  543. "data": data
  544. }
  545. layer.photos({
  546. photos: json
  547. , anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  548. , shadeClose: false
  549. , shade: [0.8, '#393D49']
  550. , closeBtn: 1
  551. });
  552. });
  553. })
  554. // 7框
  555. function fillCbdPhoto(data) {
  556. var photos = data.photolist;
  557. $('#cbdPhoto1').attr('src', 'http://120.27.222.26/' + photos[0]);
  558. $('#cbdPhoto2').attr('src', 'http://120.27.222.26/' + photos[1]);
  559. $('#cbdPhoto3').attr('src', 'http://120.27.222.26/' + photos[2]);
  560. }
  561. // 8框
  562. function getQxzInfo(id) {
  563. $.ajax({
  564. url: 'qxz_display',
  565. type: 'post',
  566. data: {
  567. imei: id
  568. },
  569. dataType: 'json',
  570. success: function (data) {
  571. assembleQxzData(data.dat)
  572. },
  573. error: function (type) {
  574. $('#ts').html('--');
  575. $('#rps').html('--');
  576. $('#lps').html('--');
  577. $('#tps').html('--');
  578. $('#gs').html('--');
  579. $('#hs').html('--');
  580. $('#csq').html('--');
  581. }
  582. })
  583. }
  584. function assembleQxzData(data) {
  585. var category = []; //要素种类
  586. var chartVal = []; //包含时间和值
  587. if (data.length) {
  588. for (var i = 0; i < data.length; i++) {
  589. for (var z = 0; z < data[i].unit.length; z++) {
  590. if (category.indexOf(data[i].unit[z][4]) == -1) {
  591. category.push(data[i].unit[z][4])
  592. var dat = {
  593. val: [data[i].unit[z][0]],
  594. time: [data[i].upl_time],
  595. txt: data[i].unit[z][1],
  596. unit: data[i].unit[z][2],
  597. num: data[i].unit[z][4],
  598. }
  599. chartVal.push(dat)
  600. } else {
  601. chartVal[category.indexOf(data[i].unit[z][4])].val.unshift(data[i].unit[z][0]);
  602. chartVal[category.indexOf(data[i].unit[z][4])].time.unshift(data[i].upl_time);
  603. }
  604. }
  605. if (i == data.length - 1) {
  606. fillQxzData(chartVal);
  607. }
  608. }
  609. } else {
  610. qxzbarchart.clear();
  611. qxzoption.series = [];
  612. qxzoption.xAxis[0].data = [];
  613. qxzbarchart.setOption(qxzoption);
  614. }
  615. }
  616. function fillQxzData(data) {
  617. var str = '<div class="swiper-wrapper">';
  618. for (var i = 0; i < data.length; i++) {
  619. str += '<div class="swiper-slide"><div>' +
  620. '<img src="../static/bigData/image/dev/icon_' + data[i].num + '.png" alt="" width="36">' +
  621. '<div class="qxzItemInfo"><p>' + data[i].txt + '</p><div>' + data[i].val[data[i].val.length - 1] + data[i].unit + '</div>' +
  622. '</div></div></div>';
  623. if (i == data.length - 1) {
  624. str += '</div>';
  625. $('.qxzSwiperContent').html(str);
  626. var swiper = new Swiper('.qxzItem', {
  627. direction: 'vertical',
  628. slidesPerView: 3,
  629. autoplay: {
  630. delay: 5000
  631. },//可选选项,自动滑动
  632. // centeredSlides: true,
  633. // loop: true,
  634. // navigation: {
  635. // nextEl: '.swiper-button-next',
  636. // prevEl: '.swiper-button-prev',
  637. // },
  638. on: {
  639. slideChange: function () {
  640. console.log(this)
  641. $('.swiper-slide .qxzItemInfo').css('color', '#2eb0c4');
  642. $(this.slides[this.activeIndex]).find('.qxzItemInfo').css('color', '#f6ee0b');
  643. fillQxzChart(data, this.activeIndex);
  644. },
  645. click: function () {
  646. console.log(this);
  647. // if (this.clickedSlide) {
  648. $('.swiper-slide .qxzItemInfo').css('color', '#2eb0c4');
  649. $(this.clickedSlide).find('.qxzItemInfo').css('color', '#f6ee0b');
  650. fillQxzChart(data, this.clickedIndex);
  651. // }
  652. },
  653. },
  654. });
  655. fillQxzChart(data, 0);
  656. }
  657. }
  658. }
  659. var qxzbarchart = echarts.init(document.getElementById('qxzbarchart'));
  660. // 指定图表的配置项和数据
  661. qxzoption = {
  662. color: ['#3398DB'],
  663. legend: {
  664. data: [],
  665. x: 'right',
  666. textStyle: {//图例文字的样式
  667. color: '#ccc',
  668. fontSize: 12
  669. }
  670. },
  671. tooltip: {
  672. trigger: 'axis',
  673. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  674. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  675. }
  676. },
  677. grid: {
  678. x: '30',
  679. y: '30',
  680. x2: '30',
  681. y2: '30'
  682. },
  683. xAxis: [
  684. {
  685. type: 'category',
  686. data: [],
  687. // axisTick: {
  688. // alignWithLabel: true
  689. // },
  690. axisLine: { lineStyle: { color: "#2b8dc2" } }
  691. }
  692. ],
  693. yAxis: [
  694. {
  695. type: 'value',
  696. axisLine: { lineStyle: { color: "#2b8dc2" } },
  697. splitLine: { show: false }
  698. }
  699. ],
  700. series: []
  701. };
  702. // qxzbarchart.setOption(qxzoption);
  703. function fillQxzChart(data, idx) {
  704. qxzbarchart.clear();
  705. qxzoption.series = [];
  706. qxzoption.xAxis[0].data = data[idx].time;
  707. qxzoption.legend = { data: [data[idx].txt], x: 'right', textStyle: { color: '#ccc', fontSize: 12 } }
  708. qxzoption.series = [
  709. {
  710. name: data[idx].txt,
  711. type: 'bar',
  712. barWidth: '60%',
  713. data: data[idx].val
  714. }
  715. ];
  716. qxzbarchart.setOption(qxzoption);
  717. }
  718. window.onresize = function () {
  719. myChart.resize();
  720. qxzbarchart.resize();
  721. getjkPath($('#jkList').val())
  722. }
  723. var map = new AMap.Map('container', {
  724. resizeEnable: true
  725. });
  726. if($('#userCurrCity').val()){
  727. onComplete($('#userCurrCity').val())
  728. }else{
  729. AMap.plugin('AMap.Geolocation', function () {
  730. var geolocation = new AMap.Geolocation({
  731. enableHighAccuracy: true,//是否使用高精度定位,默认:true
  732. timeout: 10000, //超过10秒后停止定位,默认:5s
  733. buttonPosition: 'RB', //定位按钮的停靠位置
  734. buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
  735. zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点
  736. });
  737. map.addControl(geolocation);
  738. geolocation.getCurrentPosition(function (status, result) {
  739. if (status == 'complete') {
  740. onComplete(result.addressComponent.city)
  741. } else {
  742. onComplete('郑州市')
  743. }
  744. });
  745. });
  746. }
  747. //解析定位结果
  748. function onComplete(data) {
  749. var city = data;
  750. AMap.plugin('AMap.Weather', function () {
  751. var weather = new AMap.Weather();
  752. //未来4天天气预报
  753. weather.getForecast(data, function (err, data) {
  754. if (err) { return; }
  755. var str = '';
  756. dayWeather = data.forecasts[0];
  757. str += '<div class="weathericon"><img src="../static/bigData/image/weatherIcon/' + weatherIcon[dayWeather.dayWeather] + '" width="30" alt="">' +
  758. '</div><div class="weatherval"><p>' + city + '</p><p>' + dayWeather.nightTemp + '~' + dayWeather.dayTemp + '℃</p></div><div><P>' + dayWeather.dayWeather + '</P></div>'
  759. $('.weatherInner').html(str)
  760. });
  761. });
  762. }