index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <div>
  3. <div class="wrapper pc" v-if="screenWidth > 960">
  4. <div class="header">
  5. <div class="bgImage">
  6. <img src="@/assets/img/salary/background.png" alt="">
  7. </div>
  8. <div class="topContent">
  9. <h1 class="title">查岗位薪资 就上程序员客栈</h1>
  10. <div class="search-wrapper">
  11. <el-select class="salary-job-search" style="margin-right:5px;width:500px;" @change="changeJob" v-model="searchJob" placeholder="请选择">
  12. <el-option
  13. v-for="item in jobList"
  14. :key="item.job"
  15. :label="item.job"
  16. :value="item.job_slug"
  17. ></el-option>
  18. </el-select>
  19. <el-select class="salary-city-search" style="margin-right:5px;width:100px;" v-model="searchCity" placeholder="请选择">
  20. <el-option
  21. v-for="item in cityList"
  22. :key="item.city"
  23. :label="item.city"
  24. :value="item.city_slug"
  25. ></el-option>
  26. </el-select>
  27. <div class="search-btn" @click="search" type="primary">查询</div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="content">
  32. <div
  33. class="info"
  34. >截至2019年9月6日,调查了全国的开发者的工资数据后发现,{{city}}开发者平均工资最高达¥{{citySalary}}元/月,{{job}}开发者的平均工资最高达{{jobSalary}}元/月,本数据仅供参考。</div>
  35. <div class="module-wrapper">
  36. <div class="module-title">开发者薪资排行城市TOP10</div>
  37. <div id="city-chart" class="city-chart"></div>
  38. </div>
  39. <div class="module-wrapper">
  40. <div class="module-title">开发者薪资岗位TOP10</div>
  41. <div id="job-chart" class="job-chart"></div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="wrapper mobile" v-else>
  46. <div class="header">
  47. <h1 class="title">
  48. 查岗位薪资
  49. <br />就上程序员客栈
  50. </h1>
  51. <div class="search-wrapper">
  52. <el-select class="salary-job-search" style="margin-right:.1rem;width:3.75rem;" @change="changeJob" v-model="searchJob" placeholder="请选择">
  53. <el-option
  54. v-for="item in jobList"
  55. :key="item.job"
  56. :label="item.job"
  57. :value="item.job_slug"
  58. ></el-option>
  59. </el-select>
  60. <el-select class="salary-city-search" style="margin-right:.1rem;width:2rem;" v-model="searchCity" placeholder="请选择">
  61. <el-option
  62. v-for="item in cityList"
  63. :key="item.city"
  64. :label="item.city"
  65. :value="item.city_slug"
  66. ></el-option>
  67. </el-select>
  68. <div class="search-btn" @click="search" type="primary">查询</div>
  69. <!-- <div class="search-content">-->
  70. <!-- <input type="text" @keyup.enter="search" v-model="searchJob" placeholder="岗位名称,如c++软件工程师" class="search-input">-->
  71. <!-- <el-dropdown>-->
  72. <!-- <div class="search-city">-->
  73. <!-- <span>{{searchCity}}</span>-->
  74. <!-- <img src="@/assets/img/salary/icon_arrow_down.png" alt="">-->
  75. <!-- </div>-->
  76. <!-- <el-dropdown-menu slot="dropdown">-->
  77. <!-- <el-dropdown-item v-for="citys in cityList" :command="citys.city">{{citys.city}}</el-dropdown-item>-->
  78. <!-- </el-dropdown-menu>-->
  79. <!-- </el-dropdown>-->
  80. <!-- </div>-->
  81. <!-- <div @click="search" class="search-btn">查询</div>-->
  82. </div>
  83. <!-- <div class="hot-search">热门搜索:<span style="display: inline-block;cursor: pointer;" v-for="jobType in jobList"><div @click="inVal(jobType.job)" >{{jobType.job}}</div></span></div>-->
  84. </div>
  85. <div class="content">
  86. <div
  87. class="info"
  88. >截至2019年9月6日,调查了全国的开发者的工资数据后发现,{{city}}开发者平均工资最高达¥{{citySalary}}元/月,{{job}}开发者的平均工资最高达{{jobSalary}}元/月,本数据仅供参考。</div>
  89. <div class="module-wrapper">
  90. <div class="module-title">开发者薪资排行城市TOP10</div>
  91. <div id="city-chart" class="city-chart"></div>
  92. </div>
  93. <div class="module-wrapper">
  94. <div class="module-title">开发者薪资岗位TOP10</div>
  95. <div id="job-chart" class="job-chart"></div>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. export default {
  103. layout: "opacity_header",
  104. head() {
  105. return {
  106. title: "程序员月薪工资待遇查询,企业招聘程序员费用查询-程序员客栈",
  107. meta: [
  108. {
  109. name: "keywords",
  110. content: "程序员工资,程序员月薪,程序员待遇,企业招聘程序员费用"
  111. },
  112. {
  113. name: "descrption",
  114. content:
  115. "程序员客栈提供全国每个城市程序员岗位工资查询,帮助每一位程序员找到合适的工作,让每一个有程序员招聘需求的企业利用合适的费用找到合适的人才。"
  116. }
  117. ]
  118. };
  119. },
  120. data() {
  121. return {
  122. screenWidth: 0,
  123. cityChart: [],
  124. jobChart: [],
  125. jobList: [],
  126. city: "",
  127. citySalary: 0,
  128. cityList: [],
  129. job: "",
  130. jobSalary: 0,
  131. cityTick: 0,
  132. jobTick: 0,
  133. searchJob: "",
  134. searchCity: ""
  135. };
  136. },
  137. async asyncData ({ $axios, req, res }) {
  138. // 请检查您是否在服务器端
  139. // 使用 req 和 res
  140. console.log(req)
  141. if (process.server) {
  142. let res = await $axios.$post("/api/salary/index_info");
  143. const cityChart = res.data.sortOfCity;
  144. const jobChart = res.data.sortOfJob;
  145. const jobList = res.data.allJobType;
  146. const city = res.data.sortOfCity[0].city;
  147. const citySalary = res.data.sortOfCity[0].salary;
  148. const job = res.data.sortOfJob[0].job;
  149. const jobSalary = res.data.sortOfJob[0].salary;
  150. const cityTick = res.data.cityTick;
  151. const jobTick = res.data.jobTick;
  152. const cityList = res.data.cityList;
  153. const searchJob = res.data.allJobType[0].job_slug;
  154. const searchCity = res.data.cityList[0].city_slug;
  155. for (let i = 0; i < cityChart.length; i++) {
  156. cityChart[i].salary = parseInt(cityChart[i].salary);
  157. }
  158. for (let i = 0; i < jobChart.length; i++) {
  159. jobChart[i].salary = parseInt(jobChart[i].salary);
  160. }
  161. return {
  162. cityChart,
  163. jobChart,
  164. jobList,
  165. city,
  166. citySalary,
  167. cityList,
  168. job,
  169. jobSalary,
  170. cityTick,
  171. jobTick,
  172. searchJob,
  173. searchCity
  174. }
  175. }
  176. return {}
  177. },
  178. mounted() {
  179. this.screenWidth = window.screen.width;
  180. this.$nextTick(() => {
  181. this.getData();
  182. });
  183. },
  184. methods: {
  185. async getData() {
  186. // let res = await this.$axios.$post("/api/salary/index_info");
  187. // this.cityChart = res.data.sortOfCity;
  188. // this.jobChart = res.data.sortOfJob;
  189. // this.jobList = res.data.allJobType;
  190. // this.city = res.data.sortOfCity[0].city;
  191. // this.citySalary = res.data.sortOfCity[0].salary;
  192. // this.job = res.data.sortOfJob[0].job;
  193. // this.jobSalary = res.data.sortOfJob[0].salary;
  194. // this.cityTick = res.data.cityTick;
  195. // this.jobTick = res.data.jobTick;
  196. // this.cityList = res.data.cityList;
  197. // this.searchJob = res.data.allJobType[0].job_slug;
  198. // this.searchCity = res.data.cityList[0].city_slug;
  199. // console.log(this.cityList);
  200. // for (let i = 0; i < this.cityChart.length; i++) {
  201. // this.cityChart[i].salary = parseInt(this.cityChart[i].salary);
  202. // }
  203. // for (let i = 0; i < this.jobChart.length; i++) {
  204. // this.jobChart[i].salary = parseInt(this.jobChart[i].salary);
  205. // }
  206. //开发者薪资排行城市TOP10
  207. const chart1 = new G2.Chart({
  208. container: "city-chart",
  209. forceFit: true,
  210. height: 400
  211. });
  212. chart1.source(this.cityChart);
  213. chart1.scale("salary", {
  214. tickInterval: this.cityTick
  215. });
  216. chart1.interval().position("city*salary");
  217. chart1.render();
  218. //开发者薪资岗位TOP10
  219. const chart2 = new G2.Chart({
  220. container: "job-chart",
  221. forceFit: true,
  222. height: 400
  223. });
  224. chart2.source(this.jobChart);
  225. chart2.scale("salary", {
  226. tickInterval: this.jobTick
  227. });
  228. chart2.interval().position("job*salary");
  229. chart2.render();
  230. },
  231. async changeJob() {
  232. let data = { job: this.searchJob };
  233. let res = await this.$axios.$post("/api/salary/search_city", data);
  234. this.cityList = res.data.cityList;
  235. },
  236. handleCommandJob(command) {
  237. this.searchJob = command;
  238. },
  239. handleCommand(command) {
  240. this.searchCity = command;
  241. },
  242. search() {
  243. if (this.searchJob.length === 0) {
  244. this.$message("请输入查询岗位名称");
  245. return false;
  246. }
  247. // this.searchJob = this.searchJob.replace(/c#/, "c%23");
  248. // this.searchJob = this.searchJob.replace(/c\+\+*/, "c%24");
  249. // this.$router.push(
  250. // "/salary/detail?job=" + this.searchJob + "&city=" + this.searchCity
  251. // );
  252. window.location.href = `/salary/${this.searchCity}-${this.searchJob}/`.replace('c#', 'c%23');
  253. },
  254. inVal(val) {
  255. this.searchJob = val;
  256. }
  257. }
  258. };
  259. </script>
  260. <style lang="scss" scoped>
  261. .wrapper {
  262. overflow: hidden;
  263. }
  264. .main {
  265. margin: 0;
  266. width: 100%;
  267. }
  268. .pc {
  269. position: relative;
  270. margin: -85px 0 0;
  271. width: 100%;
  272. .header {
  273. position: relative;
  274. overflow: hidden;
  275. width: 100%;
  276. min-height: 200px;
  277. .bgImage {
  278. img {
  279. width: 100%;
  280. vertical-align: middle;
  281. }
  282. }
  283. .topContent {
  284. position: absolute;
  285. top: 85px;
  286. display: flex;
  287. justify-content: space-around;
  288. align-items: center;
  289. flex-direction: column;
  290. width: 1000px;
  291. left: 50%;
  292. transform: translateX(-50%);
  293. height: calc(100% - 85px);
  294. .title {
  295. line-height: 53px;
  296. text-align: center;
  297. font-weight: 600;
  298. font-size: 38px;
  299. color: #ffffff;
  300. }
  301. .search-wrapper {
  302. margin: 50px;
  303. display: flex;
  304. align-items: center;
  305. justify-content: center;
  306. }
  307. .search-content {
  308. /*width: 578px;*/
  309. height: 43px;
  310. border-radius: 4px 0px 0px 4px;
  311. background-color: #ffffff;
  312. display: flex;
  313. align-items: center;
  314. }
  315. .search-input {
  316. flex: 1;
  317. padding-left: 14px;
  318. padding-right: 14px;
  319. font-size: 16px;
  320. color: #999999;
  321. }
  322. .search-city {
  323. margin-right: 18px;
  324. display: flex;
  325. align-items: center;
  326. }
  327. .search-city span {
  328. line-height: 14px;
  329. font-weight: 600;
  330. font-size: 16px;
  331. color: #919aa7;
  332. }
  333. .search-city img {
  334. margin-left: 4px;
  335. width: 11px;
  336. height: 7px;
  337. }
  338. .search-btn {
  339. width: 104px;
  340. height: 53px;
  341. border-radius: 4px;
  342. background-color: #147eff;
  343. line-height: 53px;
  344. text-align: center;
  345. font-weight: 600;
  346. font-size: 20px;
  347. color: #ffffff;
  348. cursor: pointer;
  349. }
  350. }
  351. }
  352. .hot-search {
  353. margin: 15px auto 0;
  354. width: 700px;
  355. line-height: 20px;
  356. font-weight: 500;
  357. font-size: 14px;
  358. color: #ffffff;
  359. }
  360. .hot-search span {
  361. margin-right: 20px;
  362. }
  363. .content {
  364. overflow: hidden;
  365. margin-top: 20px;
  366. margin-bottom: 20px;
  367. background-color: #ffffff;
  368. }
  369. .info {
  370. margin: 40px auto 0;
  371. width: 807px;
  372. line-height: 26px;
  373. font-size: 15px;
  374. color: #666666;
  375. }
  376. .module-wrapper {
  377. margin: 50px auto 0;
  378. width: 1000px;
  379. }
  380. .module-title {
  381. margin-left: 47px;
  382. line-height: 25px;
  383. font-weight: 600;
  384. font-size: 18px;
  385. color: #000000;
  386. }
  387. .city-chart,
  388. .job-chart {
  389. margin: 50px auto 0;
  390. width: 950px;
  391. }
  392. }
  393. .el-scrollbar__wrap {
  394. overflow-x: hidden;
  395. }
  396. .mobile {
  397. .header {
  398. overflow: hidden;
  399. width: 100%;
  400. height: 6.5rem;
  401. background-image: url("~@/assets/img/salary/background.png");
  402. background-size: auto 6.5rem;
  403. background-repeat: no-repeat;
  404. background-position: top center;
  405. }
  406. .title {
  407. margin-top: 1.16rem;
  408. line-height: 0.92rem;
  409. text-align: center;
  410. font-weight: 600;
  411. font-size: 0.66rem;
  412. color: #ffffff;
  413. }
  414. .search-wrapper {
  415. margin: 0.66rem 0.2rem 0rem 0.2rem;
  416. display: flex;
  417. align-items: center;
  418. justify-content: center;
  419. }
  420. .search-content {
  421. width: 5.3rem;
  422. height: 0.85rem;
  423. border-radius: 0.06rem 0 0 0.06rem;
  424. background-color: #ffffff;
  425. display: flex;
  426. align-items: center;
  427. }
  428. .search-input {
  429. flex: 1;
  430. padding-left: 0.22rem;
  431. padding-right: 0.22rem;
  432. font-size: 0.26rem;
  433. color: #999999;
  434. }
  435. .search-city {
  436. margin-right: 0.32rem;
  437. display: flex;
  438. align-items: center;
  439. }
  440. .search-city span {
  441. font-weight: 600;
  442. font-size: 0.26rem;
  443. color: #919aa7;
  444. }
  445. .search-city img {
  446. margin-left: 0.06rem;
  447. width: 0.2rem;
  448. height: 0.12rem;
  449. }
  450. .search-btn {
  451. width: 1.66rem;
  452. height: 0.85rem;
  453. border-radius: 0.06rem 0 0 0.06rem;
  454. background-color: #147eff;
  455. line-height: 0.85rem;
  456. text-align: center;
  457. font-weight: 600;
  458. font-size: 0.32rem;
  459. color: #ffffff;
  460. }
  461. .hot-search {
  462. margin-top: 0.22rem;
  463. margin-left: 0.26rem;
  464. line-height: 0.34rem;
  465. font-weight: 500;
  466. font-size: 0.24rem;
  467. color: #ffffff;
  468. }
  469. .hot-search span {
  470. margin-right: 0.2rem;
  471. }
  472. .content {
  473. overflow: hidden;
  474. }
  475. .info {
  476. margin-bottom: 0.12rem;
  477. padding: 0.5rem 0.28rem 0.48rem;
  478. background-color: #ffffff;
  479. line-height: 0.44rem;
  480. font-size: 0.26rem;
  481. color: #666666;
  482. }
  483. .module-wrapper {
  484. overflow: hidden;
  485. background-color: #ffffff;
  486. }
  487. .module-title {
  488. margin-top: 0.44rem;
  489. margin-left: 0.36rem;
  490. line-height: 0.44rem;
  491. font-weight: 600;
  492. font-size: 0.32rem;
  493. color: #000000;
  494. }
  495. .city-chart,
  496. .job-chart {
  497. margin-top: 0.48rem;
  498. margin-left: -0.24rem;
  499. width: 100%;
  500. }
  501. .dropdown {
  502. //设置高度才能显示出滚动条 !important
  503. height: 300px;
  504. overflow: auto;
  505. }
  506. .dropdown::-webkit-scrollbar {
  507. width: 5px;
  508. height: 5px;
  509. background-color: #f5f5f5;
  510. }
  511. .dropdown::-webkit-scrollbar-track {
  512. //-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  513. border-radius: 10px;
  514. background-color: #f5f5f5;
  515. }
  516. }
  517. </style>
  518. <style>
  519. .pc .salary-job-search .el-input__inner {
  520. height: 53px;
  521. }
  522. .pc .salary-city-search .el-input__inner {
  523. height: 53px;
  524. }
  525. .mobile .salary-job-search .el-input__inner {
  526. height: .85rem;
  527. }
  528. .mobile .salary-city-search .el-input__inner {
  529. height: .85rem;
  530. }
  531. </style>