index.vue 16 KB

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