index.js 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. var host = 'http://192.168.1.222:8081';
  2. //图表对象定义
  3. (function (win) {
  4. win.myEcharts = function (id, option) {
  5. var _this = this;
  6. _this.mapJsonUrl = typeof (option) == 'undefined' ? '' : option.mapJsonUrl || ''; //地图包数据接口
  7. _this.dataJsonUrl = typeof (option) == 'undefined' ? '' : option.dataJsonUrl || ''; //用户数据接口
  8. _this.elem = document.getElementById(id);
  9. _this.mapName = 'china';
  10. _this.xAxisData = [];
  11. _this.yAxisData = [];
  12. _this.option = {
  13. //鼠标经过提示
  14. tooltip: {
  15. trigger: 'axis'
  16. },
  17. //图表位置,坐标系类型,grid直角坐标
  18. grid: {
  19. top: '21%',
  20. left: '3%',
  21. right: '4%',
  22. bottom: '3%',
  23. containLabel: true
  24. },
  25. xAxis: {
  26. type: 'category',
  27. boundaryGap: true,
  28. data: _this.xAxisData,
  29. axisLabel: {
  30. show: true,
  31. textStyle: {
  32. color: "#609dbd"
  33. },
  34. interval: 0,
  35. // rotate: 40
  36. },
  37. splitLine: {
  38. show: false
  39. },
  40. axisTick: {
  41. show: false
  42. },
  43. axisLine: {
  44. show: false
  45. }
  46. },
  47. yAxis: {
  48. type: 'value',
  49. axisLabel: {
  50. show: true,
  51. textStyle: {
  52. color: "#609dbd"
  53. },
  54. formatter: '{value}'
  55. },
  56. splitLine: {
  57. show: false
  58. },
  59. axisTick: {
  60. show: false
  61. },
  62. axisLine: {
  63. show: false
  64. }
  65. },
  66. };
  67. for (var t in option) {
  68. _this.option[t] = option[t];
  69. }
  70. _this.show();
  71. win.myEcharts.prototype.resizeObj.push(_this);
  72. }
  73. /**
  74. * 所有对象集合
  75. */
  76. win.myEcharts.prototype.resizeObj = [];
  77. /**
  78. * 设置AJAX数据地图,并更新显示
  79. */
  80. win.myEcharts.prototype.setMap = function (id) {
  81. var _this = this;
  82. $.ajax({
  83. url: _this.mapJsonUrl,
  84. datatype: "JSON",
  85. success: function (res) {
  86. echarts.registerMap(_this.mapName, res);
  87. _this.show();
  88. }
  89. });
  90. return _this;
  91. }
  92. /**
  93. * 清除并设置容器元素图表
  94. */
  95. win.myEcharts.prototype.dispose = function () {
  96. var _this = this;
  97. echarts.dispose(_this.elem);
  98. _this.myChart = echarts.init(_this.elem);
  99. return _this;
  100. }
  101. /**
  102. * 显示渲染图表
  103. */
  104. win.myEcharts.prototype.show = function (option, tool) {
  105. var _this = this;
  106. _this.dispose();
  107. if ((option || _this.option) && typeof ((option || _this.option)) === "object") {
  108. _this.myChart.setOption((option || _this.option), true);
  109. }
  110. //自动轮播tooltip
  111. if (tool) {
  112. var index = 0; //播放所在下标
  113. clearInterval(mTime);
  114. _this.myChart.dispatchAction({
  115. type: 'showTip',
  116. seriesIndex: 0,
  117. dataIndex: 0
  118. });
  119. var mTime = setInterval(function () {
  120. _this.myChart.dispatchAction({
  121. type: 'downplay',
  122. seriesIndex: 0,
  123. });
  124. _this.myChart.dispatchAction({
  125. type: 'showTip',
  126. seriesIndex: 0,
  127. dataIndex: index + 1
  128. });
  129. index++;
  130. if (index > option.series[0].data.length - 1) {
  131. index = 0;
  132. _this.myChart.dispatchAction({
  133. type: 'showTip',
  134. seriesIndex: 0,
  135. dataIndex: 0
  136. });
  137. }
  138. }, 15 * 1000);
  139. }
  140. return _this;
  141. }
  142. /**
  143. * 重绘图表
  144. */
  145. win.myEcharts.prototype.resize = function () {
  146. var _this = this;
  147. _this.myChart.resize();
  148. return _this;
  149. };
  150. /**
  151. * 更新dataJsonUrl
  152. */
  153. win.myEcharts.prototype.setDataUrl = function (url) {
  154. var _this = this;
  155. if (url) {
  156. _this.dataJsonUrl = url;
  157. }
  158. return _this;
  159. }
  160. /**
  161. * 配置图表类型
  162. */
  163. win.myEcharts.prototype.setTable = function (setData) {
  164. var _this = this;
  165. $.ajax({
  166. url: _this.dataJsonUrl,
  167. datatype: "JSON",
  168. success: function (res) {
  169. if (setData) {
  170. _this.temp = setData;
  171. _this.temp(res);
  172. return;
  173. }
  174. try {
  175. _this.option.xAxis.data = res.name;
  176. if (res.type) {
  177. for (var xc in _this.option.series) {
  178. _this.option.series[xc].data = res.data[xc];
  179. }
  180. } else {
  181. _this.option.series[0].data = res.data;
  182. }
  183. _this.show();
  184. } catch (e) {
  185. //TODO handle the exception
  186. }
  187. }
  188. });
  189. return _this;
  190. }
  191. /**
  192. * 更新配置地图数据
  193. */
  194. win.myEcharts.prototype.setMapData = function (setData, id) {
  195. var _this = this;
  196. $.ajax({
  197. url: _this.dataJsonUrl,
  198. datatype: "JSON",
  199. success: function (res) {
  200. if (setData) {
  201. _this.temp = setData;
  202. _this.temp(res);
  203. return;
  204. }
  205. try {
  206. if (type) {
  207. _this.option.series[0].data = res;
  208. } else {
  209. for (var i in _this.option.series[0].data) {
  210. _this.option.series[0].data[i].value = res.data[i];
  211. };
  212. }
  213. } catch (e) {
  214. }
  215. }
  216. });
  217. _this.show();
  218. return _this;
  219. }
  220. })(window);
  221. //图表置入对象实例
  222. (function (win) {
  223. //左上角数据读取 价格监控统计
  224. (function leftTop() {
  225. $.ajax({
  226. url: host + '/main/monitorTheStatistical',
  227. type: 'get',
  228. success: function (res) {
  229. if (res.retHead.errCode == 0) {
  230. let resData = res.retBody;
  231. var html = "";
  232. for (var i = 0; i < resData.length; i++) {
  233. html += '<li><h4 class="name">' + resData[i].type + '</h4><div class="number"><ul class="number-list"></ul><span class="unit">' + resData[i].unit + '</span></div></li>'
  234. }
  235. $('.left-top').html(html);
  236. for (let j = 0; j < resData.length; j++) {
  237. this['num' + j] = '';
  238. let totalNUm = resData[j].number.toString();
  239. for (let z in totalNUm) {
  240. this['num' + j] += '<li>' + totalNUm[z] + '</li>'
  241. }
  242. $("#left-top .number-list").eq(j).html(this['num' + j]);
  243. }
  244. }
  245. }
  246. });
  247. })();
  248. //左下角滚动
  249. (function leftBotTable(e, type) {
  250. $.ajax({
  251. url: host + '/main/wholesaleMarketToday?isLimit=false',
  252. type: 'get',
  253. success: function (res) {
  254. if (res.retHead.errCode == 0) {
  255. let resData = res.retBody;
  256. let cts = '-'
  257. var html = "";
  258. for (var i in resData) {
  259. let str = resData[i].amplitude.indexOf(cts) != -1 ? "fall-number" : "rise-number";
  260. html += '<li class="ui-flex table-row"><span>' + resData[i].productName + '</span><span>' + resData[i].price + '</span><span class="number ' + str + '"><b class="num">' + resData[i].amplitude + '</b><b class="arrow"></b></span></li>'
  261. }
  262. $('#left-bot-table').html(html);
  263. }
  264. if (type) {
  265. //启用滚动
  266. $('.left-bot-table').myScroll({
  267. speed: 40, //数值越大,速度越慢
  268. rowHeight: 40 //li的高度
  269. });
  270. }
  271. }
  272. });
  273. })(1, true);
  274. function zhidong(e) {
  275. let ld = $("#priceIndex li").length - 1,
  276. riseFallData = [],
  277. productData = [];
  278. let ul = $("#priceIndex li").width() * (ld + 1),
  279. box = $(".productBox").width(),
  280. li = parseInt(box / 110);
  281. if (e > ld) {
  282. e = 0;
  283. }
  284. if (e < li - 1) {
  285. $("#priceIndex").css('margin-left', '0px');
  286. } else if (e >= li - 1 && e <= ld) {
  287. $("#priceIndex").css('margin-left', -110 * (e - (li - 1)) + 'px');
  288. } else if (e > ld) {
  289. $("#priceIndex").css('margin-left', (ul - box) + 'px');
  290. }
  291. let id = $($("#priceIndex li")[e]).attr('id');
  292. $.ajax({
  293. url: host + "/main/chartOfUpsAndDowns?id=" + id,
  294. type: "get",
  295. success: function (res) {
  296. if (res.retHead.errCode == 0) {
  297. let resData = res.retBody;
  298. if (resData) {
  299. for (let j = 0; j < resData.length; j++) {
  300. riseFallData.push(resData[j].amplitude)
  301. productData.push(resData[j].productName)
  302. }
  303. chartObj1.option.xAxis.data = productData;
  304. chartObj1.option.series[0].data = riseFallData;
  305. chartObj1.show();
  306. } else {
  307. chartObj1.option.xAxis.data = [];
  308. chartObj1.option.series[0].data = [];
  309. chartObj1.show();
  310. }
  311. }
  312. }
  313. });
  314. $($("#priceIndex li")[e]).addClass('active');
  315. setTimeout(function () {
  316. $($("#priceIndex li")[e]).removeClass('active');
  317. zhidong(++e);
  318. }, 15 * 1000);
  319. };
  320. //左中折线图
  321. $.ajax({
  322. url: host + '/main/kindOfUpsAndDowns',
  323. success: function (res) {
  324. let resData = res.retBody;
  325. let html = "";
  326. let cts = '-'
  327. for (let i = 0; i < resData.length; i++) {
  328. let str = resData[i].amplitude.indexOf(cts) != -1 ? "fall-arrow" : "rise-arrow";
  329. if (resData[i].amplitude == '-') {
  330. html += '<li id="' + resData[i].id + '"><div><h4 class="number">' + resData[i].amplitude + '</h4><p class="name">' + resData[i].type.substring(0, 5) + '</p></div></li>'
  331. } else {
  332. html += '<li id="' + resData[i].id + '"><div><h4 class="number">' + resData[i].amplitude + '<span class="arrow ' + str + '"></span></h4><p class="name">' + resData[i].type.substring(0, 5) + '</p></div></li>'
  333. }
  334. }
  335. $('#priceIndex').html(html);
  336. $($("#priceIndex li")[0]).addClass('active');
  337. }
  338. });
  339. var chartObj1 = new myEcharts('riseFallChart', {
  340. //dataJsonUrl: "json/middle/bar.json",
  341. tooltip: {
  342. trigger: 'axis',
  343. axisPointer: {
  344. type: 'line',
  345. },
  346. formatter: function (params) {
  347. var res = '<div><p>' + params[0].name + '</p></div>'
  348. for (var i = 0; i < params.length; i++) {
  349. if (params[i].data >= 0) {
  350. res += '<p>涨价:' + params[i].data + '</p>'
  351. } else {
  352. res += '<p>跌价:' + params[i].data + '</p>'
  353. }
  354. }
  355. return res;
  356. }
  357. },
  358. grid: {
  359. top: '20%',
  360. right: '5%',
  361. left: '12%',
  362. bottom: '38%',
  363. },
  364. xAxis: {
  365. type: 'category',
  366. axisLine: {
  367. lineStyle: {
  368. color: '#0c3563',
  369. width: 1
  370. }
  371. },
  372. axisTick: {
  373. alignWithLabel: true
  374. },
  375. splitLine: {
  376. show: false,
  377. },
  378. axisLabel: {
  379. color: "#609dbd",
  380. interval: 0
  381. },
  382. data: []
  383. },
  384. series: [{
  385. name: '涨价',
  386. type: 'bar',
  387. stack: '总量',
  388. barWidth: 8,
  389. itemStyle: {
  390. normal: {
  391. barBorderRadius: 50,
  392. color: function (params) {
  393. var colorList;
  394. if (params.data >= 0) {
  395. colorList = new echarts.graphic.LinearGradient(
  396. 0, 0, 0, 1,
  397. [{
  398. offset: 0,
  399. color: '#e21166'
  400. },
  401. {
  402. offset: 0.6,
  403. color: '#700779'
  404. }
  405. ]
  406. )
  407. } else {
  408. colorList = new echarts.graphic.LinearGradient(
  409. 0, 0, 0, 1,
  410. [{
  411. offset: 0,
  412. color: '#0264af'
  413. },
  414. {
  415. offset: 1,
  416. color: '#0aeef5'
  417. }
  418. ]
  419. )
  420. }
  421. return colorList;
  422. },
  423. }
  424. },
  425. label: {
  426. show: true,
  427. position: 'top',
  428. textStyle: {
  429. color: '#c9e8f9',
  430. fontSize: 13
  431. }
  432. },
  433. }]
  434. }).setTable(function (res) {
  435. zhidong(0);
  436. });
  437. //地图
  438. var chartObj2 = new myEcharts('mapChart', {
  439. mapJsonUrl: "js/china.json",
  440. //dataJsonUrl: host + "/main/findById"
  441. });
  442. chartObj2.option = {
  443. tooltip: {
  444. trigger: 'item',
  445. formatter: function (data) {
  446. if (!isNaN(data.value)) {
  447. return data.name + ":" + data.value;
  448. }
  449. }
  450. },
  451. visualMap: {
  452. min: 0,
  453. max: 10,
  454. itemWidth: 15,
  455. itemHeight: 80,
  456. left: 'left',
  457. top: 'bottom',
  458. text: ['高', '低'],
  459. textStyle: {
  460. color: '#fff',
  461. left: 20
  462. },
  463. calculable: true,
  464. textGap: 10,
  465. left: '15%',
  466. inRange: {
  467. color: ['#0693ff', '#0aeef5', '#e21166', ]
  468. },
  469. },
  470. series: [{
  471. name: '价格',
  472. type: 'map',
  473. mapType: 'china',
  474. zoom: 1.2,
  475. roam: false,
  476. label: {
  477. normal: {
  478. show: true
  479. },
  480. emphasis: {
  481. show: true,
  482. color: '#fff'
  483. }
  484. },
  485. itemStyle: {
  486. normal: {
  487. areaColor: '#103d7e',
  488. borderColor: '#03204a',
  489. shadowColor: 'rgba(0, 0, 0, 0.5)',
  490. shadowBlur: 5,
  491. shadowOffsetX: 1,
  492. shadowOffsetY: 1
  493. },
  494. emphasis: {
  495. areaColor: '#0693ff'
  496. }
  497. }
  498. }]
  499. };
  500. $.ajax({
  501. url: host + "/collect/product/monitorProducts?isLimit=false",
  502. type: "get",
  503. success: function (res) {
  504. if (res.retHead.errCode == 0) {
  505. console.log('地图', res)
  506. var resData = res.retBody.list;
  507. var html = "";
  508. for (let i = 0; i < resData.length; i++) {
  509. html += '<li id="' + resData[i].id + '"><h4 class="name">' + resData[i].name.substring(0, 5) + '</h4></li>'
  510. }
  511. $('#mapIndex').html(html);
  512. chartObj2.setMap().setMapData(function (res) {
  513. mapRoll(0);
  514. }, res.retBody.id);
  515. } else {
  516. layer.msg(res.retHead.errMsg)
  517. }
  518. }
  519. });
  520. function mapRoll(e) {
  521. let ld = $("#mapIndex li").length - 1,
  522. mapData = [];
  523. if (e > ld) {
  524. e = 0;
  525. }
  526. let ul = $("#mapIndex li").width() * (ld + 1);
  527. let box = $(".mapIndexBox").width();
  528. if (e < 4) {
  529. $("#mapIndex").css('margin-left', '0px');
  530. } else if (e >= 4 && e <= ld) {
  531. $("#mapIndex").css('margin-left', -95 * (e - 2) + 'px');
  532. } else if (e > ld) {
  533. $("#mapIndex").css('margin-left', (ul - box) + 'px');
  534. }
  535. let id = $($("#mapIndex li")[e]).attr('id');
  536. $.ajax({
  537. url: host + "/main/findById?id=" + id,
  538. type: "get",
  539. success: function (res) {
  540. if (res.retHead.errCode == 0) {
  541. let resMap = res.retBody;
  542. if (resMap) {
  543. for (let j = 0; j < resMap.provinces.length; j++) {
  544. mapData[j] = {
  545. name: resMap.provinces[j].name,
  546. value: resMap.provinces[j].price
  547. }
  548. }
  549. $($("#avgPrice li")).find('.nationalAvg').text(resMap.nationalAvg || '-');
  550. $($("#avgPrice li")).find('.provinceAvg').text(resMap.provinceAvg || '-');
  551. chartObj2.option.series[0].data = mapData;
  552. chartObj2.show();
  553. } else {
  554. $($("#avgPrice li")).find('.nationalAvg').text('-');
  555. $($("#avgPrice li")).find('.provinceAvg').text('-');
  556. chartObj2.option.series[0].data = [];
  557. chartObj2.show();
  558. }
  559. }
  560. }
  561. });
  562. $.ajax({
  563. url: host + "/main/salesAndPriceDistribution?id=" + id,
  564. type: "get",
  565. success: function (res) {
  566. if (res.retHead.errCode == 0) {
  567. let resData = res.retBody;
  568. if (resData) {
  569. let saleData = [],
  570. priceData = [],
  571. dateData = [];
  572. for (let i = 0; i < resData.length; i++) {
  573. saleData.push(resData[i].sales)
  574. priceData.push(resData[i].price)
  575. dateData.push(resData[i].day)
  576. }
  577. chartObj3.option.xAxis.data = dateData;
  578. chartObj3.option.series[0].data = saleData;
  579. chartObj3.option.series[1].data = priceData;
  580. chartObj3.show();
  581. } else {
  582. chartObj3.option.series[0].data = [];
  583. chartObj3.show();
  584. }
  585. }
  586. }
  587. });
  588. $.ajax({
  589. url: host + "/main/trendPrediction?id=" + id,
  590. type: "get",
  591. success: function (res) {
  592. if (res.retHead.errCode == 0) {
  593. let resData = res.retBody;
  594. if (resData) {
  595. let maxData = [],
  596. minData = [],
  597. dateData = [],
  598. avgData = [];
  599. for (let i = 0; i < resData.length; i++) {
  600. maxData.push(resData[i].maxPrice)
  601. minData.push(resData[i].minPrice)
  602. dateData.push(resData[i].day)
  603. avgData.push((resData[i].maxPrice - resData[i].minPrice).toFixed(2))
  604. }
  605. console.log('差值', avgData)
  606. chartObj4.option.xAxis.data = dateData;
  607. chartObj4.option.series[0].data = maxData;
  608. chartObj4.option.series[1].data = minData;
  609. chartObj4.option.series[2].data = avgData;
  610. chartObj4.show();
  611. } else {
  612. chartObj4.option.series[0].data = [];
  613. chartObj4.option.series[1].data = [];
  614. chartObj4.show();
  615. }
  616. }
  617. }
  618. });
  619. $($("#mapIndex li")[e]).addClass('active');
  620. setTimeout(function () {
  621. $($("#mapIndex li")[e]).removeClass('active');
  622. mapRoll(++e);
  623. }, 15 * 1000);
  624. }
  625. //中左下方表
  626. var chartObj3 = new myEcharts('priceLineChart', {
  627. //dataJsonUrl: host + '/main/salesAndPriceDistribution',
  628. tooltip: {
  629. trigger: 'axis'
  630. },
  631. yAxis: [{
  632. type: 'value',
  633. name: '数量',
  634. splitNumber: 4,
  635. splitLine: {
  636. show: false
  637. },
  638. axisTick: {
  639. show: false
  640. },
  641. axisLine: {
  642. show: false
  643. },
  644. nameTextStyle: {
  645. color: '#609dbd'
  646. },
  647. axisLabel: {
  648. color: "#609dbd"
  649. }
  650. },
  651. {
  652. type: 'value',
  653. name: '元',
  654. splitNumber: 4,
  655. position: 'right',
  656. splitLine: {
  657. show: false
  658. },
  659. axisTick: {
  660. show: false
  661. },
  662. axisLine: {
  663. show: false
  664. },
  665. nameTextStyle: {
  666. color: '#609dbd',
  667. align: 'right',
  668. },
  669. axisLabel: {
  670. color: "#609dbd"
  671. }
  672. }
  673. ],
  674. series: [{
  675. name: '销量',
  676. type: 'bar',
  677. barWidth: 8,
  678. itemStyle: {
  679. normal: {
  680. color: function (params) {
  681. var colorList;
  682. colorList = new echarts.graphic.LinearGradient(
  683. 0, 0, 0, 1,
  684. [{
  685. offset: 0,
  686. color: '#0aeef5'
  687. },
  688. {
  689. offset: 1,
  690. color: '#0264af'
  691. }
  692. ]
  693. )
  694. return colorList;
  695. },
  696. barBorderRadius: 50,
  697. }
  698. },
  699. data: [200, 210, 220, 210, 230, 290, 310],
  700. },
  701. {
  702. name: '价格',
  703. type: 'line',
  704. yAxisIndex: 1,
  705. smooth: true,
  706. showSymbol: false,
  707. itemStyle: {
  708. normal: {
  709. color: '#e21166',
  710. lineStyle: {
  711. width: 1
  712. }
  713. }
  714. },
  715. data: [97, 110, 110, 70, 121, 132, 109],
  716. }
  717. ]
  718. }).setTable(function (res) {
  719. });
  720. //中右下方表
  721. var chartObj4 = new myEcharts('axisBarChart', {
  722. //dataJsonUrl: "json/middle/line.json",
  723. tooltip: {
  724. trigger: 'axis',
  725. formatter: function (params) {
  726. var res = '<div><p>' + params[0].name + '</p></div>'
  727. for (var i = 0; i < params.length - 1; i++) {
  728. res += '<p>' + params[i].seriesName + ':' + params[i].data + '</p>'
  729. }
  730. return res;
  731. }
  732. },
  733. grid: {
  734. top: '15%',
  735. left: '6%',
  736. right: '2%',
  737. bottom: '6%',
  738. containLabel: true
  739. },
  740. yAxis: {
  741. type: 'value',
  742. splitLine: {
  743. show: false
  744. },
  745. axisTick: {
  746. show: false
  747. },
  748. axisLine: {
  749. show: false
  750. },
  751. axisLabel: {
  752. color: "#609dbd"
  753. },
  754. },
  755. series: [{
  756. name: '最高',
  757. // stack: '总量',
  758. type: 'line',
  759. smooth: true,
  760. symbol: 'circle',
  761. symbolSize: 5,
  762. showSymbol: false,
  763. lineWidth: 1,
  764. itemStyle: {
  765. normal: {
  766. color: 'rgb(6, 147, 255)',
  767. lineStyle: {
  768. width: 1
  769. }
  770. }
  771. },
  772. data: [220, 182, 191, 134, 250, 120, 110, 125, 145, 122, 165, 122]
  773. },
  774. {
  775. name: '最低',
  776. stack: '总量',
  777. type: 'line',
  778. smooth: true,
  779. showSymbol: false,
  780. lineWidth: 1,
  781. itemStyle: {
  782. normal: {
  783. color: 'rgb(226, 17, 102)',
  784. lineStyle: {
  785. width: 1
  786. }
  787. },
  788. },
  789. data: [120, 110, 125, 145, 122, 165, 122, 220, 282, 191, 134, 150]
  790. },
  791. {
  792. name: '差距',
  793. stack: '总量',
  794. type: 'line',
  795. smooth: true,
  796. showSymbol: false,
  797. lineStyle: {
  798. normal: {
  799. type: 'dashed',
  800. color: 'rgba(0,0,0,0)'
  801. }
  802. },
  803. areaStyle: {
  804. normal: {
  805. color: 'rgba(6, 147, 255,0.2)',
  806. shadowColor: 'rgba(0, 0, 0, 0.1)',
  807. shadowBlur: 10
  808. }
  809. },
  810. data: [220, 182, 191, 134, 250, 120, 110, 125, 145, 122, 165, 122]
  811. }
  812. ]
  813. }).setTable(function (res) {
  814. });
  815. //右上方表
  816. var chartObj5 = new myEcharts('poarChart', {
  817. dataJsonUrl: host + "/main/sourceDistribution",
  818. tooltip: {
  819. trigger: 'axis',
  820. transitionDuration: 1,
  821. axisPointer: {
  822. type: 'line'
  823. }
  824. },
  825. xAxis: {
  826. splitLine: {
  827. show: false
  828. },
  829. axisTick: {
  830. show: false
  831. },
  832. axisLine: {
  833. show: false
  834. }
  835. },
  836. yAxis: [{
  837. type: 'value',
  838. splitLine: {
  839. show: false
  840. },
  841. axisTick: {
  842. show: false
  843. },
  844. axisLine: {
  845. show: false
  846. }
  847. }],
  848. angleAxis: {
  849. type: 'category',
  850. data: ['修文县', '黔东南', '黔西南', '遵义市', '毕节市', '贵阳市', '兴义市'],
  851. z: 10,
  852. axisLine: {
  853. lineStyle: {
  854. color: '#0c3563',
  855. }
  856. },
  857. splitLine: {
  858. show: false,
  859. lineStyle: {
  860. color: '#0c3563',
  861. }
  862. },
  863. axisLabel: { //刻度标签设置
  864. textStyle: {
  865. color: '#c9e8f9'
  866. },
  867. interval: 0,
  868. }
  869. },
  870. radiusAxis: {
  871. splitLine: {
  872. show: true,
  873. lineStyle: {
  874. color: '#0c3563',
  875. }
  876. },
  877. splitNumber: 4, // 坐标轴的分割段数
  878. axisLine: {
  879. show: true,
  880. lineStyle: {
  881. color: 'rgba(76,99,111,0.1)'
  882. }
  883. }
  884. },
  885. polar: {},
  886. series: [{
  887. type: 'bar',
  888. data: [8, 2, 3, 4, 3, 5, 1],
  889. coordinateSystem: 'polar',
  890. name: '来源量',
  891. stack: 'a',
  892. itemStyle: {
  893. normal: {
  894. color: function (params) {
  895. // console.log(params.dataIndex)
  896. let colorList = [
  897. new echarts.graphic.LinearGradient(
  898. 0, 0, 0, 1,
  899. [{
  900. offset: 0,
  901. color: '#e21166'
  902. },
  903. {
  904. offset: 0.6,
  905. color: '#700779'
  906. }
  907. ]
  908. ),
  909. new echarts.graphic.LinearGradient(
  910. 0, 1, 0, 0,
  911. [{
  912. offset: 0,
  913. color: '#0264af'
  914. },
  915. {
  916. offset: 1,
  917. color: '#0aeef5'
  918. }
  919. ]
  920. ),
  921. ];
  922. if ((params.dataIndex) % 2 == 0) {
  923. currentItem = 1
  924. return colorList[0]
  925. } else {
  926. currentItem = 0
  927. return colorList[1]
  928. }
  929. }
  930. },
  931. },
  932. }]
  933. }).setTable(function (res) {
  934. let resData = res.retBody;
  935. let city = [],
  936. numberData = []
  937. for (let i = 0; i < resData.length; i++) {
  938. city.push(resData[i].source.substring(0, 5))
  939. numberData.push(resData[i].number)
  940. }
  941. this.option.angleAxis.data = city;
  942. this.option.series[0].data = numberData;
  943. this.show(this.option, true);
  944. });
  945. //右中滚动
  946. (function rightMiddleTable(e, type) {
  947. $.ajax({
  948. url: host + '/main/monthlyWholesaleVolumeRanking',
  949. type: 'get',
  950. success: function (res) {
  951. let resData = res.retBody;
  952. let html = "";
  953. for (var i in resData) {
  954. if (i == 0) {
  955. html += '<li class="ui-flex table-row one"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].mark + '</span><span>' + resData[i].number + '</span></li>'
  956. } else if (i == 1) {
  957. html += '<li class="ui-flex table-row two"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].mark + '</span><span>' + resData[i].number + '</span></li>'
  958. } else if (i == 2) {
  959. html += '<li class="ui-flex table-row three"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].mark + '</span><span>' + resData[i].number + '</span></li>'
  960. } else {
  961. html += '<li class="ui-flex table-row"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].mark + '</span><span>' + resData[i].number + '</span></li>'
  962. }
  963. }
  964. $('#right-middle-table').html(html);
  965. // if (type) {
  966. // //启用滚动
  967. // $('.right-middle-table').myScroll({
  968. // speed: 40, //数值越大,速度越慢
  969. // rowHeight: 40 //li的高度
  970. // });
  971. // }
  972. }
  973. });
  974. })(1, true);
  975. //右下角滚动
  976. (function rightBotTable(e, type) {
  977. $.ajax({
  978. url: host + '/main/productWholesaleVolumeRanking',
  979. success: function (res) {
  980. let resData = res.retBody;
  981. let html = "";
  982. for (var i in resData) {
  983. if (i == 0) {
  984. html += '<li class="ui-flex table-row one"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].productName + '</span><span>' + resData[i].wholesaleQuantity + '</span></li>'
  985. } else if (i == 1) {
  986. html += '<li class="ui-flex table-row two"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].productName + '</span><span>' + resData[i].wholesaleQuantity + '</span></li>'
  987. } else if (i == 2) {
  988. html += '<li class="ui-flex table-row three"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].productName + '</span><span>' + resData[i].wholesaleQuantity + '</span></li>'
  989. } else {
  990. html += '<li class="ui-flex table-row"><span class="index"><b>' + resData[i].rank + '</b></span><span>' + resData[i].productName + '</span><span>' + resData[i].wholesaleQuantity + '</span></li>'
  991. }
  992. }
  993. $('#right-bot-table').html(html);
  994. // if (type) {
  995. // //启用滚动
  996. // $('.right-bot-table').myScroll({
  997. // speed: 40, //数值越大,速度越慢
  998. // rowHeight: 40 //li的高度
  999. // });
  1000. // }
  1001. }
  1002. });
  1003. })(1, true);
  1004. //窗口变化,重绘图表
  1005. win.addEventListener("resize", function () {
  1006. chartObj1.resize();
  1007. chartObj2.setMap().setMapData();
  1008. chartObj3.resize();
  1009. chartObj4.resize();
  1010. chartObj5.resize();
  1011. });
  1012. //全屏
  1013. (function (css) {
  1014. var runPrefixMethod = function (element, method) {
  1015. var usablePrefixMethod;
  1016. ["webkit", "moz", "ms", "o", ""].forEach(function (prefix) {
  1017. if (usablePrefixMethod) return;
  1018. if (prefix === "") {
  1019. // 无前缀,方法首字母小写
  1020. method = method.slice(0, 1).toLowerCase() + method.slice(1);
  1021. }
  1022. var typePrefixMethod = typeof element[prefix + method];
  1023. if (typePrefixMethod + "" !== "undefined") {
  1024. if (typePrefixMethod === "function") {
  1025. usablePrefixMethod = element[prefix + method]();
  1026. } else {
  1027. usablePrefixMethod = element[prefix + method];
  1028. }
  1029. }
  1030. });
  1031. return usablePrefixMethod;
  1032. };
  1033. if (typeof screenX === "number") {
  1034. if (window.top != window.self) {
  1035. try {
  1036. let elem = parent.document.getElementsByTagName('iframe');
  1037. for (let i = 0; i < elem.length; i++) {
  1038. elem[i].setAttribute('allowFullScreen', true); //添加内联框架全屏属性
  1039. }
  1040. } catch (e) {
  1041. }
  1042. }
  1043. let full = document.querySelector(css);
  1044. full.addEventListener("click", function () {
  1045. if (runPrefixMethod(document, "FullScreen") || runPrefixMethod(document, "IsFullScreen")) {
  1046. runPrefixMethod(document, "CancelFullScreen");
  1047. this.title = this.title.replace("退出", "");
  1048. } else if (runPrefixMethod(document.body, "RequestFullScreen")) {
  1049. this.title = this.title.replace("点击", "点击退出");
  1050. }
  1051. });
  1052. } else {
  1053. alert("浏览器太老了!!");
  1054. }
  1055. })('#full-screen');
  1056. })(window);