index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. //自调用函数
  2. (function() {
  3. // 1、页面一加载就要知道页面宽度计算
  4. var setFont = function() {
  5. // 因为要定义变量可能和别的变量相互冲突,污染,所有用自调用函数
  6. var html = document.documentElement; // 获取html
  7. // 获取宽度
  8. var width = html.clientWidth;
  9. // 判断
  10. if (width < 1024) width = 1024
  11. if (width > 1920) width = 1920
  12. // 设置html的基准值
  13. var fontSize = width / 80 + 'px';
  14. // 设置给html
  15. html.style.fontSize = fontSize;
  16. }
  17. setFont();
  18. // 2、页面改变的时候也需要设置
  19. // 尺寸改变事件
  20. window.onresize = function() {
  21. setFont();
  22. }
  23. })();
  24. $.get('https://aggadmin.jucai.gov.cn/admin/api/bi_talent', (res) => {
  25. init(res)
  26. });
  27. function init(data) {
  28. $('#industry_enterprise_num').text(data.industry_enterprise_num);
  29. $('#industry_institution_employee').text(data.industry_institution_employee);
  30. $('#industry_institution_num').text(data.industry_institution_num);
  31. $('#industry_institution_turnover').text(data.industry_institution_turnover);
  32. $('#industry_service_num').text(data.industry_service_num);
  33. $('#talent_problem_deal').text(data.talent_problem_deal);
  34. $('#talent_problem_total').text(data.talent_problem_total);
  35. $('#talent_total').text(data.talent_total);
  36. this.talent_count(data);
  37. this.talent_level(data.talent_level);
  38. this.talent_problem(data.talent_problem_cate);
  39. this.pieTalentChannel(data);
  40. this.pieInstitutionType(data);
  41. }
  42. function talent_count(data) {
  43. var htmlArr = [];
  44. htmlArr['talent_industry'] = '';
  45. htmlArr['talent_age'] = '';
  46. htmlArr['talent_education'] = '';
  47. data.talent_industry.forEach(function (item) {
  48. htmlArr['talent_industry'] += `<li><span>${item.name}</span><span>${item.count} <s class="icon-up"></s></span></li>`;
  49. });
  50. data.talent_age.forEach(function (item) {
  51. htmlArr['talent_age'] += `<li><span>${item.name}</span><span>${item.count} <s class="icon-up"></s></span></li>`;
  52. });
  53. data.talent_education.forEach(function (item) {
  54. htmlArr['talent_education'] += `<li><span>${item.name}</span><span>${item.count} <s class="icon-up"></s></span></li>`;
  55. });
  56. $('.inner').on('mouseenter', '.sup li', function () {
  57. $(this).addClass('active').siblings().removeClass('active');
  58. //渲染
  59. $('.sub').html(htmlArr[$(this).attr('data-type')]);
  60. });
  61. $('.province .sup li').eq(0).mouseenter();
  62. var index = 0;
  63. var timer = setInterval(() => {
  64. index++;
  65. if (index > 2) {
  66. index = 0;
  67. }
  68. $('.sup li').eq(index).mouseenter();
  69. }, 2000);
  70. }
  71. function talent_level(data) {
  72. let titleArr = [];
  73. let countArr = [];
  74. let total = 0;
  75. let count = data.length;
  76. // 中间省略的数据 准备三项
  77. var hiddenItem = {
  78. name: '',
  79. value: 10,
  80. // 柱子颜色
  81. itemStyle: {
  82. color: '#254065'
  83. },
  84. // 鼠标经过柱子颜色
  85. emphasis: {
  86. itemStyle: {
  87. color: '#254065'
  88. }
  89. },
  90. // 工具提示隐藏
  91. tooltip: {
  92. extraCssText: 'opacity:0'
  93. }
  94. };
  95. data.forEach((item, index) => {
  96. if (index < 7 || index + 7 >= count) {
  97. titleArr.push(item.name)
  98. countArr.push(item.count)
  99. } else if (count > 12 && index == 7) {
  100. //随机三个
  101. let arr = []
  102. for (let i = 7; i < count - 7; i++) {
  103. arr.push(i)
  104. }
  105. let randomArr = [];
  106. while (randomArr.length < 3) {
  107. let temp = (Math.random() * arr.length) >> 0;
  108. randomArr.push(arr.splice(temp, 1)[0]);
  109. }
  110. randomArr.forEach((randomIndex) => {
  111. titleArr.push(data[randomIndex].name)
  112. countArr.push(data[randomIndex].count)
  113. })
  114. }
  115. total += (item.count - 0)
  116. });
  117. $('.talent_level-total').text(total)
  118. option = {
  119. // 工具提示
  120. tooltip: {
  121. // 触发类型 经过轴触发axis 经过轴触发item
  122. trigger: 'item',
  123. // 轴触发提示才有效
  124. axisPointer: {
  125. // 默认为直线,可选为:'line' 线效果 | 'shadow' 阴影效果
  126. type: 'shadow'
  127. }
  128. },
  129. // 图表边界控制
  130. grid: {
  131. // 距离 上右下左 的距离
  132. left: '0',
  133. right: '3%',
  134. bottom: '3%',
  135. top: '5%',
  136. // 大小是否包含文本【类似于boxsizing】
  137. containLabel: true,
  138. //显示边框
  139. show: true,
  140. //边框颜色
  141. borderColor: 'rgba(0, 240, 255, 0.3)'
  142. },
  143. // 控制x轴
  144. xAxis: [{
  145. // 使用类目,必须有data属性
  146. type: 'category',
  147. // 使用 data 中的数据设为刻度文字
  148. data: titleArr,
  149. // 刻度设置
  150. axisTick: {
  151. // true意思:图形在刻度中间
  152. // false意思:图形在刻度之间
  153. alignWithLabel: false,
  154. show: false
  155. },
  156. //文字
  157. axisLabel: {
  158. color: '#4c9bfd'
  159. }
  160. }],
  161. // 控制y轴
  162. yAxis: [{
  163. // 使用数据的值设为刻度文字
  164. type: 'value',
  165. axisTick: {
  166. // true意思:图形在刻度中间
  167. // false意思:图形在刻度之间
  168. alignWithLabel: false,
  169. show: false
  170. },
  171. //文字
  172. axisLabel: {
  173. color: '#4c9bfd'
  174. },
  175. splitLine: {
  176. lineStyle: {
  177. color: 'rgba(0, 240, 255, 0.3)'
  178. }
  179. },
  180. }],
  181. // 控制x轴
  182. series: [
  183. {
  184. // series配置
  185. // 颜色
  186. itemStyle: {
  187. // 提供的工具函数生成渐变颜色
  188. color: new echarts.graphic.LinearGradient(
  189. // (x1,y2) 点到点 (x2,y2) 之间进行渐变
  190. 0, 0, 0, 1,
  191. [{
  192. offset: 0,
  193. color: '#00fffb'
  194. }, // 0 起始颜色
  195. {
  196. offset: 1,
  197. color: '#0061ce'
  198. } // 1 结束颜色
  199. ]
  200. )
  201. },
  202. // 图表数据名称
  203. name: '层次人数',
  204. // 图表类型
  205. type: 'bar',
  206. // 柱子宽度
  207. barWidth: '60%',
  208. // 数据
  209. data: countArr
  210. }
  211. ]
  212. };
  213. var myechart = echarts.init($('.talent_level')[0]);
  214. myechart.setOption(option);
  215. }
  216. function talent_problem(data) {
  217. let titleArr = [];
  218. let countArr = [];
  219. let count = data.length;
  220. // 中间省略的数据 准备三项
  221. var hiddenItem = {
  222. name: '',
  223. value: 10,
  224. // 柱子颜色
  225. itemStyle: {
  226. color: '#254065'
  227. },
  228. // 鼠标经过柱子颜色
  229. emphasis: {
  230. itemStyle: {
  231. color: '#254065'
  232. }
  233. },
  234. // 工具提示隐藏
  235. tooltip: {
  236. extraCssText: 'opacity:0'
  237. }
  238. };
  239. data.forEach((item, index) => {
  240. titleArr.push(item.name)
  241. countArr.push(item.count)
  242. });
  243. option = {
  244. // 工具提示
  245. tooltip: {
  246. // 触发类型 经过轴触发axis 经过轴触发item
  247. trigger: 'item',
  248. // 轴触发提示才有效
  249. axisPointer: {
  250. // 默认为直线,可选为:'line' 线效果 | 'shadow' 阴影效果
  251. type: 'shadow'
  252. }
  253. },
  254. // 图表边界控制
  255. grid: {
  256. // 距离 上右下左 的距离
  257. left: '0',
  258. right: '3%',
  259. bottom: '3%',
  260. top: '5%',
  261. // 大小是否包含文本【类似于boxsizing】
  262. containLabel: true,
  263. //显示边框
  264. show: true,
  265. //边框颜色
  266. borderColor: 'rgba(0, 240, 255, 0.3)'
  267. },
  268. // 控制x轴
  269. xAxis: [{
  270. // 使用类目,必须有data属性
  271. type: 'category',
  272. // 使用 data 中的数据设为刻度文字
  273. data: titleArr,
  274. // 刻度设置
  275. axisTick: {
  276. // true意思:图形在刻度中间
  277. // false意思:图形在刻度之间
  278. alignWithLabel: false,
  279. show: false
  280. },
  281. //文字
  282. axisLabel: {
  283. interval: 0, // 强制显示所有标签
  284. color: '#4c9bfd'
  285. }
  286. }],
  287. // 控制y轴
  288. yAxis: [{
  289. // 使用数据的值设为刻度文字
  290. type: 'value',
  291. axisTick: {
  292. // true意思:图形在刻度中间
  293. // false意思:图形在刻度之间
  294. alignWithLabel: false,
  295. show: false
  296. },
  297. //文字
  298. axisLabel: {
  299. color: '#4c9bfd'
  300. },
  301. splitLine: {
  302. lineStyle: {
  303. color: 'rgba(0, 240, 255, 0.3)'
  304. }
  305. },
  306. }],
  307. // 控制x轴
  308. series: [
  309. {
  310. // series配置
  311. // 颜色
  312. itemStyle: {
  313. // 提供的工具函数生成渐变颜色
  314. color: new echarts.graphic.LinearGradient(
  315. // (x1,y2) 点到点 (x2,y2) 之间进行渐变
  316. 0, 0, 0, 1,
  317. [{
  318. offset: 0,
  319. color: '#00fffb'
  320. }, // 0 起始颜色
  321. {
  322. offset: 1,
  323. color: '#0061ce'
  324. } // 1 结束颜色
  325. ]
  326. )
  327. },
  328. // 图表数据名称
  329. name: '咨询人数',
  330. // 图表类型
  331. type: 'bar',
  332. // 柱子宽度
  333. barWidth: '60%',
  334. // 数据
  335. data: countArr
  336. }
  337. ]
  338. };
  339. var myechart = echarts.init($('.talent_problem')[0]);
  340. myechart.setOption(option);
  341. }
  342. function pieTalentChannel(data) {
  343. let recruit_age = data.talent_channel;
  344. let total = 0;
  345. let other = 0;
  346. var myechartAge = echarts.init($('.talent_channel')[0]);
  347. recruit_age.map((item, index) => {
  348. if (item.name == '其他渠道') {
  349. other = item.count;
  350. } else {
  351. total += item.count - 0;
  352. }
  353. item.value = item.count;
  354. return item;
  355. });
  356. $('#talent_channel_total').text(total);
  357. $('#talent_channel_other').text(other);
  358. option = {
  359. // 控制提示
  360. tooltip: {
  361. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  362. trigger: 'item',
  363. // 格式化提示内容:
  364. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  365. formatter: "{b} : {c} ({d}%)"
  366. },
  367. // 控制图表
  368. series: [{
  369. // 图表名称
  370. name: '咨询渠道',
  371. // 图表类型
  372. type: 'pie',
  373. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  374. // 百分比基于 图表DOM容器的半径
  375. radius: ['10%', '70%'],
  376. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  377. center: ['50%', '50%'],
  378. // 半径模式,另外一种是 area 面积模式
  379. roseType: 'radius',
  380. // 数据集 value 数据的值 name 数据的名称
  381. data: recruit_age,
  382. //文字调整
  383. label: {
  384. fontSize: 10
  385. },
  386. //引导线
  387. labelLine: {
  388. length: 8,
  389. length2: 10
  390. }
  391. }],
  392. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  393. };
  394. myechartAge.setOption(option);
  395. }
  396. function pieInstitutionType(data) {
  397. let recruit_age = data.industry_institution_type;
  398. let total = 0;
  399. let other = 0;
  400. var myechartAge = echarts.init($('.institution_type')[0]);
  401. recruit_age.map((item, index) => {
  402. if (item.name == '其他') {
  403. other = item.count;
  404. } else {
  405. total += item.count - 0;
  406. }
  407. item.value = item.count;
  408. return item;
  409. });
  410. $('#institution_type_total').text(total);
  411. $('#institution_type_other').text(other);
  412. option = {
  413. // 控制提示
  414. tooltip: {
  415. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  416. trigger: 'item',
  417. // 格式化提示内容:
  418. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  419. formatter: "{b} : {c} ({d}%)"
  420. },
  421. // 控制图表
  422. series: [{
  423. // 图表名称
  424. name: '机构类型',
  425. // 图表类型
  426. type: 'pie',
  427. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  428. // 百分比基于 图表DOM容器的半径
  429. radius: ['10%', '70%'],
  430. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  431. center: ['50%', '50%'],
  432. // 半径模式,另外一种是 area 面积模式
  433. roseType: 'radius',
  434. // 数据集 value 数据的值 name 数据的名称
  435. data: recruit_age,
  436. //文字调整
  437. label: {
  438. fontSize: 10
  439. },
  440. //引导线
  441. labelLine: {
  442. length: 8,
  443. length2: 10
  444. }
  445. }],
  446. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  447. };
  448. myechartAge.setOption(option);
  449. }
  450. let second = 10;
  451. let set = null;
  452. function countdown() {
  453. set = setInterval(() => {
  454. second--;
  455. if (second == 0) {
  456. location.href = "/bi";
  457. }
  458. $('#countdown').text(second);
  459. },1000);
  460. }
  461. $(document).ready(() => {
  462. countdown();
  463. });
  464. $('#countdown').click(() => {
  465. if (set) {
  466. clearInterval(set);
  467. set = null;
  468. } else {
  469. countdown();
  470. }
  471. });