detail.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. <template>
  2. <div>
  3. <div class="wrapper pc" v-if="screenWidth > 960">
  4. <div class="title">{{city}}-{{job}}收入水平</div>
  5. <div class="subtitle">{{city}}{{job}}平均工资:¥{{avg_salary}}/月,取自23212份数据样本,较2018年,减少1.1%,统计来自程序员客栈(proginn.com)</div>
  6. <div class="content">
  7. <div class="module-wrapper">
  8. <div class="module-title">开发者薪资范围分布</div>
  9. <div id="range-chart" class="range-chart"></div>
  10. </div>
  11. <div class="module-wrapper">
  12. <div class="average-title">平均工资:¥{{avg_salary}}元/月</div>
  13. <div class="average-subtitle">最高为{{max_salary}}元/月,最低为{{min_salary}}元/月其中,平均工资为{{avg_salary}}元/月</div>
  14. <img class="average-img" src="@/assets/img/salary/average_salary.png" alt="">
  15. </div>
  16. <div class="module-wrapper">
  17. <div class="module-title">杭州其他岗位平均工资</div>
  18. <div id="industry-chart" class="industry-chart"></div>
  19. </div>
  20. <div class="module-wrapper">
  21. <div class="module-title">按工作经验统计</div>
  22. <div id="experience-chart" class="experience-chart"></div>
  23. </div>
  24. <!-- <div class="module-wrapper">-->
  25. <!-- <div class="module-title">按学历统计</div>-->
  26. <!-- <div id="education-chart" class="education-chart"></div>-->
  27. <!-- </div>-->
  28. <!-- <div class="module-wrapper">-->
  29. <!-- <div class="module-title">按各城市岗位需求统计</div>-->
  30. <!-- <div id="city-chart" class="city-chart"></div>-->
  31. <!-- </div>-->
  32. <div class="module-wrapper">
  33. <div class="module-title">全国城市{{job}}平均工资</div>
  34. <div class="module-list">
  35. <div class="module-item" v-for="citys in allCitySalary">
  36. <div class="module-label">{{citys.city}}</div>
  37. <div class="module-line"></div>
  38. <div class="module-salary">¥{{citys.salary}}元/月</div>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="module-wrapper">
  43. <div class="module-title">{{city}}其他岗位平均工资</div>
  44. <div class="module-list">
  45. <div class="module-item" v-for="jobs in jobList">
  46. <div class="module-label">{{jobs.job}}</div>
  47. <div class="module-line"></div>
  48. <div class="module-salary">¥{{jobs.salary}}元/月</div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="wrapper mobile" v-else-if="screenWidth > 0">
  55. <div class="title-wrapper">
  56. <div class="title">{{city}}-{{job}}收入水平</div>
  57. <div class="subtitle">杭州产品经理平均工资:¥66666/月,取自23212份数据样本,较2018年,减少1.1%,统计来自程序员客栈(proginn.com)</div>
  58. </div>
  59. <div class="module-wrapper">
  60. <div class="module-title">开发者薪资排行城市TOP10</div>
  61. <div id="range-chart" class="range-chart"></div>
  62. </div>
  63. <div class="module-wrapper">
  64. <div class="average-title">平均工资:¥13000元/月</div>
  65. <div class="average-subtitle">最高为16000元/月,最低为10000元/月其中,人工智能行业的产品经理平均工资最高达54363元/月</div>
  66. <img class="average-img" src="@/assets/img/salary/average_salary.png" alt="">
  67. </div>
  68. <div class="module-wrapper">
  69. <div class="module-title">杭州其他岗位平均工资</div>
  70. <div id="industry-chart" class="industry-chart"></div>
  71. </div>
  72. <div class="module-wrapper">
  73. <div class="module-title">按工作经验统计</div>
  74. <div id="experience-chart" class="experience-chart"></div>
  75. </div>
  76. <!-- <div class="module-wrapper">-->
  77. <!-- <div class="module-title">按学历统计</div>-->
  78. <!-- <div id="education-chart" class="education-chart"></div>-->
  79. <!-- </div>-->
  80. <!-- <div class="module-wrapper">-->
  81. <!-- <div class="module-title">按各城市岗位需求统计</div>-->
  82. <!-- <div id="city-chart" class="city-chart"></div>-->
  83. <!-- </div>-->
  84. <div class="module-wrapper">
  85. <div class="module-title">全国城市{{job}}平均工资</div>
  86. <div class="module-list">
  87. <div class="module-item" v-for="citys in allCitySalary">
  88. <div class="module-label">{{citys.city}}</div>
  89. <div class="module-line"></div>
  90. <div class="module-salary">¥{{citys.salary}}元/月</div>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="module-wrapper">
  95. <div class="module-title">{{city}}其他岗位平均工资</div>
  96. <div class="module-list">
  97. <div class="module-item" v-for="jobs in jobList">
  98. <div class="module-label">{{jobs.job}}</div>
  99. <div class="module-line"></div>
  100. <div class="module-salary">¥{{jobs.salary}}元/月</div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. export default {
  109. data() {
  110. return {
  111. screenWidth: 0,
  112. job:'',
  113. city:'',
  114. avg_salary:0,
  115. max_salary:0,
  116. min_salary:0,
  117. jobList:[],
  118. experience:[],
  119. allCitySalary:[],
  120. salaryRange:[]
  121. }
  122. },
  123. mounted() {
  124. this.screenWidth = window.screen.width
  125. this.$nextTick(()=>{
  126. this.getData();
  127. // this.getRangeChart();
  128. // this.getIndustryChart();
  129. // this.getExperienceChart();
  130. // this.getEducationChart()
  131. // this.getCityChart()
  132. })
  133. },
  134. methods: {
  135. async getData(){
  136. let query = window.location.search.substring(1);
  137. let vars = query.split("&");
  138. this.job = decodeURI(vars[0].split("=")[1]).replace(/c%23/, "c#");
  139. this.city = decodeURI(vars[1].split("=")[1]);
  140. let params = {
  141. job:this.job,
  142. city:this.city
  143. };
  144. let res = await this.$axios.$post('/api/salary/search_info',params);
  145. this.avg_salary = res.data.info.avg_salary;
  146. this.max_salary = res.data.info.max_salary;
  147. this.min_salary = res.data.info.min_salary;
  148. this.jobList = res.data.jobSort;
  149. this.experience = res.data.experience;
  150. this.allCitySalary = res.data.allCitySalary;
  151. this.salaryRange = res.data.salaryRange;
  152. for (let i=0 ;i < this.jobList.length ;i++){
  153. this.jobList[i].salary = parseInt(this.jobList[i].salary);
  154. }
  155. for (let i=0 ;i < this.experience.length ;i++){
  156. this.experience[i].salary = parseInt(this.experience[i].salary);
  157. }
  158. const sortJob = this.jobList;
  159. const sortExperience = this.experience;
  160. const allSalaryRange = this.salaryRange;
  161. console.log('-------------------------------');
  162. console.log(allSalaryRange);
  163. const chart = new G2.Chart({
  164. container: 'range-chart',
  165. forceFit: true,
  166. height: 300
  167. });
  168. chart.source(allSalaryRange, {
  169. percent: {
  170. formatter: function formatter(val) {
  171. val = val * 100 + '%';
  172. return val;
  173. }
  174. }
  175. });
  176. chart.coord('theta', {
  177. radius: 0.75
  178. });
  179. chart.tooltip({
  180. showTitle: false,
  181. itemTpl: '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
  182. });
  183. chart.intervalStack().position('percent').color('item').label('percent', {
  184. formatter: function formatter(val, item) {
  185. return item.point.item + ': ' + val;
  186. }
  187. }).tooltip('item*percent', function(item, percent) {
  188. percent = percent * 100 + '%';
  189. return {
  190. name: item,
  191. value: percent
  192. };
  193. }).style({
  194. lineWidth: 1,
  195. stroke: '#fff'
  196. });
  197. chart.render();
  198. const chart1 = new G2.Chart({
  199. container: 'industry-chart',
  200. forceFit: true,
  201. height: 300
  202. });
  203. chart1.source(sortJob);
  204. chart1.scale('salary', {
  205. min: 0
  206. });
  207. chart1.scale('job', {
  208. range: [0, 1]
  209. });
  210. chart1.tooltip({
  211. crosshairs: {
  212. type: 'line'
  213. }
  214. });
  215. chart1.line().position('job*salary');
  216. chart1.point().position('job*salary').size(4).shape('circle').style({
  217. stroke: '#fff',
  218. lineWidth: 1
  219. });
  220. chart1.render();
  221. const chart2 = new G2.Chart({
  222. container: 'experience-chart',
  223. forceFit: true,
  224. height: 300
  225. });
  226. chart2.source(sortExperience);
  227. chart2.scale('salary', {
  228. min: 0
  229. });
  230. chart2.scale('experience', {
  231. range: [0, 1]
  232. });
  233. chart2.tooltip({
  234. crosshairs: {
  235. type: 'line'
  236. }
  237. });
  238. chart2.line().position('experience*salary');
  239. chart2.point().position('experience*salary').size(4).shape('circle').style({
  240. stroke: '#fff',
  241. lineWidth: 1
  242. });
  243. chart2.render();
  244. },
  245. getRangeChart() {
  246. const data = [{
  247. item: '事例一',
  248. count: 40,
  249. percent: 0.4
  250. }, {
  251. item: '事例二',
  252. count: 21,
  253. percent: 0.21
  254. }, {
  255. item: '事例三',
  256. count: 17,
  257. percent: 0.17
  258. }, {
  259. item: '事例四',
  260. count: 13,
  261. percent: 0.13
  262. }, {
  263. item: '事例五',
  264. count: 9,
  265. percent: 0.09
  266. }];
  267. const chart = new G2.Chart({
  268. container: 'range-chart',
  269. forceFit: true,
  270. height: 300
  271. });
  272. chart.source(data, {
  273. percent: {
  274. formatter: function formatter(val) {
  275. val = val * 100 + '%';
  276. return val;
  277. }
  278. }
  279. });
  280. chart.coord('theta', {
  281. radius: 0.75
  282. });
  283. chart.tooltip({
  284. showTitle: false,
  285. itemTpl: '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
  286. });
  287. chart.intervalStack().position('percent').color('item').label('percent', {
  288. formatter: function formatter(val, item) {
  289. return item.point.item + ': ' + val;
  290. }
  291. }).tooltip('item*percent', function(item, percent) {
  292. percent = percent * 100 + '%';
  293. return {
  294. name: item,
  295. value: percent
  296. };
  297. }).style({
  298. lineWidth: 1,
  299. stroke: '#fff'
  300. });
  301. chart.render();
  302. },
  303. getIndustryChart() {
  304. const data = [{
  305. industry: '行业一',
  306. salary: 23000
  307. }, {
  308. industry: '行业二',
  309. salary: 18000
  310. }, {
  311. industry: '行业三',
  312. salary: 15000
  313. }, {
  314. industry: '行业四',
  315. salary: 13000
  316. }, {
  317. industry: '行业五',
  318. salary: 16000
  319. }];
  320. const chart = new G2.Chart({
  321. container: 'industry-chart',
  322. forceFit: true,
  323. height: 300
  324. });
  325. chart.source(data);
  326. chart.scale('salary', {
  327. min: 0
  328. });
  329. chart.scale('industry', {
  330. range: [0, 1]
  331. });
  332. chart.tooltip({
  333. crosshairs: {
  334. type: 'line'
  335. }
  336. });
  337. chart.line().position('industry*salary');
  338. chart.point().position('industry*salary').size(4).shape('circle').style({
  339. stroke: '#fff',
  340. lineWidth: 1
  341. });
  342. chart.render();
  343. },
  344. getExperienceChart() {
  345. const data = [{
  346. experience: '第一年',
  347. salary: 7887
  348. }, {
  349. experience: '第二年',
  350. salary: 9014
  351. }, {
  352. experience: '第三年',
  353. salary: 12394
  354. }, {
  355. experience: '第四年',
  356. salary: 13098
  357. }, {
  358. experience: '第五年',
  359. salary: 29295
  360. }];
  361. const chart = new G2.Chart({
  362. container: 'experience-chart',
  363. forceFit: true,
  364. height: 300
  365. });
  366. chart.source(data);
  367. chart.scale('salary', {
  368. min: 0
  369. });
  370. chart.scale('experience', {
  371. range: [0, 1]
  372. });
  373. chart.tooltip({
  374. crosshairs: {
  375. type: 'line'
  376. }
  377. });
  378. chart.line().position('experience*salary');
  379. chart.point().position('experience*salary').size(4).shape('circle').style({
  380. stroke: '#fff',
  381. lineWidth: 1
  382. });
  383. chart.render();
  384. },
  385. // getEducationChart() {
  386. // const data = [{
  387. // education: '高中',
  388. // salary: 7887
  389. // }, {
  390. // education: '大专',
  391. // salary: 9014
  392. // }, {
  393. // education: '本科',
  394. // salary: 12394
  395. // }, {
  396. // education: '硕士',
  397. // salary: 13098
  398. // }, {
  399. // education: '博士',
  400. // salary: 29295
  401. // }];
  402. // const chart = new G2.Chart({
  403. // container: 'education-chart',
  404. // forceFit: true,
  405. // height: 300
  406. // });
  407. // chart.source(data);
  408. // chart.scale('salary', {
  409. // min: 0
  410. // });
  411. // chart.scale('education', {
  412. // range: [0, 1]
  413. // });
  414. // chart.tooltip({
  415. // crosshairs: {
  416. // type: 'line'
  417. // }
  418. // });
  419. // chart.line().position('education*salary');
  420. // chart.point().position('education*salary').size(4).shape('circle').style({
  421. // stroke: '#fff',
  422. // lineWidth: 1
  423. // });
  424. // chart.render();
  425. // },
  426. // getCityChart() {
  427. // const data = [
  428. // {
  429. // city: '北京',
  430. // salary: 23000
  431. // }, {
  432. // city: '上海',
  433. // salary: 15000
  434. // }, {
  435. // city: '深圳',
  436. // salary: 18000
  437. // }, {
  438. // city: '杭州',
  439. // salary: 13000
  440. // }, {
  441. // city: '武汉',
  442. // salary: 16000
  443. // }, {
  444. // city: '长沙',
  445. // salary: 10000
  446. // }, {
  447. // city: '成都',
  448. // salary: 17000
  449. // }, {
  450. // city: '广州',
  451. // salary: 14000
  452. // }, {
  453. // city: '南京',
  454. // salary: 10000
  455. // }, {
  456. // city: '苏州',
  457. // salary: 24000
  458. // }
  459. // ]
  460. // const chart = new G2.Chart({
  461. // container: 'city-chart',
  462. // forceFit: true,
  463. // height: 300
  464. // });
  465. // chart.source(data);
  466. // chart.scale('salary', {
  467. // min: 0
  468. // });
  469. // chart.scale('city', {
  470. // range: [0, 1]
  471. // });
  472. // chart.tooltip({
  473. // crosshairs: {
  474. // type: 'line'
  475. // }
  476. // });
  477. // chart.line().position('city*salary');
  478. // chart.point().position('city*salary').size(4).shape('circle').style({
  479. // stroke: '#fff',
  480. // lineWidth: 1
  481. // });
  482. // chart.render();
  483. // }
  484. }
  485. }
  486. </script>
  487. <style lang="scss" scope>
  488. .wrapper {
  489. overflow: hidden;
  490. }
  491. .main {
  492. margin: 0;
  493. width: 100%;
  494. }
  495. .pc {
  496. margin: 10px auto;
  497. padding-bottom: 36px;
  498. width: 1000px;
  499. background-color: #ffffff;
  500. .title {
  501. margin-top: 30px;
  502. margin-left: 18px;
  503. line-height: 28px;
  504. font-weight: 600;
  505. font-size: 20px;
  506. color: #333333;
  507. }
  508. .subtitle {
  509. margin-top: 7px;
  510. margin-left: 18px;
  511. line-height: 17px;
  512. font-size: 12px;
  513. color: #999999;
  514. }
  515. .content {
  516. margin-top: 51px;
  517. display: flex;
  518. justify-content: center;
  519. flex-wrap: wrap;
  520. }
  521. .module-wrapper {
  522. overflow: hidden;
  523. width: 480px;
  524. min-height: 366px;
  525. border: 1px solid #EBEBEB;
  526. }
  527. .module-title {
  528. margin-top: 22px;
  529. margin-left: 31px;
  530. line-height: 25px;
  531. font-weight: 600;
  532. font-size: 18px;
  533. color: #000000;
  534. }
  535. .range-chart, .industry-chart, .experience-chart, .education-chart, .city-chart {
  536. margin-top: 38px;
  537. margin-left: -20px;
  538. }
  539. .average-title {
  540. margin-top: 51px;
  541. line-height: 28px;
  542. text-align: center;
  543. font-weight: 600;
  544. font-size: 20px;
  545. color: #000000;
  546. }
  547. .average-subtitle {
  548. margin: 9px auto 0;
  549. width: 422px;
  550. line-height: 18px;
  551. font-size: 13px;
  552. color: #666666;
  553. }
  554. .average-img {
  555. margin: 50px auto 0;
  556. display: block;
  557. width: 235px;
  558. height: 135px;
  559. }
  560. .module-list {
  561. margin-top: 24px;
  562. margin-bottom: 10px;
  563. }
  564. .module-item {
  565. display: flex;
  566. align-items: center;
  567. }
  568. .module-label {
  569. margin-left: 25px;
  570. line-height: 32px;
  571. font-weight: 500;
  572. font-size: 13px;
  573. color: #000000;
  574. }
  575. .module-line {
  576. flex: 1;
  577. margin-left: 13px;
  578. margin-right: 5px;
  579. border-bottom: 1px dashed #BCBCBC;
  580. }
  581. .module-salary {
  582. margin-right: 23px;
  583. line-height: 32px;
  584. font-size: 12px;
  585. color: #666666;
  586. }
  587. }
  588. .mobile {
  589. .title-wrapper {
  590. overflow: hidden;
  591. width: 100%;
  592. height: 2.38rem;
  593. background-color: #ffffff;
  594. }
  595. .title {
  596. margin-top: .54rem;
  597. margin-left: .3rem;
  598. line-height: .56rem;
  599. font-weight: 600;
  600. font-size: .4rem;
  601. color: #333333;
  602. }
  603. .subtitle {
  604. margin-top: .1rem;
  605. margin-left: .3rem;
  606. width: 7.04rem;
  607. line-height: .34rem;
  608. font-size: .24rem;
  609. color: #999999;
  610. }
  611. .module-wrapper {
  612. overflow: hidden;
  613. margin-top: .12rem;
  614. width: 100%;
  615. background-color: #ffffff;
  616. }
  617. .module-title {
  618. margin-top: .38rem;
  619. margin-left: .36rem;
  620. line-height: .44rem;
  621. font-weight: 600;
  622. font-size: .32rem;
  623. color: #000000;
  624. }
  625. .range-chart, .industry-chart, .experience-chart, .education-chart, .city-chart {
  626. margin-top: .38rem;
  627. margin-left: -.4rem;
  628. }
  629. .average-title {
  630. margin-top: .38rem;
  631. margin-left: .36rem;
  632. line-height: .44rem;
  633. font-weight: 600;
  634. font-size: .32rem;
  635. color: #000000;
  636. }
  637. .average-subtitle {
  638. margin: .28rem auto 0;
  639. width: 6.76rem;
  640. line-height: .36rem;
  641. font-size: .24rem;
  642. color: #666666;
  643. }
  644. .average-img {
  645. margin: .94rem auto 0;
  646. display: block;
  647. width: 4.7rem;
  648. height: 2.7rem;
  649. }
  650. .module-list {
  651. margin-top: .34rem;
  652. margin-bottom: .4rem;
  653. }
  654. .module-item {
  655. display: flex;
  656. align-items: center;
  657. }
  658. .module-label {
  659. margin-left: .36rem;
  660. line-height: .64rem;
  661. font-weight: 500;
  662. font-size: .26rem;
  663. color: #000000;
  664. }
  665. .module-line {
  666. flex: 1;
  667. margin-left: .2rem;
  668. margin-right: .1rem;
  669. width: 4.44rem;
  670. border-bottom: .02rem dashed #BCBCBC;
  671. }
  672. .module-salary {
  673. margin-right: .3rem;
  674. line-height: .64rem;
  675. font-size: .24rem;
  676. color: #666666;
  677. }
  678. }
  679. </style>