index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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://www.jucai.gov.cn/api/config/bi/agg', (res) => {
  25. agg_init(res)
  26. });
  27. $.get('https://www.jucai.gov.cn/api/config/bi/company', (res) => {
  28. company_init(res)
  29. });
  30. function agg_init(data) {
  31. $('.resume_sex-total').text(data.resume_sex[3].count);
  32. $('.resume_sex-male').text(data.resume_sex[1].count);
  33. $('.resume_sex-female').text(data.resume_sex[2].count);
  34. $('.recruit_count').text(data.recruit_count);
  35. $('.recruit_post').text(data.recruit_post);
  36. $('.recruit_apply').text(data.recruit_apply);
  37. this.resume_trade(data.resume_trade);
  38. this.resume_age(data.resume_age);
  39. this.resume_education(data.resume_education);
  40. this.pieAge(data);
  41. this.pieEdu(data);
  42. }
  43. function company_init(data) {
  44. this.company_total(data);
  45. this.company_count(data);
  46. }
  47. function resume_trade(data) {
  48. let titleArr = [];
  49. let countArr = [];
  50. data.forEach((item, index) => {
  51. titleArr.push(item.name)
  52. countArr.push(item.count)
  53. });
  54. var option = {
  55. //鼠标提示工具
  56. tooltip: {
  57. trigger: 'axis'
  58. },
  59. xAxis: {
  60. // 类目类型
  61. type: 'category',
  62. // x轴刻度文字
  63. data: titleArr,
  64. axisTick: {
  65. show: false //去除刻度线
  66. },
  67. axisLabel: {
  68. color: '#4c9bfd' //文本颜色
  69. },
  70. axisLine: {
  71. show: false //去除轴线
  72. },
  73. boundaryGap: false //去除轴内间距
  74. },
  75. yAxis: {
  76. // 数据作为刻度文字
  77. type: 'value',
  78. axisTick: {
  79. show: false //去除刻度线
  80. },
  81. axisLabel: {
  82. color: '#4c9bfd' //文本颜色
  83. },
  84. axisLine: {
  85. show: false //去除轴线
  86. },
  87. boundaryGap: false //去除轴内间距
  88. },
  89. //图例组件
  90. legend: {
  91. textStyle: {
  92. color: '#4c9bfd' // 图例文字颜色
  93. },
  94. right: '10%' //距离右边10%
  95. },
  96. // 设置网格样式
  97. grid: {
  98. show: true, // 显示边框
  99. top: '20%',
  100. left: '3%',
  101. right: '4%',
  102. bottom: '3%',
  103. borderColor: '#012f4a', // 边框颜色
  104. containLabel: true // 包含刻度文字在内
  105. },
  106. series: [{
  107. name: '求职人数',
  108. // 数据
  109. data: countArr,
  110. // 图表类型
  111. type: 'line',
  112. // 圆滑连接
  113. smooth: true,
  114. itemStyle: {
  115. color: '#00f2f1' // 线颜色
  116. }
  117. }]
  118. };
  119. var myechart = echarts.init($('.resume_trade')[0]);
  120. myechart.setOption(option);
  121. }
  122. function resume_age(data) {
  123. let unknown = 0;
  124. let total = 0;
  125. data.map((item, index) => {
  126. if (item.name == '其他') {
  127. unknown += item.count;
  128. //其他数据
  129. item.value = item.count;
  130. } else {
  131. total += item.count;
  132. item.value = item.count;
  133. }
  134. return item;
  135. });
  136. var myechar = echarts.init($('.resume_age')[0]);
  137. option = {
  138. // 控制提示
  139. tooltip: {
  140. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  141. trigger: 'item',
  142. // 格式化提示内容:
  143. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  144. formatter: "{a} <br/>{b} : {c} ({d}%)"
  145. },
  146. // 控制图表
  147. series: [{
  148. // 图表名称
  149. name: '年龄',
  150. // 图表类型
  151. type: 'pie',
  152. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  153. // 百分比基于 图表DOM容器的半径
  154. radius: ['10%', '70%'],
  155. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  156. center: ['50%', '50%'],
  157. // 半径模式,另外一种是 area 面积模式
  158. roseType: 'radius',
  159. // 数据集 value 数据的值 name 数据的名称
  160. data: data,
  161. //文字调整
  162. label: {
  163. fontSize: 10
  164. },
  165. //引导线
  166. labelLine: {
  167. length: 8,
  168. length2: 10
  169. }
  170. }],
  171. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  172. };
  173. myechar.setOption(option);
  174. }
  175. function resume_education(data) {
  176. let unknown = 0;
  177. let total = 0;
  178. data.map((item, index) => {
  179. if (item.name == '其他') {
  180. unknown += item.count;
  181. //其他数据
  182. item.value = item.count;
  183. } else {
  184. total += item.count;
  185. item.value = item.count;
  186. }
  187. return item;
  188. });
  189. $('.resume_education-unknown').text(unknown);
  190. $('.resume_education-total').text(total);
  191. var myechar = echarts.init($('.resume_education')[0]);
  192. option = {
  193. // 控制提示
  194. tooltip: {
  195. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  196. trigger: 'item',
  197. // 格式化提示内容:
  198. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  199. formatter: "{a} <br/>{b} : {c} ({d}%)"
  200. },
  201. // 控制图表
  202. series: [{
  203. // 图表名称
  204. name: '学历',
  205. // 图表类型
  206. type: 'pie',
  207. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  208. // 百分比基于 图表DOM容器的半径
  209. radius: ['10%', '70%'],
  210. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  211. center: ['50%', '50%'],
  212. // 半径模式,另外一种是 area 面积模式
  213. roseType: 'radius',
  214. // 数据集 value 数据的值 name 数据的名称
  215. data: data,
  216. //文字调整
  217. label: {
  218. fontSize: 10
  219. },
  220. //引导线
  221. labelLine: {
  222. length: 8,
  223. length2: 10
  224. }
  225. }],
  226. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  227. };
  228. myechar.setOption(option);
  229. }
  230. function pieAge(data) {
  231. let recruit_age = data.recruit_age;
  232. let gt35 = 0;
  233. let lt35 = 0;
  234. recruit_age.map((item, index) => {
  235. if (item.name == '35到40岁' || item.name == '40岁以上') {
  236. gt35 += item.count;
  237. //其他数据
  238. item.value = item.count;
  239. } else {
  240. lt35 += item.count;
  241. item.value = item.count;
  242. }
  243. return item;
  244. });
  245. $('.age-gt35').text(gt35);
  246. $('.age-lt35').text(lt35);
  247. var myechartAge = echarts.init($('.recruit_age')[0]);
  248. option = {
  249. // 控制提示
  250. tooltip: {
  251. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  252. trigger: 'item',
  253. // 格式化提示内容:
  254. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  255. formatter: "{a} <br/>{b} : {c} ({d}%)"
  256. },
  257. // 控制图表
  258. series: [{
  259. // 图表名称
  260. name: '年龄',
  261. // 图表类型
  262. type: 'pie',
  263. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  264. // 百分比基于 图表DOM容器的半径
  265. radius: ['10%', '70%'],
  266. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  267. center: ['50%', '50%'],
  268. // 半径模式,另外一种是 area 面积模式
  269. roseType: 'radius',
  270. // 数据集 value 数据的值 name 数据的名称
  271. data: recruit_age,
  272. //文字调整
  273. label: {
  274. fontSize: 10
  275. },
  276. //引导线
  277. labelLine: {
  278. length: 8,
  279. length2: 10
  280. }
  281. }],
  282. color: ['#006cff', '#9fe6b8', '#32c5e9', '#1d9dff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff']
  283. };
  284. myechartAge.setOption(option);
  285. }
  286. function pieEdu(data) {
  287. let eduction = data.recruit_education;
  288. let unknown = 0;
  289. let total = 0;
  290. eduction.map((item, index) => {
  291. if (item.name == '其他') {
  292. unknown += item.count;
  293. eduction.splice(index, 1);
  294. } else {
  295. total += item.count;
  296. item.value = item.count;
  297. }
  298. return item;
  299. });
  300. $('.edu-unknown').text(unknown);
  301. $('.edu-total').text(total);
  302. var myechart = echarts.init($('.recruit_education')[0]);
  303. option = {
  304. // 控制提示
  305. tooltip: {
  306. // 非轴图形,使用item的意思是放到数据对应图形上触发提示
  307. trigger: 'item',
  308. // 格式化提示内容:
  309. // a 代表图表名称 b 代表数据名称 c 代表数据 d代表 当前数据/总数据的比例
  310. formatter: "{a} <br/>{b} : {c} ({d}%)"
  311. },
  312. // 控制图表
  313. series: [{
  314. // 图表名称
  315. name: '学历',
  316. // 图表类型
  317. type: 'pie',
  318. // 南丁格尔玫瑰图 有两个圆 内圆半径10% 外圆半径70%
  319. // 百分比基于 图表DOM容器的半径
  320. radius: ['10%', '70%'],
  321. // 图表中心位置 left 50% top 50% 距离图表DOM容器
  322. center: ['50%', '50%'],
  323. // 半径模式,另外一种是 area 面积模式
  324. roseType: 'radius',
  325. // 数据集 value 数据的值 name 数据的名称
  326. data: eduction,
  327. //文字调整
  328. label: {
  329. fontSize: 10
  330. },
  331. //引导线
  332. labelLine: {
  333. length: 8,
  334. length2: 10
  335. }
  336. }],
  337. color: ['#006cff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff', '#9fe6b8', '#32c5e9', '#1d9dff']
  338. };
  339. myechart.setOption(option);
  340. }
  341. function company_total(data) {
  342. $('.company_number').text(data.total_count[0].count);
  343. $('.jobs_number').text(data.total_count[1].count);
  344. }
  345. function company_count(data) {
  346. //事件委托
  347. $('.monitor').on('click', ' a', function () {
  348. //点击当前的a 加类名 active 他的兄弟删除类名
  349. $(this).addClass('active').siblings().removeClass('active');
  350. //获取一一对应的下标
  351. var index = $(this).index();
  352. //选取content 然后狗日对应下标的 显示 当前的兄弟.content隐藏
  353. $('.content').eq(index).show().siblings('.content').hide();
  354. });
  355. var index = 0;
  356. var monitortimer = setInterval(() => {
  357. index++;
  358. if (index > 1) {
  359. index = 0;
  360. }
  361. $('.monitor a').eq(index).click();
  362. }, 5000);
  363. //填充数据
  364. var company_trade = data.company_trade;
  365. var job_category = data.job_category;
  366. var html = '';
  367. company_trade.forEach(function(item) {
  368. html += `<div class="row">`;
  369. html += `<span class="col">${item.name}</span>`;
  370. html += `<span class="col">${item.count}</span>`;
  371. html += `<span class="icon-dot"></span>`;
  372. html += `</div>`;
  373. });
  374. //渲染
  375. $('.company_trade').html(html);
  376. html = '';
  377. job_category.forEach(function(item) {
  378. html += `<div class="row">`;
  379. html += `<span class="col">${item.name}</span>`;
  380. html += `<span class="col">${item.count}</span>`;
  381. html += `<span class="icon-dot"></span>`;
  382. html += `</div>`;
  383. });
  384. //渲染
  385. $('.job_category').html(html);
  386. //滚动
  387. //原理:把marquee下面的子盒子都复制一遍 加入到marquee中
  388. // 然后动画向上滚动,滚动到一半重新开始滚动
  389. //因为选取的是两个marquee 所以要遍历
  390. $('.monitor .marquee').each(function (index, dom) {
  391. //将每个 的所有子级都复制一遍
  392. var rows = $(dom).children().clone();
  393. //再将新的到的加入原来的
  394. $(dom).append(rows);
  395. });
  396. }
  397. let second = 10;
  398. let set = null;
  399. function countdown() {
  400. set = setInterval(() => {
  401. second--;
  402. if (second == 0) {
  403. location.href = "/linggong";
  404. }
  405. $('#countdown').text(second);
  406. },1000);
  407. }
  408. $(document).ready(() => {
  409. countdown();
  410. });
  411. $('#countdown').click(() => {
  412. if (set) {
  413. clearInterval(set);
  414. set = null;
  415. } else {
  416. countdown();
  417. }
  418. });