_id.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <div>
  3. <div class="wrapper pc" v-if="screenWidth > 960">
  4. <h1 class="title">{{city}}-{{job}}收入水平</h1>
  5. <div class="subtitle">{{city}}{{job}}平均工资:¥{{avg_salary}}/月,统计来自程序员客栈(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
  14. class="average-subtitle"
  15. >最高为{{max_salary}}元/月,最低为{{min_salary}}元/月,其中,平均工资为{{avg_salary}}元/月</div>
  16. <img class="average-img" src="@/assets/img/salary/average_salary.png" alt />
  17. </div>
  18. <!-- <div class="module-wrapper">-->
  19. <!-- <div class="module-title">杭州其他岗位平均工资</div>-->
  20. <!-- <div id="industry-chart" class="industry-chart"></div>-->
  21. <!-- </div>-->
  22. <!-- <div class="module-wrapper">-->
  23. <!-- <div class="module-title">按工作经验统计</div>-->
  24. <!-- <div id="experience-chart" class="experience-chart"></div>-->
  25. <!-- </div>-->
  26. <!-- <div class="module-wrapper">-->
  27. <!-- <div class="module-title">按学历统计</div>-->
  28. <!-- <div id="education-chart" class="education-chart"></div>-->
  29. <!-- </div>-->
  30. <!-- <div class="module-wrapper">-->
  31. <!-- <div class="module-title">按各城市岗位需求统计</div>-->
  32. <!-- <div id="city-chart" class="city-chart"></div>-->
  33. <!-- </div>-->
  34. <div class="module-wrapper">
  35. <div class="module-title">全国城市{{job}}平均工资</div>
  36. <div class="module-list">
  37. <div class="module-item" v-for="citys in allCitySalary">
  38. <div class="module-label">{{citys.city}}</div>
  39. <div class="module-line"></div>
  40. <div class="module-salary">¥{{citys.salary}}元/月</div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="module-wrapper">
  45. <div class="module-title">{{city}}其他岗位平均工资</div>
  46. <div class="module-list">
  47. <div class="module-item" v-for="jobs in jobList">
  48. <div class="module-label">{{jobs.job}}</div>
  49. <div class="module-line"></div>
  50. <div class="module-salary">¥{{jobs.salary}}元/月</div>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="wrapper mobile" v-else>
  57. <div class="title-wrapper">
  58. <h1 class="title">{{city}}-{{job}}收入水平</h1>
  59. <div class="subtitle">{{city}}{{job}}平均工资:¥{{avg_salary}}/月,统计来自程序员客栈(proginn.com)</div>
  60. </div>
  61. <div class="module-wrapper">
  62. <div class="module-title">开发者薪资排行城市TOP10</div>
  63. <div id="range-chart" class="range-chart"></div>
  64. </div>
  65. <div class="module-wrapper">
  66. <div class="average-title">平均工资:¥{{avg_salary}}元/月</div>
  67. <div class="average-subtitle">最高为{{max_salary}}元/月,最低为{{min_salary}}元/月,其中,人工智能行业的产品经理平均工资最高达{{avg_salary}}元/月</div>
  68. <img class="average-img" src="@/assets/img/salary/average_salary.png" alt />
  69. </div>
  70. <!-- <div class="module-wrapper">-->
  71. <!-- <div class="module-title">杭州其他岗位平均工资</div>-->
  72. <!-- <div id="industry-chart" class="industry-chart"></div>-->
  73. <!-- </div>-->
  74. <!-- <div class="module-wrapper">-->
  75. <!-- <div class="module-title">按工作经验统计</div>-->
  76. <!-- <div id="experience-chart" class="experience-chart"></div>-->
  77. <!-- </div>-->
  78. <!-- <div class="module-wrapper">-->
  79. <!-- <div class="module-title">按学历统计</div>-->
  80. <!-- <div id="education-chart" class="education-chart"></div>-->
  81. <!-- </div>-->
  82. <!-- <div class="module-wrapper">-->
  83. <!-- <div class="module-title">按各城市岗位需求统计</div>-->
  84. <!-- <div id="city-chart" class="city-chart"></div>-->
  85. <!-- </div>-->
  86. <div class="module-wrapper">
  87. <div class="module-title">全国城市{{job}}平均工资</div>
  88. <div class="module-list">
  89. <div class="module-item" v-for="citys in allCitySalary">
  90. <div class="module-label">{{citys.city}}</div>
  91. <div class="module-line"></div>
  92. <div class="module-salary">¥{{citys.salary}}元/月</div>
  93. </div>
  94. </div>
  95. </div>
  96. <div class="module-wrapper">
  97. <div class="module-title">{{city}}其他岗位平均工资</div>
  98. <div class="module-list">
  99. <div class="module-item" v-for="jobs in jobList">
  100. <div class="module-label">{{jobs.job}}</div>
  101. <div class="module-line"></div>
  102. <div class="module-salary">¥{{jobs.salary}}元/月</div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </template>
  109. <script>
  110. export default {
  111. head() {
  112. return {
  113. title: `${this.city}${this.job}月薪工资待遇查询,${this.city}企业招聘${this.job}费用查询-程序员客栈`,
  114. meta: [
  115. {
  116. name: "keywords",
  117. content: `${this.city}${this.job}工资,${this.city}${this.job}兼职工资,${this.city}企业${this.job}招聘费用`
  118. },
  119. {
  120. name: "description",
  121. content: `程序员客栈提供${this.city}${this.job}工资查询,让${this.city}${this.job}程序员能了解自身兼职价值,帮助${this.city}有${this.job}招聘需求的企业利用合理的费用找到合适的人才!`
  122. }
  123. ]
  124. };
  125. },
  126. data() {
  127. return {
  128. screenWidth: 0,
  129. job: "",
  130. city: "",
  131. avg_salary: 0,
  132. max_salary: 0,
  133. min_salary: 0,
  134. jobList: [],
  135. experience: [],
  136. allCitySalary: [],
  137. salaryRange: []
  138. };
  139. },
  140. async asyncData ({ $axios, req, res }) {
  141. // 请检查您是否在服务器端
  142. // 使用 req 和 res
  143. console.log(req)
  144. if (process.server) {
  145. const path = req.url
  146. const cityJob = path.split('/')[2]
  147. const city = cityJob.split('-')[0]
  148. const job = cityJob.split('-')[1].replace('c%23', 'c#')
  149. let params = {
  150. job: job,
  151. city: city
  152. };
  153. let res = await $axios.$post("/api/salary/search_info", params);
  154. const jobList = res.data.jobSort || [];
  155. const experience = res.data.experience || [];
  156. for (let i = 0; i < jobList.length; i++) {
  157. jobList[i].salary = parseInt(jobList[i].salary);
  158. }
  159. for (let i = 0; i < experience.length; i++) {
  160. experience[i].salary = parseInt(experience[i].salary);
  161. }
  162. return {
  163. job: res.data.info.job || '',
  164. city: res.data.info.city || '',
  165. avg_salary: res.data.info.avg_salary,
  166. max_salary: res.data.info.max_salary,
  167. min_salary: res.data.info.min_salary,
  168. jobList: jobList,
  169. experience: experience,
  170. allCitySalary: res.data.allCitySalary || [],
  171. salaryRange: res.data.salaryRange || [],
  172. }
  173. }
  174. return {}
  175. },
  176. mounted() {
  177. this.screenWidth = window.screen.width;
  178. this.$nextTick(() => {
  179. this.getData();
  180. // this.getRangeChart();
  181. // this.getIndustryChart();
  182. // this.getExperienceChart();
  183. // this.getEducationChart()
  184. // this.getCityChart()
  185. });
  186. },
  187. methods: {
  188. async getData() {
  189. // const path = window.location.pathname
  190. // const cityJob = path.split('/')[2]
  191. // this.city = cityJob.split('-')[0]
  192. // this.job = cityJob.split('-')[1]
  193. // let params = {
  194. // job: this.job,
  195. // city: this.city
  196. // };
  197. // let res = await this.$axios.$post("/api/salary/search_info", params);
  198. // this.job = res.data.info.job;
  199. // this.city = res.data.info.city;
  200. // this.avg_salary = res.data.info.avg_salary;
  201. // this.max_salary = res.data.info.max_salary;
  202. // this.min_salary = res.data.info.min_salary;
  203. // this.jobList = res.data.jobSort || [];
  204. // this.experience = res.data.experience || [];
  205. // this.allCitySalary = res.data.allCitySalary || [];
  206. // this.salaryRange = res.data.salaryRange || [];
  207. // for (let i = 0; i < this.jobList.length; i++) {
  208. // this.jobList[i].salary = parseInt(this.jobList[i].salary);
  209. // }
  210. // for (let i = 0; i < this.experience.length; i++) {
  211. // this.experience[i].salary = parseInt(this.experience[i].salary);
  212. // }
  213. const sortJob = this.jobList;
  214. const sortExperience = this.experience;
  215. const allSalaryRange = this.salaryRange;
  216. const chart = new G2.Chart({
  217. container: "range-chart",
  218. forceFit: true,
  219. height: 300
  220. });
  221. chart.source(allSalaryRange, {
  222. percent: {
  223. formatter: function formatter(val) {
  224. val = val * 100 + "%";
  225. return val;
  226. }
  227. }
  228. });
  229. chart.coord("theta", {
  230. radius: 0.75
  231. });
  232. chart.tooltip({
  233. showTitle: false,
  234. itemTpl:
  235. '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
  236. });
  237. chart
  238. .intervalStack()
  239. .position("percent")
  240. .color("item")
  241. .label("percent", {
  242. formatter: function formatter(val, item) {
  243. return item.point.item + ": " + val;
  244. }
  245. })
  246. .tooltip("item*percent", function(item, percent) {
  247. percent = percent * 100 + "%";
  248. return {
  249. name: item,
  250. value: percent
  251. };
  252. })
  253. .style({
  254. lineWidth: 1,
  255. stroke: "#fff"
  256. });
  257. chart.render();
  258. // const chart1 = new G2.Chart({
  259. // container: "industry-chart",
  260. // forceFit: true,
  261. // height: 300
  262. // });
  263. // chart1.source(sortJob);
  264. // chart1.scale("salary", {
  265. // min: 0
  266. // });
  267. // chart1.scale("job", {
  268. // range: [0, 1]
  269. // });
  270. // chart1.tooltip({
  271. // crosshairs: {
  272. // type: "line"
  273. // }
  274. // });
  275. // chart1.line().position("job*salary");
  276. // chart1
  277. // .point()
  278. // .position("job*salary")
  279. // .size(4)
  280. // .shape("circle")
  281. // .style({
  282. // stroke: "#fff",
  283. // lineWidth: 1
  284. // });
  285. // chart1.render();
  286. // const chart2 = new G2.Chart({
  287. // container: "experience-chart",
  288. // forceFit: true,
  289. // height: 300
  290. // });
  291. // chart2.source(sortExperience);
  292. // chart2.scale("salary", {
  293. // min: 0
  294. // });
  295. // chart2.scale("experience", {
  296. // range: [0, 1]
  297. // });
  298. // chart2.tooltip({
  299. // crosshairs: {
  300. // type: "line"
  301. // }
  302. // });
  303. // chart2.line().position("experience*salary");
  304. // chart2
  305. // .point()
  306. // .position("experience*salary")
  307. // .size(4)
  308. // .shape("circle")
  309. // .style({
  310. // stroke: "#fff",
  311. // lineWidth: 1
  312. // });
  313. // chart2.render();
  314. }
  315. }
  316. };
  317. </script>
  318. <style lang="scss" scoped>
  319. .wrapper {
  320. overflow: hidden;
  321. }
  322. .main {
  323. margin: 0;
  324. width: 100%;
  325. }
  326. .pc {
  327. margin: 10px auto;
  328. padding-bottom: 36px;
  329. width: 1000px;
  330. background-color: #ffffff;
  331. .title {
  332. margin-top: 30px;
  333. margin-left: 18px;
  334. line-height: 28px;
  335. font-weight: 600;
  336. font-size: 20px;
  337. color: #333333;
  338. }
  339. .subtitle {
  340. margin-top: 7px;
  341. margin-left: 18px;
  342. line-height: 17px;
  343. font-size: 12px;
  344. color: #999999;
  345. }
  346. .content {
  347. margin-top: 51px;
  348. display: flex;
  349. justify-content: center;
  350. flex-wrap: wrap;
  351. }
  352. .module-wrapper {
  353. overflow: hidden;
  354. width: 480px;
  355. min-height: 366px;
  356. border: 1px solid #ebebeb;
  357. }
  358. .module-title {
  359. margin-top: 22px;
  360. margin-left: 31px;
  361. line-height: 25px;
  362. font-weight: 600;
  363. font-size: 18px;
  364. color: #000000;
  365. }
  366. .range-chart,
  367. .industry-chart,
  368. .experience-chart,
  369. .education-chart,
  370. .city-chart {
  371. margin-top: 38px;
  372. margin-left: -20px;
  373. }
  374. .average-title {
  375. margin-top: 51px;
  376. line-height: 28px;
  377. text-align: center;
  378. font-weight: 600;
  379. font-size: 20px;
  380. color: #000000;
  381. }
  382. .average-subtitle {
  383. margin: 9px auto 0;
  384. width: 422px;
  385. line-height: 18px;
  386. font-size: 13px;
  387. color: #666666;
  388. }
  389. .average-img {
  390. margin: 50px auto 0;
  391. display: block;
  392. width: 235px;
  393. height: 135px;
  394. }
  395. .module-list {
  396. margin-top: 24px;
  397. margin-bottom: 10px;
  398. }
  399. .module-item {
  400. display: flex;
  401. align-items: center;
  402. }
  403. .module-label {
  404. margin-left: 25px;
  405. line-height: 32px;
  406. font-weight: 500;
  407. font-size: 13px;
  408. color: #000000;
  409. }
  410. .module-line {
  411. flex: 1;
  412. margin-left: 13px;
  413. margin-right: 5px;
  414. border-bottom: 1px dashed #bcbcbc;
  415. }
  416. .module-salary {
  417. margin-right: 23px;
  418. line-height: 32px;
  419. font-size: 12px;
  420. color: #666666;
  421. }
  422. }
  423. .mobile {
  424. .title-wrapper {
  425. overflow: hidden;
  426. width: 100%;
  427. height: 2.38rem;
  428. background-color: #ffffff;
  429. }
  430. .title {
  431. margin-top: 0.54rem;
  432. margin-left: 0.3rem;
  433. line-height: 0.56rem;
  434. font-weight: 600;
  435. font-size: 0.4rem;
  436. color: #333333;
  437. }
  438. .subtitle {
  439. margin-top: 0.1rem;
  440. margin-left: 0.3rem;
  441. width: 7.04rem;
  442. line-height: 0.34rem;
  443. font-size: 0.24rem;
  444. color: #999999;
  445. }
  446. .module-wrapper {
  447. overflow: hidden;
  448. margin-top: 0.12rem;
  449. width: 100%;
  450. background-color: #ffffff;
  451. }
  452. .module-title {
  453. margin-top: 0.38rem;
  454. margin-left: 0.36rem;
  455. line-height: 0.44rem;
  456. font-weight: 600;
  457. font-size: 0.32rem;
  458. color: #000000;
  459. }
  460. .range-chart,
  461. .industry-chart,
  462. .experience-chart,
  463. .education-chart,
  464. .city-chart {
  465. margin-top: 0.38rem;
  466. margin-left: -0.4rem;
  467. }
  468. .average-title {
  469. margin-top: 0.38rem;
  470. margin-left: 0.36rem;
  471. line-height: 0.44rem;
  472. font-weight: 600;
  473. font-size: 0.32rem;
  474. color: #000000;
  475. }
  476. .average-subtitle {
  477. margin: 0.28rem auto 0;
  478. width: 6.76rem;
  479. line-height: 0.36rem;
  480. font-size: 0.24rem;
  481. color: #666666;
  482. }
  483. .average-img {
  484. margin: 0.94rem auto 0;
  485. display: block;
  486. width: 4.7rem;
  487. height: 2.7rem;
  488. }
  489. .module-list {
  490. margin-top: 0.34rem;
  491. margin-bottom: 0.4rem;
  492. }
  493. .module-item {
  494. display: flex;
  495. align-items: center;
  496. }
  497. .module-label {
  498. margin-left: 0.36rem;
  499. line-height: 0.64rem;
  500. font-weight: 500;
  501. font-size: 0.26rem;
  502. color: #000000;
  503. }
  504. .module-line {
  505. flex: 1;
  506. margin-left: 0.2rem;
  507. margin-right: 0.1rem;
  508. width: 4.44rem;
  509. border-bottom: 0.02rem dashed #bcbcbc;
  510. }
  511. .module-salary {
  512. margin-right: 0.3rem;
  513. line-height: 0.64rem;
  514. font-size: 0.24rem;
  515. color: #666666;
  516. }
  517. }
  518. </style>