index.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. var abs = (val, showPoint = true) => {
  2. //金额转换 保留2位小数 并每隔3位用逗号分开 1,234.56
  3. let str = (val / 1).toFixed(2) + ''
  4. let intSum = str.substring(0, str.indexOf(".")).replace(/\B(?=(?:\d{3})+$)/g, ',') //取到整数部分
  5. let dot = str.substring(str.length, str.indexOf(".")) //取到小数部分搜索
  6. let ret = intSum + dot;
  7. return ret;
  8. }
  9. let timer = null;
  10. let timer1 = null;
  11. // 定义一个索引
  12. let index = 0;
  13. // 定义一个索引
  14. let ind = 0;
  15. var pietimer1, pietimer
  16. //左上
  17. function handle1(res) {
  18. if (res.data && res.data.length != 0) {
  19. $('#total').text(`累计新增创客 ${res.data[0].ckcount}`)
  20. $('#todayAdd').text(`累计新增商户 ${res.data[0].shcount}`)
  21. }
  22. }
  23. // 列表
  24. function handle2(res_2) {
  25. $('.firstpanel').empty();
  26. for (var i = 0; i < res_2.data.length; i++) {
  27. const element = `<div class="row"> <span class="col">${res_2.data[i].activationTime}</span><span class="col">${res_2.data[i].productName}</span>
  28. <span class="col">${res_2.data[i].realname}</span>
  29. <span class="col">${res_2.data[i].count}</span>
  30. </div>`
  31. $('.firstpanel').append(element);
  32. };
  33. }
  34. // 左下
  35. function handle3(res_1) {
  36. $('.year').text(`${new Date().getFullYear()}年`)
  37. if (res_1.data && res_1.data.length > 0) {
  38. $('.withdrawAmount').text(abs(res_1.data[0].withdrawAmount))
  39. $('.store-count').text(res_1.data[0].count)
  40. $('.yearsum').text(abs(res_1.data[0].yearsum))
  41. $('.yearcount').text(res_1.data[0].yearcount)
  42. $('.quartersum').text(abs(res_1.data[0].quartersum))
  43. $('.quartercount').text(res_1.data[0].quartercount)
  44. $('.monthsum').text(abs(res_1.data[0].monthsum))
  45. $('.monthcount').text(res_1.data[0].monthcount)
  46. $('.nowsum').text(abs(res_1.data[0].nowsum))
  47. $('.nowcount').text(res_1.data[0].nowcount)
  48. }
  49. }
  50. // 排行榜
  51. function handle4(res_3, res_4, res_5) {
  52. if (res_3 || res_4 || res_5) {
  53. // console.log('handle4','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
  54. let resArr = Array.of(res_3.data, res_4.data, res_5.data)
  55. resArr.map((res, i) => {
  56. // $(`.user-content${i}`).empty();
  57. res.map((item, index) => {
  58. let result = () => {
  59. if (item.openCount || item.openCount === 0) {
  60. return item.openCount
  61. }
  62. if (item.sum || item.sum === 0) {
  63. return abs(item.sum)
  64. }
  65. }
  66. $(`.user-content${i} .item${index} .name`).text(item.RealName ? item.RealName : item.realName);
  67. $(`.user-content${i} .item${index} .count`).text(result());
  68. // let element = `
  69. // <div class="item">
  70. // <span class="name">${item.RealName}</span>
  71. // <span class="count">${result()}</span>
  72. // </div>`
  73. // $(`.user-content${i}`).append(element);
  74. })
  75. // console.log(res_3);
  76. })
  77. }
  78. }
  79. //月度交易额环比
  80. function handle5(res_10, res_11) {
  81. let present = (val) => {
  82. if (val.LastMonthTrade === 0) {
  83. return '100%'
  84. } else {
  85. return (val.ThisMonthTrade / val.LastMonthTrade * 100).toFixed(2) + '%'
  86. };
  87. }
  88. // let present_1 = (val) => {
  89. // if(val.LastMonthTrade === 0){
  90. // return '100%'
  91. // }else{
  92. // return (((val.ThisMonthTrade / val.LastMonthTrade) - 1) * 100).toFixed(2) + '%'
  93. // };
  94. // }
  95. let present_add = (val) => {
  96. return (val.ThisMonthCount / val.LastMonthCount * 100).toFixed(2) + '%'
  97. }
  98. // let present_add_1 = (val) => {
  99. // return (((val.ThisMonthCount / val.LastMonthCount) - 1) * 100).toFixed(2) + '%'
  100. // }
  101. if (res_10) {
  102. $('.mounthResult').text(present(res_10.data[0]));
  103. $('.thismonthsum').text(`${(res_10.data[0].ThisMonthTrade / 10000).toFixed(2)}`);
  104. $('.lastmonthsum').text(`${(res_10.data[0].LastMonthTrade / 10000).toFixed(2)}`);
  105. // $('.result').text(`${ present_1(res_10.data[0])}`);
  106. }
  107. if (res_11) {
  108. $('.addPresent').text(present_add(res_11.data[0]));
  109. $('.addSum').text(`${(res_11.data[0].ThisMonthCount).toFixed(0)}`);
  110. $('.addResult').text(`${(res_11.data[0].LastMonthCount).toFixed(0)}`);
  111. // $('.addResult').text(`${present_add_1(res_11.data[0])}`);
  112. }
  113. }
  114. // 右上折线图
  115. function handle6(res_6, res_7) {
  116. // 定义数据
  117. let real_year = new Array(); //年Y轴数据
  118. let year_xAxis = new Array();
  119. let month_xAxis = new Array(); //14天x轴数据
  120. // let house_xAxis = new Array(); //一天x轴数据
  121. let real_14day = new Array(); //14天Y轴,真实数据
  122. // let real_house = new Array(); //1天Y轴,真实数据
  123. res_6.data.map((item) => {
  124. real_year.push((item.TradeAmount / 10000).toFixed(2))
  125. year_xAxis.push((item.TradeMonth.slice(-2) + '月'))
  126. });
  127. res_7.data.map((item) => {
  128. real_14day.push((item.TradeAmount / 10000).toFixed(2))
  129. month_xAxis.unshift(item.TradeDate + '日');
  130. })
  131. let data = {
  132. year: [
  133. [0],
  134. real_year
  135. ],
  136. month: [],
  137. quarter: [],
  138. };
  139. const chart = echarts.init(document.querySelector(".line"))
  140. const option = {
  141. tooltip: {
  142. trigger: 'axis'
  143. },
  144. legend: {
  145. // 向右距离边框10%
  146. right: '10%',
  147. textStyle: {
  148. color: '#4c9bfd'
  149. }
  150. },
  151. grid: {
  152. show: true, //显示边框
  153. borderColor: '#012f4a', //边框颜色
  154. left: '3%',
  155. right: '4%',
  156. bottom: '3%',
  157. top: '20%', // 距离上边20%
  158. containLabel: true
  159. },
  160. xAxis: {
  161. type: 'category',
  162. boundaryGap: false,
  163. data: year_xAxis,
  164. axisLabel: {
  165. color: '#4c9bfd',
  166. fontSize: 9,
  167. },
  168. axisLine: {
  169. show: false,
  170. },
  171. axisTick: {
  172. show: false,
  173. }
  174. },
  175. yAxis: {
  176. type: 'value',
  177. axisLabel: {
  178. color: '#4c9bfd',
  179. },
  180. axisLine: {
  181. show: false,
  182. },
  183. axisTick: {
  184. show: false,
  185. },
  186. splitLine: {
  187. lineStyle: {
  188. color: "#012f4a"
  189. }
  190. }
  191. },
  192. color: ['#00f2f1', '#ed3f35'],
  193. series: [{
  194. name: '实际交易额',
  195. type: 'line',
  196. stack: '总量',
  197. smooth: true,
  198. data: data.year[1],
  199. }]
  200. };
  201. chart.setOption(option);
  202. window.addEventListener('resize', function () {
  203. chart.resize();
  204. })
  205. if (!timer) {
  206. // 3.点击切换高亮并且切换折线图显示数据
  207. $(".sales .caption a").on('click', function () {
  208. // console.log('111000')
  209. option.series[0].data = [];
  210. // caption里面有5个元素,排序并不是以选取元素进行排序的
  211. index = $(this).index() - 1;
  212. if (index === 0) {
  213. data.year[1] = real_year
  214. option.xAxis.data = year_xAxis
  215. }
  216. if (index === 1) {
  217. option.xAxis.data = month_xAxis
  218. data.month[1] = real_14day
  219. }
  220. if (index === 2) {
  221. option.xAxis.data = house_xAxis
  222. data.quarter[1] = real_house
  223. };
  224. $(this).addClass("active").siblings("a").removeClass("active");
  225. // 在结构新增data-type属性,并赋值,通过新增属性获取属性值
  226. // const attr = $(this).attr('data-type')
  227. const attr = this.dataset.type
  228. // 通过新增属性值获取data对象里面的对应数据
  229. const arr = data[attr];
  230. option.series[0].data = arr[1];
  231. // 重新渲染option数据
  232. chart.setOption(option);
  233. })
  234. $(".point .filter a").on('click', function () {
  235. ind = $(this).index();
  236. // console.log('indeed', ind)
  237. $(this).addClass("active").siblings("a").removeClass("active");
  238. $(".point .data").eq(ind).show().siblings(".data").hide();
  239. })
  240. $(".sales").on('mouseover', function () {
  241. clearInterval(timer);
  242. })
  243. $(".point").on('mouseover', function () {
  244. clearInterval(timer1);
  245. })
  246. $(".sales").on('mouseout', function () {
  247. timer = setInterval(function () {
  248. // 定时器开启,索引自增
  249. index++;
  250. // 当索引值大于等于4,索引重新变为0
  251. if (index >= 3) {
  252. index = 0;
  253. }
  254. // 自动触发点击事件
  255. $(".sales .caption a").eq(index).click();
  256. }, 2000)
  257. })
  258. $(".point").on('mouseout', function () {
  259. timer1 = setInterval(function () {
  260. // 定时器开启,索引自增
  261. ind++;
  262. // 当索引值大于等于4,索引重新变为0
  263. if (ind >= 4) {
  264. ind = 0;
  265. }
  266. // 自动触发点击事件
  267. $(".point .filter a").eq(ind).click();
  268. }, 2000)
  269. })
  270. // 定义一个定时器
  271. timer1 = setInterval(function () {
  272. // 定时器开启,索引自增
  273. ind++;
  274. // 当索引值大于等于4,索引重新变为0
  275. if (ind >= 4) {
  276. ind = 0;
  277. }
  278. // 自动触发点击事件
  279. $(".point .filter a").eq(ind).click();
  280. }, 2000)
  281. // 定义一个定时器
  282. timer = setInterval(function () {
  283. // 定时器开启,索引自增
  284. index++;
  285. // 当索引值大于等于4,索引重新变为0
  286. if (index >= 3) {
  287. index = 0;
  288. }
  289. // 自动触发点击事件
  290. $(".sales .caption a").eq(index).click();
  291. }, 2000)
  292. }
  293. };
  294. // 半圆饼图1
  295. function handle7(res_10) {
  296. const chart = echarts.init(document.querySelector(".quarter1 .gauge"));
  297. let present = 0;
  298. if (res_10.data[0].LastMonthTrade === 0) {
  299. present = 100;
  300. } else {
  301. present = (res_10.data[0].ThisMonthTrade / res_10.data[0].LastMonthTrade * 100).toFixed(2)
  302. }
  303. if (present > 100) {
  304. present = 100
  305. }
  306. const option = {
  307. series: [{
  308. color: ['skyblue', '#777'],
  309. name: '销售进度',
  310. type: 'pie',
  311. radius: ['130%', '150%'],
  312. center: ['48%', '80%'],
  313. label: {
  314. show: false
  315. },
  316. startAngle: 180,
  317. hoverOffset: 0,
  318. data: [{
  319. value: present,
  320. itemStyle: {
  321. // 颜色渐变#00c9e0->#005fc1
  322. color: new echarts.graphic.LinearGradient(
  323. // (x1,y2) 点到点 (x2,y2) 之间进行渐变
  324. 0,
  325. 0,
  326. 0,
  327. 1,
  328. [{
  329. offset: 0,
  330. color: "#00c9e0"
  331. }, // 0 起始颜色
  332. {
  333. offset: 1,
  334. color: "#005fc1"
  335. } // 1 结束颜色
  336. ]
  337. )
  338. }
  339. },
  340. {
  341. value: 100 - present,
  342. itemStyle: {
  343. color: '#12274d'
  344. }
  345. },
  346. {
  347. value: 100,
  348. itemStyle: {
  349. color: 'transparent'
  350. }
  351. },
  352. ],
  353. // silent: true
  354. }]
  355. };
  356. chart.setOption(option);
  357. window.addEventListener('resize', function () {
  358. chart.resize();
  359. })
  360. };
  361. // 半圆饼图2
  362. function handle8(res_11) {
  363. const chart = echarts.init(document.querySelector(".quarter2 .gauge"));
  364. let present = (res_11.data[0].ThisMonthCount / res_11.data[0].LastMonthCount * 100).toFixed(2)
  365. if (present > 100) {
  366. present = 100
  367. }
  368. const option = {
  369. series: [{
  370. color: ['skyblue', '#777'],
  371. name: '销售进度',
  372. type: 'pie',
  373. radius: ['130%', '150%'],
  374. center: ['48%', '80%'],
  375. label: {
  376. show: false
  377. },
  378. startAngle: 180,
  379. hoverOffset: 0,
  380. data: [{
  381. value: present,
  382. itemStyle: {
  383. // 颜色渐变#00c9e0->#005fc1
  384. color: new echarts.graphic.LinearGradient(
  385. // (x1,y2) 点到点 (x2,y2) 之间进行渐变
  386. 0,
  387. 0,
  388. 0,
  389. 1,
  390. [{
  391. offset: 0,
  392. color: "#00c9e0"
  393. }, // 0 起始颜色
  394. {
  395. offset: 1,
  396. color: "#005fc1"
  397. } // 1 结束颜色
  398. ]
  399. )
  400. }
  401. },
  402. {
  403. value: 100 - present,
  404. itemStyle: {
  405. color: '#12274d'
  406. }
  407. },
  408. {
  409. value: 100,
  410. itemStyle: {
  411. color: 'transparent'
  412. }
  413. },
  414. ],
  415. // silent: true
  416. }]
  417. };
  418. chart.setOption(option);
  419. window.addEventListener('resize', function () {
  420. chart.resize();
  421. })
  422. };
  423. //饼图1
  424. function handle9(res_12) {
  425. const chart = echarts.init(document.querySelector(".piebox1"));
  426. const option = {
  427. color: ['#536fc6', '#90cc74', '#f7c95a', '#ee6666', '#73bfdf', '#3ba372', '#fc8450', '#9a60b4', '#eb7acd'],
  428. title: {
  429. text: '开机量统计图',
  430. x: 'center',
  431. y: 'bottom',
  432. textStyle: {
  433. fontSize: '14',
  434. fontWeight: 'normal',
  435. color: '#fff',
  436. }
  437. },
  438. series: [{
  439. name: 'Access From',
  440. type: 'pie',
  441. radius: ['50%', '70%'],
  442. center: ['50%', '45%'],
  443. avoidLabelOverlap: false,
  444. itemStyle: {
  445. borderRadius: 10,
  446. borderColor: '#fff',
  447. borderWidth: 1,
  448. textColor: '#fff'
  449. },
  450. label: {
  451. show: false,
  452. position: 'center'
  453. },
  454. emphasis: {
  455. label: {
  456. show: true,
  457. fontSize: '16',
  458. fontWeight: 'bold',
  459. color: '#fff',
  460. formatter: "{aa|{d}}{bb|%}\n{cc|{b}}",
  461. rich: {
  462. bb: {
  463. color: '#fff'
  464. },
  465. }
  466. }
  467. },
  468. labelLine: {
  469. show: false
  470. },
  471. data: []
  472. }]
  473. };
  474. res_12.data.map((item) => {
  475. option.series[0].data.push({
  476. value: item.count,
  477. name: item.name
  478. })
  479. option.series.name = item.name
  480. option.series[0].name = item.name
  481. })
  482. chart.setOption(option);
  483. window.addEventListener('resize', function () {
  484. chart.resize();
  485. })
  486. chart.dispatchAction({
  487. type: 'downplay',
  488. seriesIndex: 0,
  489. // dataIndex: lastIndex +1
  490. });
  491. chart.dispatchAction({
  492. type: 'highlight',
  493. seriesIndex: 0,
  494. dataIndex: 0
  495. });
  496. let currentIndex = -1
  497. clearInterval(pietimer)
  498. pietimer = setInterval(function () {
  499. var dataLen = option.series[0].data.length;
  500. // 取消之前高亮的图形
  501. chart.dispatchAction({
  502. type: 'downplay',
  503. seriesIndex: 0,
  504. dataIndex: currentIndex
  505. });
  506. currentIndex = (currentIndex + 1) % dataLen;
  507. // 高亮当前图形
  508. chart.dispatchAction({
  509. type: 'highlight',
  510. seriesIndex: 0,
  511. dataIndex: currentIndex
  512. });
  513. // 显示 tooltip
  514. // chart.dispatchAction({
  515. // type: 'showTip',
  516. // seriesIndex: 0,
  517. // dataIndex: currentIndex
  518. // });
  519. }, 1500);
  520. // 处理点击事件并且跳转到相应的百度搜索页面
  521. chart.on('mouseover', function (params) {
  522. console.log('饼图进事件', params)
  523. clearInterval(pietimer)
  524. chart.dispatchAction({
  525. type: 'downplay',
  526. seriesIndex: 0,
  527. });
  528. chart.dispatchAction({
  529. type: 'highlight',
  530. seriesIndex: 0,
  531. dataIndex: params.dataIndex
  532. });
  533. });
  534. chart.on('mouseout', function (params) {
  535. console.log('饼图出事件', params)
  536. chart.dispatchAction({
  537. type: 'downplay',
  538. seriesIndex: 0,
  539. });
  540. currentIndex = params.dataIndex
  541. clearInterval(pietimer)
  542. pietimer = setInterval(function () {
  543. var dataLen = option.series[0].data.length;
  544. // 取消之前高亮的图形
  545. chart.dispatchAction({
  546. type: 'downplay',
  547. seriesIndex: 0,
  548. dataIndex: currentIndex
  549. });
  550. currentIndex = (currentIndex + 1) % dataLen;
  551. // 高亮当前图形
  552. chart.dispatchAction({
  553. type: 'highlight',
  554. seriesIndex: 0,
  555. dataIndex: currentIndex
  556. });
  557. // 显示 tooltip
  558. // chart.dispatchAction({
  559. // type: 'showTip',
  560. // seriesIndex: 0,
  561. // dataIndex: currentIndex
  562. // });
  563. }, 1500);
  564. });
  565. };
  566. //饼图2
  567. function handle10(res_13) {
  568. const chart = echarts.init(document.querySelector(".piebox2"));
  569. const option = {
  570. color: ['#536fc6', '#90cc74', '#f7c95a', '#ee6666', '#73bfdf', '#3ba372', '#fc8450', '#9a60b4', '#eb7acd'],
  571. title: {
  572. text: '交易量统计图',
  573. x: 'center',
  574. y: 'bottom',
  575. textStyle: {
  576. fontSize: '14',
  577. fontWeight: 'normal',
  578. color: '#fff',
  579. }
  580. },
  581. series: [{
  582. name: 'Access From',
  583. type: 'pie',
  584. radius: ['50%', '70%'],
  585. center: ['50%', '45%'],
  586. avoidLabelOverlap: false,
  587. itemStyle: {
  588. borderRadius: 10,
  589. borderColor: '#fff',
  590. borderWidth: 1,
  591. textColor: '#fff'
  592. },
  593. label: {
  594. show: false,
  595. position: 'center'
  596. },
  597. emphasis: {
  598. label: {
  599. show: true,
  600. fontSize: '16',
  601. fontWeight: 'bold',
  602. color: '#fff',
  603. formatter: "{aa|{d}}{bb|%}\n{cc|{b}}",
  604. rich: {
  605. bb: {
  606. color: '#fff',
  607. },
  608. }
  609. }
  610. },
  611. labelLine: {
  612. show: false
  613. },
  614. data: []
  615. }]
  616. };
  617. res_13.data.map((item) => {
  618. option.series[0].data.push({
  619. value: item.sum,
  620. name: item.name
  621. })
  622. })
  623. chart.setOption(option);
  624. window.addEventListener('resize', function () {
  625. chart.resize();
  626. })
  627. chart.dispatchAction({
  628. type: 'downplay',
  629. seriesIndex: 0,
  630. // dataIndex: lastIndex +1
  631. });
  632. chart.dispatchAction({
  633. type: 'highlight',
  634. seriesIndex: 0,
  635. dataIndex: 0
  636. });
  637. let currentIndex = -1
  638. clearInterval(pietimer1)
  639. pietimer1 = setInterval(function () {
  640. var dataLen = option.series[0].data.length;
  641. // 取消之前高亮的图形
  642. chart.dispatchAction({
  643. type: 'downplay',
  644. seriesIndex: 0,
  645. dataIndex: currentIndex
  646. });
  647. currentIndex = (currentIndex + 1) % dataLen;
  648. // 高亮当前图形
  649. chart.dispatchAction({
  650. type: 'highlight',
  651. seriesIndex: 0,
  652. dataIndex: currentIndex
  653. });
  654. // 显示 tooltip
  655. // chart.dispatchAction({
  656. // type: 'showTip',
  657. // seriesIndex: 0,
  658. // dataIndex: currentIndex
  659. // });
  660. }, 1500);
  661. // 处理点击事件并且跳转到相应的百度搜索页面
  662. chart.on('mouseover', function (params) {
  663. console.log('饼图进事件', params)
  664. clearInterval(pietimer1)
  665. chart.dispatchAction({
  666. type: 'downplay',
  667. seriesIndex: 0,
  668. });
  669. chart.dispatchAction({
  670. type: 'highlight',
  671. seriesIndex: 0,
  672. dataIndex: params.dataIndex
  673. });
  674. });
  675. chart.on('mouseout', function (params) {
  676. console.log('饼图出事件', params)
  677. chart.dispatchAction({
  678. type: 'downplay',
  679. seriesIndex: 0,
  680. });
  681. currentIndex = params.dataIndex
  682. clearInterval(pietimer1)
  683. pietimer1 = setInterval(function () {
  684. var dataLen = option.series[0].data.length;
  685. // 取消之前高亮的图形
  686. chart.dispatchAction({
  687. type: 'downplay',
  688. seriesIndex: 0,
  689. dataIndex: currentIndex
  690. });
  691. currentIndex = (currentIndex + 1) % dataLen;
  692. // 高亮当前图形
  693. chart.dispatchAction({
  694. type: 'highlight',
  695. seriesIndex: 0,
  696. dataIndex: currentIndex
  697. });
  698. // 显示 tooltip
  699. // chart.dispatchAction({
  700. // type: 'showTip',
  701. // seriesIndex: 0,
  702. // dataIndex: currentIndex
  703. // });
  704. }, 1500);
  705. });
  706. }