index.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. const host_port = "119.23.151.229:8006/";
  2. const url = "http://" + host_port;
  3. // const url = "http://127.0.0.1:8006/";
  4. var myPieEchart = echarts.init($('.pie')[0]); // 饼图
  5. var myLineEchart = echarts.init($('.line')[0]); // 折线图
  6. var myBarEchart = echarts.init($('.users .bar')[0]); // 柱状图
  7. var myMapChart = echarts.init($('.map .geo')[0]); // 地图
  8. var mapOption; // 地图参数
  9. var heartbeatTime, breakTime, showTime; // 定时任务
  10. var partId; // 机构id
  11. var colorList = ['#00f2f1','#006cff', '#eab408', '#ed8884', '#ff9f7f', '#0096ff', '#9fe6b8', '#32c5e9', '#1d9dff'];
  12. /*大屏*/
  13. //自调用函数
  14. (function () {
  15. // 1、页面一加载就要知道页面宽度计算
  16. var setFont = function () {
  17. // 因为要定义变量可能和别的变量相互冲突,污染,所有用自调用函数
  18. var html = document.documentElement;// 获取html
  19. // 获取宽度
  20. var width = html.clientWidth;
  21. // 判断
  22. if (width < 1024) width = 1024
  23. if (width > 1920) width = 1920
  24. // 设置html的基准值
  25. var fontSize = width / 80 + 'px';
  26. // 设置给html
  27. html.style.fontSize = fontSize;
  28. }
  29. setFont();
  30. $(".geo").height($(".map").height());
  31. // 2、页面改变的时候也需要设置
  32. // 尺寸改变事件
  33. window.onresize = function () {
  34. setFont();
  35. $(".geo").height($(".map").height());
  36. }
  37. //时间
  38. // $('.clock').FlipClock({
  39. // clockFace: 'TwentyFourHourClock'
  40. // });
  41. })();
  42. // 请求后台获取数据
  43. (function () {
  44. partId = getQuery("partId");
  45. if (partId) {
  46. // 连接webSocket
  47. initWebSocket();
  48. // 打开定时器
  49. openTimer();
  50. }
  51. })();
  52. // 获取看板用户信息
  53. function getUserInfo() {
  54. $.get(url + "bulletinBoard/user_info/" + partId, function (data, status) {
  55. console.log(data.partInfo.shop_name);
  56. $(".title").text(data.partInfo.shop_name);
  57. $("#allCount").text(data.userCount.all_count); // 总用户
  58. $("#quarterly-addition").text(data.userCount.quarterly_count); // 季度新增
  59. $("#monthly-addition").text(data.userCount.month_count); // 月度新增
  60. $("#manCount").text(data.userCount.man_count ? data.userCount.man_count : 0); // 男生人数
  61. $("#womanCount").text(data.userCount.woman_count ? data.userCount.woman_count : 0); // 女生人数
  62. // 地图人员分布
  63. mapOption = initMap();
  64. if (data.memberList.length > 0) {
  65. var d = []
  66. data.memberList.forEach((item, index) => {
  67. d.push({
  68. name: item.nickname,
  69. value: item.lng_lat.split(","),
  70. size: 10,
  71. text: formatText(item),
  72. })
  73. })
  74. mapOption.series[1].data = d;
  75. // mapOption.bmap.center = [114.08259, 22.356868]; // 114.08259, 22.556868
  76. mapOption.bmap.center = d[0].value; // 114.08259, 22.556868
  77. mapOption.bmap.zoom = 16;
  78. }
  79. myMapChart.setOption(mapOption);
  80. window.addEventListener('resize', myMapChart.resize);
  81. // 年龄段饼图
  82. var pieOption = initPieChar();
  83. pieOption.series[0].data = data.pieData;
  84. myPieEchart.setOption(pieOption);
  85. });
  86. }
  87. // 获取看板事件报警信息
  88. function getSOSInfo() {
  89. $.get(url + "bulletinBoard/sos_info/" + partId, function (data, status) {
  90. // 最新事件报警表格
  91. var rows = []
  92. $.each(data.actionList, function (i, n) {
  93. var name = '';
  94. if (n.from_member_name == null || n.from_member_name === "") {
  95. name = n.from_frame_name;
  96. } else {
  97. name = n.from_member_name;
  98. }
  99. var row = '<div class="row">\n' +
  100. '<span class="col">'+unixToDate(n.create_date, "MM-dd hh:mm")+'</span>\n' +
  101. '<span class="col">'+name+'</span>\n' +
  102. '<span class="col">'+n.from_device_name+'</span>\n' +
  103. '<span class="icon-dot"></span>\n' +
  104. '</div>';
  105. rows.push(row)
  106. });
  107. $("#vsLogTable").html(rows.join(''))
  108. // 报警分布
  109. var xData = [], yData = [];
  110. data.barList.forEach((item, index) => {
  111. xData.push(item.name)
  112. yData.push(item.value)
  113. })
  114. var barOption = initBarChar();
  115. barOption.xAxis[0].data = xData;
  116. barOption.series[0].data = yData;
  117. myBarEchart.setOption(barOption);
  118. // 动态报警折线图
  119. initDynamicAlarm(data);
  120. });
  121. }
  122. // 获取看板体征信息
  123. function getLogInfo() {
  124. $.get(url + "bulletinBoard/log_info/" + partId, function (data, status) {
  125. $("#dayCount").text(data.logCount.day_count); // 今日测量数
  126. $("#hourCount").text(data.logCount.hour_count); // 近1小时测量数
  127. // 动态测量项
  128. initMeasureItem(data);
  129. // 体征报警表格
  130. var rows = []
  131. $.each(data.errVsLogList, function (i, n) {
  132. var row = '<div class="row">\n' +
  133. '<span class="col">'+unixToDate(n.log_time, "MM-dd hh:mm")+'</span>\n' +
  134. '<span class="col">'+n.member_nickname+'</span>\n' +
  135. '<span class="col">'+n.param_name+'</span>\n' +
  136. '<span class="col">'+n.vs_value+'</span>\n' +
  137. '<span class="icon-dot"></span>\n' +
  138. '</div>';
  139. rows.push(row)
  140. });
  141. $("#errVsLogTable").html(rows.join(''))
  142. // $.each(data.errVsLogList, function (i, n) {
  143. // var row = $("#errVsLogTemplate").clone();
  144. // row.find(".errVsLogTime").text(unixToDate(n.log_time, "MM-dd hh:mm"));
  145. // row.find(".errVsLogUser").text(n.member_nickname);
  146. // row.find(".errVsLogItem").text(n.param_name);
  147. // row.find(".errVsLogValue").text(n.vs_value);
  148. // row.appendTo("#errVsLogTable");
  149. // });
  150. });
  151. }
  152. function initWebSocket() {
  153. var time = Math.round(new Date()) + "" + Math.round(Math.random()*100);
  154. console.log(time)
  155. // var s = "ws://127.0.0.1:8006/bulletinBoard/" + time + "/" + partId;
  156. var s = "ws://" + host_port + "bulletinBoard/" + time + "/" + partId;
  157. console.log(s)
  158. var ws = new WebSocket(s);
  159. ws.onopen = function(evt) {
  160. console.log("webSocket连接成功 ...");
  161. clearInterval(breakTime);
  162. breakTime = null;
  163. heartbeatTime = setInterval(function () {
  164. ws.send("ping");
  165. }, 55000); // 55秒心跳包
  166. // 获取看板用户信息
  167. getUserInfo();
  168. // 获取看板事件报警信息
  169. getSOSInfo();
  170. // 获取看板体征信息
  171. getLogInfo();
  172. };
  173. ws.onmessage = function(e) {
  174. console.log("收到消息: " + e.data);
  175. if (e.data === 'pong') {
  176. return
  177. }
  178. // {"address":"广东省深圳市南山区留仙大道大学城创客小镇","ageUnit":"岁","birthday":-189417600,"createTime":1661990011,"data":"15秒红外报警",
  179. // "frameId":1155,"id":457,"lngLat":"113.961957,22.579848","memberId":54658,"mobile":"18174091244","named":"小米面","partId":2,
  180. // "renewType":"SOS","sex":1,"status":0}
  181. const data = JSON.parse(e.data);
  182. if (data.renewType === 'SOS') {
  183. console.log('有人报警...')
  184. openSOSMap(data); // 地图高亮
  185. getSOSInfo(); // 刷新看板
  186. } else if ("LOG") {
  187. console.log('体征异常...')
  188. openSOSMap(data); // 地图高亮
  189. getLogInfo(); // 刷新体征
  190. } else { // USER
  191. getUserInfo(); // 刷新用户
  192. }
  193. };
  194. ws.onclose = function(evt) {
  195. console.log("webSocket连接关闭.", breakTime);
  196. if (!breakTime) {
  197. console.log('新的定时任务....')
  198. clearInterval(heartbeatTime);
  199. breakTime = setInterval(function () {
  200. console.log('正在重连...')
  201. initWebSocket();
  202. }, 5000); // 5秒重连一次
  203. }
  204. // heartbeatTime.
  205. };
  206. }
  207. // 地图高亮
  208. function openSOSMap(data) {
  209. if (data.lngLat) {
  210. var d = []
  211. d.push({
  212. name: data.named,
  213. value: data.lngLat.split(","),
  214. size: 20,
  215. text: formatSOSText(data),
  216. })
  217. mapOption.series[0].data = d;
  218. mapOption.bmap.center = d[0].value;
  219. mapOption.bmap.zoom = 18;
  220. myMapChart.setOption(mapOption);
  221. myMapChart.dispatchAction({
  222. type: 'showTip',
  223. seriesIndex: 0,
  224. dataIndex: 0
  225. });
  226. clearTimeout(showTime);
  227. showTime = setTimeout(clearSOSMap, 15000);
  228. }
  229. }
  230. // 清除百度地图报警点
  231. function clearSOSMap() {
  232. console.log("我要清除报警高亮点了", mapOption.series[0].data, mapOption.series[1].data[0].value)
  233. mapOption.series[0].data = [];
  234. mapOption.bmap.center = mapOption.series[1].data[0].value;
  235. mapOption.bmap.zoom = 16;
  236. myMapChart.setOption(mapOption);
  237. }
  238. // 打开定时器
  239. function openTimer() {
  240. // 测量时间段定时器
  241. var i = 0, ii = 0;
  242. var aclick = $('.order a');
  243. setInterval(function () {
  244. i++;
  245. if (i > 3) {
  246. i = 0;
  247. }
  248. //每3秒调用点击事件
  249. aclick.eq(i).click();
  250. }, 3000);
  251. // 报警统计折线图定时器
  252. setInterval(function () {
  253. ii++;
  254. if (ii > 4) {
  255. ii = 0;
  256. }
  257. $('.alarms .caption a').eq(ii).click();
  258. }, 5000);
  259. }
  260. (function () {
  261. //事件委托
  262. $('.monitor').on('click', ' a', function () {
  263. //点击当前的a 加类名 active 他的兄弟删除类名
  264. $(this).addClass('active').siblings().removeClass('active');
  265. //获取一一对应的下标
  266. var index = $(this).index();
  267. //选取content 然后对应下标的 显示 当前的兄弟.content隐藏
  268. $('.content').eq(index).show().siblings('.content').hide();
  269. });
  270. //滚动
  271. //原理:把marquee下面的子盒子都复制一遍 加入到marquee中
  272. // 然后动画向上滚动,滚动到一半重新开始滚动
  273. //因为选取的是两个marquee 所以要遍历
  274. $('.monitor .marquee').each(function (index, dom) {
  275. //将每个 的所有子级都复制一遍
  276. var rows = $(dom).children().clone();
  277. //再将新的到的加入原来的
  278. $(dom).append(rows);
  279. });
  280. })();
  281. // 报警分布柱状图
  282. function initBarChar() {
  283. return {
  284. // 工具提示
  285. tooltip: {
  286. // 触发类型 经过轴触发axis 经过轴触发item
  287. trigger: 'item',
  288. // 轴触发提示才有效
  289. axisPointer: {
  290. // 默认为直线,可选为:'line' 线效果 | 'shadow' 阴影效果
  291. type: 'shadow'
  292. }
  293. },
  294. // 图表边界控制
  295. grid: {
  296. // 距离 上右下左 的距离
  297. left: '0',
  298. right: '3%',
  299. bottom: '3%',
  300. top: '5%',
  301. // 大小是否包含文本【类似于boxsizing】
  302. containLabel: true,
  303. //显示边框
  304. show: true,
  305. //边框颜色
  306. borderColor: 'rgba(0, 240, 255, 0.3)'
  307. },
  308. // 控制x轴
  309. xAxis: [
  310. {
  311. // 使用类目,必须有data属性
  312. type: 'category',
  313. // 使用 data 中的数据设为刻度文字
  314. data: [],
  315. // 刻度设置
  316. axisTick: {
  317. // true意思:图形在刻度中间
  318. // false意思:图形在刻度之间
  319. alignWithLabel: false,
  320. show: false
  321. },
  322. //文字
  323. axisLabel: {
  324. color: '#4c9bfd'
  325. }
  326. }
  327. ],
  328. // 控制y轴
  329. yAxis: [
  330. {
  331. // 使用数据的值设为刻度文字
  332. type: 'value',
  333. axisTick: {
  334. // true意思:图形在刻度中间
  335. // false意思:图形在刻度之间
  336. alignWithLabel: false,
  337. show: false
  338. },
  339. //文字
  340. axisLabel: {
  341. color: '#4c9bfd'
  342. },
  343. splitLine: {
  344. lineStyle: {
  345. color: 'rgba(0, 240, 255, 0.3)'
  346. }
  347. },
  348. }
  349. ],
  350. // 控制x轴
  351. series: [
  352. {
  353. // series配置
  354. // 颜色
  355. itemStyle: {
  356. // 提供的工具函数生成渐变颜色
  357. color: new echarts.graphic.LinearGradient(
  358. // (x1,y2) 点到点 (x2,y2) 之间进行渐变
  359. 0, 0, 0, 1,
  360. [
  361. {offset: 0, color: '#00fffb'}, // 0 起始颜色
  362. {offset: 1, color: '#0061ce'} // 1 结束颜色
  363. ]
  364. )
  365. },
  366. // 图表数据名称
  367. name: '报警分布',
  368. // 图表类型
  369. type: 'bar',
  370. // 柱子宽度
  371. barWidth: '60%',
  372. // 数据
  373. data: []
  374. }
  375. ]
  376. };
  377. }
  378. // 性别饼图
  379. function initPieChar() {
  380. return {
  381. // 控制提示
  382. tooltip: {
  383. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  384. trigger: 'item',
  385. // 格式化提示内容:
  386. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  387. formatter: "{a} <br/>{b} : {c} ({d}%)"
  388. },
  389. // 控制图表
  390. series: [
  391. {
  392. // 图表名称
  393. name: '年龄段',
  394. // 图表类型
  395. type: 'pie',
  396. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  397. // 百分比基于 图表DOM容器的半径
  398. radius: ['10%', '70%'],
  399. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  400. center: ['50%', '50%'],
  401. // 半径模式,另外一种是 area 面积模式
  402. roseType: 'radius',
  403. // 数据集 value 数据的值 name 数据的名称
  404. data: [],
  405. //文字调整
  406. label: {
  407. fontSize: 10
  408. },
  409. //引导线
  410. labelLine: {
  411. length: 8,
  412. length2: 10
  413. }
  414. },
  415. ],
  416. color: ['#006cff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff', '#9fe6b8', '#32c5e9', '#1d9dff']
  417. };
  418. }
  419. // 报警统计折线图
  420. function initLineChar() {
  421. return {
  422. //鼠标提示工具
  423. tooltip: {
  424. trigger: 'axis'
  425. },
  426. xAxis: {
  427. // 类目类型
  428. type: 'category',
  429. // x轴刻度文字
  430. data: [],
  431. axisTick: {
  432. show: false//去除刻度线
  433. },
  434. axisLabel: {
  435. color: '#4c9bfd'//文本颜色
  436. },
  437. axisLine: {
  438. show: false//去除轴线
  439. },
  440. boundaryGap: false//去除轴内间距
  441. },
  442. yAxis: {
  443. // 数据作为刻度文字
  444. type: 'value',
  445. axisTick: {
  446. show: false//去除刻度线
  447. },
  448. axisLabel: {
  449. color: '#4c9bfd'//文本颜色
  450. },
  451. axisLine: {
  452. show: false//去除轴线
  453. },
  454. boundaryGap: false//去除轴内间距
  455. },
  456. //图例组件
  457. legend: {
  458. textStyle: {
  459. color: '#4c9bfd' // 图例文字颜色
  460. },
  461. type: 'scroll',
  462. right: '10%'//距离右边10%
  463. },
  464. // 设置网格样式
  465. grid: {
  466. show: true,// 显示边框
  467. top: '20%',
  468. left: '3%',
  469. right: '4%',
  470. bottom: '3%',
  471. borderColor: '#012f4a',// 边框颜色
  472. containLabel: true // 包含刻度文字在内
  473. },
  474. series: [{
  475. // 数据
  476. data: [],
  477. // 图表类型
  478. type: 'line',
  479. // 圆滑连接
  480. smooth: true,
  481. itemStyle: {
  482. color: '#00f2f1' // 线颜色
  483. }
  484. }]
  485. };
  486. }
  487. // 动态测量项
  488. function initMeasureItem(data) {
  489. // 365天、90、30、7天测量
  490. var item = {
  491. day365: {
  492. count: data.logCount.year_count + data.logCount.year_err_count,
  493. errCount: data.logCount.year_err_count
  494. },
  495. day90: {
  496. count: data.logCount.season_count + data.logCount.season_err_count,
  497. errCount: data.logCount.season_err_count
  498. },
  499. day30: {
  500. count: data.logCount.month_count + data.logCount.month_err_count,
  501. errCount: data.logCount.month_err_count
  502. },
  503. day7: {
  504. count: data.logCount.week_count + data.logCount.week_err_count,
  505. errCount: data.logCount.week_err_count
  506. }
  507. };
  508. $('.order .item h4:eq(0)').text(item.day365.count);
  509. $('.order .item h4:eq(1)').text(item.day365.errCount);
  510. // 点击事件
  511. $('.order').on('click', '.filter a', function () {
  512. //点击之后加类名
  513. $(this).addClass('active').siblings().removeClass('active');
  514. // 先获取点击a的 data-key自定义属性
  515. var key = $(this).attr('data-key');
  516. key = item[key];
  517. $('.order .item h4:eq(0)').text(key.count);
  518. $('.order .item h4:eq(1)').text(key.errCount);
  519. });
  520. }
  521. // 动态报警折线图
  522. function initDynamicAlarm(item) {
  523. myLineEchart.resize({ height: $('.line').height() - 10 })
  524. var lineOption = initLineChar();
  525. lineOption.series = [];
  526. if (item.week[0].length > 0) {
  527. item.week[0].forEach((t, i) => {
  528. var d = {
  529. name: item.week[2][i],
  530. type: 'line',
  531. stack: 'year总量' + i,
  532. data: t,
  533. smooth: true,
  534. emphasis: {
  535. focus: 'series',
  536. blurScope: 'coordinateSystem'
  537. },
  538. itemStyle: {
  539. color: colorList[i] // 线颜色
  540. }
  541. };
  542. lineOption.series.push(d);
  543. });
  544. }
  545. // lineOption.series[0].data = item.year[0];
  546. lineOption.legend.data = item.week[2];
  547. lineOption.xAxis.data = item.week[1];
  548. var data = {
  549. year: item.year,
  550. month: item.month,
  551. week: item.week
  552. };
  553. myLineEchart.setOption(lineOption);
  554. $('.alarms ').on('click', '.caption a', function () {
  555. $(this).addClass('active').siblings('a').removeClass('active');
  556. lineOption = initLineChar();
  557. //option series data
  558. //获取自定义属性值
  559. var k = $(this).attr('data-type');
  560. //取出对应的值
  561. var key = data[k];
  562. //将值设置到 图表中
  563. if (key[0].length > 0) {
  564. if (k === 'week') {
  565. lineOption = initLineChar();
  566. myLineEchart.setOption(lineOption);
  567. }
  568. key[0].forEach((t, i) => {
  569. var d = {
  570. name: key[2][i],
  571. type: 'line',
  572. stack: k + '总量' + i,
  573. data: t,
  574. smooth: true,
  575. emphasis: {
  576. focus: 'series',
  577. blurScope: 'coordinateSystem'
  578. },
  579. itemStyle: {
  580. color: colorList[i] // 线颜色
  581. }
  582. }
  583. lineOption.series.push(d);
  584. })
  585. // lineOption.series[0].data = key[0];
  586. } else {
  587. var dd = [];
  588. key[1].forEach((t, i) => {
  589. dd.push('0');
  590. });
  591. lineOption.series.push({
  592. name: '',
  593. type: 'line',
  594. stack: k + '总量0',
  595. data: dd,
  596. smooth: true,
  597. emphasis: {
  598. focus: 'series',
  599. blurScope: 'coordinateSystem'
  600. },
  601. itemStyle: {
  602. color: '#00f2f1' // 线颜色
  603. }
  604. });
  605. key[2] = [''];
  606. }
  607. lineOption.legend.data = key[2];
  608. // 坐标修改
  609. lineOption.xAxis.data = key[1];
  610. //再次调用才能在页面显示
  611. myLineEchart.setOption(lineOption);
  612. });
  613. }
  614. // 初始化百度地图
  615. function initMap() {
  616. return {
  617. backgroundColor: 'transparent',
  618. title: {
  619. text: '用户地图一览',
  620. left: 'center',
  621. textStyle: {
  622. color: '#fff'
  623. }
  624. },
  625. tooltip: {
  626. trigger: 'item',
  627. formatter: function (params) {
  628. //console.log(params);
  629. return params.data.text
  630. }
  631. },
  632. bmap: {
  633. center: [114.25, 30.34], //地图中心点
  634. zoom: 11, //默认缩放倍数
  635. roam: true, //禁止放大缩小
  636. geo: {
  637. aspectScale: 0.3
  638. },
  639. mapStyleV2: {
  640. styleJson: returnMapStyleJson()
  641. }
  642. },
  643. series: [
  644. {
  645. name: '体征告警',
  646. type: 'effectScatter', //气泡动态效果
  647. coordinateSystem: 'bmap', // 地图选择项bmap为百度地图
  648. data: [],
  649. symbolSize: function (val1, val2) {
  650. // console.log(val1,val2)
  651. return val2.data.size;
  652. }, //标记大小
  653. showEffectOn: 'render', // 配置何时显示特效。 render 绘制完成后显示特效。emphasis 高亮(hover)的时候显示特效。
  654. rippleEffect: {
  655. brushType: 'stroke', // 波纹的绘制方式 stroke 和 fill
  656. number: 3, // 波纹的数量
  657. scale: 5, // 波纹放大的倍数
  658. color: '#8FD1C3'
  659. },
  660. hoverAnimation: true,
  661. label: {
  662. formatter: '{b}',
  663. position: 'right',
  664. show: true
  665. },
  666. itemStyle: {
  667. color: '#f37b1d',
  668. shadowBlur: 10,
  669. shadowColor: '#333'
  670. },
  671. zlevel: 1
  672. },
  673. {
  674. name: '正常体征',
  675. type: 'scatter', //气泡静态效果
  676. coordinateSystem: 'bmap',
  677. data: [],
  678. symbolSize: function (val1, val2) {
  679. return val2.data.size;
  680. }, //标记的大小
  681. label: {
  682. formatter: '{b}',
  683. position: 'right'
  684. },
  685. itemStyle: {
  686. color: '#ddb926'
  687. },
  688. emphasis: { // 高亮的图形和标签样式
  689. label: {
  690. show: true
  691. }
  692. }
  693. }
  694. ]
  695. };
  696. }
  697. // 获取网页链接参数
  698. function getQuery(name){
  699. let reg = new RegExp('(^|&)'+ name + "=([^&]*)", "i");
  700. let r = decodeURI(window.location.search.substr(1)).match(reg);
  701. if(r!=null) return r[2]; return null;
  702. }
  703. // 用户显示文字
  704. function formatText(item) {
  705. var str = "";
  706. if (item.address) {
  707. str = item.address + "<br/>";
  708. }
  709. str += item.nickname + "," + formatSex(item.sex) + (item.birthday ? ("," + formatAge(item.birthday)) : "");
  710. return str;
  711. }
  712. // SOS显示报警文字
  713. function formatSOSText(item) {
  714. var str = "";
  715. if (item.address) {
  716. str = item.address + "<br/>";
  717. }
  718. str += item.named + "," + formatSex(item.sex);
  719. if (item.birthday) {
  720. str += "," + formatAge(item.birthday);
  721. }
  722. str += "<br/>";
  723. str += "报警内容:" + item.data + "<br/>";
  724. if (item.relativeMobile) {
  725. str += "联系亲属:" + item.relativeMobile + "<br/>";
  726. }
  727. if (item.sOSLngLat) {
  728. str += "报警位置:" + item.sOSLngLat;
  729. }
  730. return str;
  731. }
  732. // 时间转换
  733. function unixToDate(unix, format) {
  734. if (!unix) return unix
  735. var _format = format || 'yyyy-MM-dd hh:mm:ss'
  736. const d = new Date(unix * 1000)
  737. const o = {
  738. 'M+': d.getMonth() + 1,
  739. 'd+': d.getDate(),
  740. 'h+': d.getHours(),
  741. 'm+': d.getMinutes(),
  742. 's+': d.getSeconds(),
  743. 'q+': Math.floor((d.getMonth() + 3) / 3),
  744. S: d.getMilliseconds()
  745. }
  746. if (/(y+)/.test(_format)) _format = _format.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length))
  747. for (const k in o) if (new RegExp('(' + k + ')').test(_format)) _format = _format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  748. return _format
  749. }
  750. // 性别转换
  751. function formatSex(sex) {
  752. return sex === 1 ? '男' : sex === 0 ? '女' : '未知'
  753. }
  754. // 生日转换
  755. function formatAge(birthday) {
  756. const data = formatBirthdayToAge(birthday * 1000)
  757. return data.age + data.ageunit
  758. }
  759. // 将生日转换成年龄
  760. function formatBirthdayToAge(birthday) {
  761. const birth = new Date(birthday)
  762. const birthYear = birth.getFullYear() // 出生年
  763. const birthMonth = birth.getMonth() + 1 // 出生月
  764. const birthDay = birth.getDate() // 出生日
  765. const nowYear = new Date().getFullYear() // 出生年
  766. const nowMonth = new Date().getMonth() + 1 // 出生月
  767. const nowDay = new Date().getDate() // 出生日
  768. if (nowYear === birthYear) { // 同年
  769. if (nowMonth === birthMonth) { // 同月
  770. return {
  771. age: nowDay - birthDay,
  772. ageunit: '天'
  773. }
  774. } else {
  775. return {
  776. age: nowMonth - birthMonth,
  777. ageunit: '月'
  778. }
  779. }
  780. } else { // 计算周岁
  781. const ageDiff = nowYear - birthYear // 年之差
  782. if (ageDiff > 0) {
  783. if (nowMonth === birthMonth) { // 同月
  784. const dayDiff = nowDay - birthDay// 日之差
  785. if (dayDiff < 0) {
  786. return {
  787. age: ageDiff - 1,
  788. ageunit: '岁'
  789. }
  790. } else {
  791. return {
  792. age: ageDiff,
  793. ageunit: '岁'
  794. }
  795. }
  796. } else {
  797. const monthDiff = nowMonth - birthMonth // 月之差
  798. if (monthDiff < 0) {
  799. return {
  800. age: ageDiff - 1,
  801. ageunit: '岁'
  802. }
  803. } else {
  804. return {
  805. age: ageDiff,
  806. ageunit: '岁'
  807. }
  808. }
  809. }
  810. }
  811. }
  812. }