index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <div>
  3. <div class="wrapper pc" v-if="!mobile">
  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: "description",
  114. content: "程序员客栈提供全国每个城市程序员岗位工资查询,帮助每一位程序员找到合适的工作,让每一个有程序员招聘需求的企业利用合适的费用找到合适的人才。"
  115. }
  116. ]
  117. };
  118. },
  119. data() {
  120. return {
  121. cityChart: [],
  122. jobChart: [],
  123. jobList: [],
  124. city: "",
  125. citySalary: 0,
  126. cityList: [],
  127. job: "",
  128. jobSalary: 0,
  129. cityTick: 0,
  130. jobTick: 0,
  131. searchJob: "",
  132. searchCity: ""
  133. };
  134. },
  135. async asyncData ({ $axios, req, res, app }) {
  136. // 请检查您是否在服务器端
  137. // 使用 req 和 res
  138. console.log(req)
  139. if (process.server) {
  140. let res = await $axios.$post("/api/salary/index_info");
  141. const cityChart = res.data.sortOfCity;
  142. const jobChart = res.data.sortOfJob;
  143. const jobList = res.data.allJobType;
  144. const city = res.data.sortOfCity[0].city;
  145. const citySalary = res.data.sortOfCity[0].salary;
  146. const job = res.data.sortOfJob[0].job;
  147. const jobSalary = res.data.sortOfJob[0].salary;
  148. const cityTick = res.data.cityTick;
  149. const jobTick = res.data.jobTick;
  150. const cityList = res.data.cityList;
  151. const searchJob = res.data.allJobType[0].job_slug;
  152. const searchCity = res.data.cityList[0].city_slug;
  153. for (let i = 0; i < cityChart.length; i++) {
  154. cityChart[i].salary = parseInt(cityChart[i].salary);
  155. }
  156. for (let i = 0; i < jobChart.length; i++) {
  157. jobChart[i].salary = parseInt(jobChart[i].salary);
  158. }
  159. return {
  160. cityChart,
  161. jobChart,
  162. jobList,
  163. city,
  164. citySalary,
  165. cityList,
  166. job,
  167. jobSalary,
  168. cityTick,
  169. jobTick,
  170. searchJob,
  171. searchCity,
  172. mobile: app.$deviceType.isMobile(),
  173. }
  174. }
  175. return {
  176. mobile: app.$deviceType.isMobile()
  177. }
  178. },
  179. mounted() {
  180. this.$nextTick(() => {
  181. this.getData();
  182. });
  183. },
  184. methods: {
  185. async getData() {
  186. //开发者薪资排行城市TOP10
  187. const chart1 = new G2.Chart({
  188. container: "city-chart",
  189. forceFit: true,
  190. height: 400
  191. });
  192. chart1.source(this.cityChart);
  193. chart1.scale("salary", {
  194. tickInterval: this.cityTick
  195. });
  196. chart1.interval().position("city*salary");
  197. chart1.render();
  198. //开发者薪资岗位TOP10
  199. const chart2 = new G2.Chart({
  200. container: "job-chart",
  201. forceFit: true,
  202. height: 400
  203. });
  204. chart2.source(this.jobChart);
  205. chart2.scale("salary", {
  206. tickInterval: this.jobTick
  207. });
  208. chart2.interval().position("job*salary");
  209. chart2.render();
  210. },
  211. async changeJob() {
  212. let data = { job: this.searchJob };
  213. let res = await this.$axios.$post("/api/salary/search_city", data);
  214. this.cityList = res.data.cityList;
  215. },
  216. handleCommandJob(command) {
  217. this.searchJob = command;
  218. },
  219. handleCommand(command) {
  220. this.searchCity = command;
  221. },
  222. search() {
  223. if (this.searchJob.length === 0) {
  224. this.$message("请输入查询岗位名称");
  225. return false;
  226. }
  227. window.location.href = `/salary/${this.searchCity}-${this.searchJob}/`.replace('c#', 'c%23');
  228. },
  229. inVal(val) {
  230. this.searchJob = val;
  231. }
  232. }
  233. };
  234. </script>
  235. <style lang="scss" scoped>
  236. .wrapper {
  237. overflow: hidden;
  238. }
  239. .main {
  240. margin: 0;
  241. width: 100%;
  242. }
  243. .pc {
  244. position: relative;
  245. margin: -85px 0 0;
  246. width: 100%;
  247. .header {
  248. position: relative;
  249. overflow: hidden;
  250. width: 100%;
  251. min-height: 200px;
  252. .bgImage {
  253. img {
  254. width: 100%;
  255. vertical-align: middle;
  256. }
  257. }
  258. .topContent {
  259. position: absolute;
  260. top: 85px;
  261. display: flex;
  262. justify-content: space-around;
  263. align-items: center;
  264. flex-direction: column;
  265. width: 1000px;
  266. left: 50%;
  267. transform: translateX(-50%);
  268. height: calc(100% - 85px);
  269. .title {
  270. line-height: 53px;
  271. text-align: center;
  272. font-weight: 600;
  273. font-size: 38px;
  274. color: #ffffff;
  275. }
  276. .search-wrapper {
  277. margin: 50px;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. }
  282. .search-content {
  283. /*width: 578px;*/
  284. height: 43px;
  285. border-radius: 4px 0px 0px 4px;
  286. background-color: #ffffff;
  287. display: flex;
  288. align-items: center;
  289. }
  290. .search-input {
  291. flex: 1;
  292. padding-left: 14px;
  293. padding-right: 14px;
  294. font-size: 16px;
  295. color: #999999;
  296. }
  297. .search-city {
  298. margin-right: 18px;
  299. display: flex;
  300. align-items: center;
  301. }
  302. .search-city span {
  303. line-height: 14px;
  304. font-weight: 600;
  305. font-size: 16px;
  306. color: #919aa7;
  307. }
  308. .search-city img {
  309. margin-left: 4px;
  310. width: 11px;
  311. height: 7px;
  312. }
  313. .search-btn {
  314. width: 104px;
  315. height: 53px;
  316. border-radius: 4px;
  317. background-color: #147eff;
  318. line-height: 53px;
  319. text-align: center;
  320. font-weight: 600;
  321. font-size: 20px;
  322. color: #ffffff;
  323. cursor: pointer;
  324. }
  325. }
  326. }
  327. .hot-search {
  328. margin: 15px auto 0;
  329. width: 700px;
  330. line-height: 20px;
  331. font-weight: 500;
  332. font-size: 14px;
  333. color: #ffffff;
  334. }
  335. .hot-search span {
  336. margin-right: 20px;
  337. }
  338. .content {
  339. overflow: hidden;
  340. margin-top: 20px;
  341. margin-bottom: 20px;
  342. background-color: #ffffff;
  343. }
  344. .info {
  345. margin: 40px auto 0;
  346. width: 807px;
  347. line-height: 26px;
  348. font-size: 15px;
  349. color: #666666;
  350. }
  351. .module-wrapper {
  352. margin: 50px auto 0;
  353. width: 1000px;
  354. }
  355. .module-title {
  356. margin-left: 47px;
  357. line-height: 25px;
  358. font-weight: 600;
  359. font-size: 18px;
  360. color: #000000;
  361. }
  362. .city-chart,
  363. .job-chart {
  364. margin: 50px auto 0;
  365. width: 950px;
  366. }
  367. }
  368. .el-scrollbar__wrap {
  369. overflow-x: hidden;
  370. }
  371. .mobile {
  372. .header {
  373. overflow: hidden;
  374. width: 100%;
  375. height: 6.5rem;
  376. background-image: url("~@/assets/img/salary/background.png");
  377. background-size: auto 6.5rem;
  378. background-repeat: no-repeat;
  379. background-position: top center;
  380. }
  381. .title {
  382. margin-top: 1.16rem;
  383. line-height: 0.92rem;
  384. text-align: center;
  385. font-weight: 600;
  386. font-size: 0.66rem;
  387. color: #ffffff;
  388. }
  389. .search-wrapper {
  390. margin: 0.66rem 0.2rem 0rem 0.2rem;
  391. display: flex;
  392. align-items: center;
  393. justify-content: center;
  394. }
  395. .search-content {
  396. width: 5.3rem;
  397. height: 0.85rem;
  398. border-radius: 0.06rem 0 0 0.06rem;
  399. background-color: #ffffff;
  400. display: flex;
  401. align-items: center;
  402. }
  403. .search-input {
  404. flex: 1;
  405. padding-left: 0.22rem;
  406. padding-right: 0.22rem;
  407. font-size: 0.26rem;
  408. color: #999999;
  409. }
  410. .search-city {
  411. margin-right: 0.32rem;
  412. display: flex;
  413. align-items: center;
  414. }
  415. .search-city span {
  416. font-weight: 600;
  417. font-size: 0.26rem;
  418. color: #919aa7;
  419. }
  420. .search-city img {
  421. margin-left: 0.06rem;
  422. width: 0.2rem;
  423. height: 0.12rem;
  424. }
  425. .search-btn {
  426. width: 1.66rem;
  427. height: 0.85rem;
  428. border-radius: 0.06rem 0 0 0.06rem;
  429. background-color: #147eff;
  430. line-height: 0.85rem;
  431. text-align: center;
  432. font-weight: 600;
  433. font-size: 0.32rem;
  434. color: #ffffff;
  435. }
  436. .hot-search {
  437. margin-top: 0.22rem;
  438. margin-left: 0.26rem;
  439. line-height: 0.34rem;
  440. font-weight: 500;
  441. font-size: 0.24rem;
  442. color: #ffffff;
  443. }
  444. .hot-search span {
  445. margin-right: 0.2rem;
  446. }
  447. .content {
  448. overflow: hidden;
  449. }
  450. .info {
  451. margin-bottom: 0.12rem;
  452. padding: 0.5rem 0.28rem 0.48rem;
  453. background-color: #ffffff;
  454. line-height: 0.44rem;
  455. font-size: 0.26rem;
  456. color: #666666;
  457. }
  458. .module-wrapper {
  459. overflow: hidden;
  460. background-color: #ffffff;
  461. }
  462. .module-title {
  463. margin-top: 0.44rem;
  464. margin-left: 0.36rem;
  465. line-height: 0.44rem;
  466. font-weight: 600;
  467. font-size: 0.32rem;
  468. color: #000000;
  469. }
  470. .city-chart,
  471. .job-chart {
  472. margin-top: 0.48rem;
  473. margin-left: -0.24rem;
  474. width: 100%;
  475. }
  476. .dropdown {
  477. //设置高度才能显示出滚动条 !important
  478. height: 300px;
  479. overflow: auto;
  480. }
  481. .dropdown::-webkit-scrollbar {
  482. width: 5px;
  483. height: 5px;
  484. background-color: #f5f5f5;
  485. }
  486. .dropdown::-webkit-scrollbar-track {
  487. //-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  488. border-radius: 10px;
  489. background-color: #f5f5f5;
  490. }
  491. }
  492. </style>
  493. <style>
  494. .pc .salary-job-search .el-input__inner {
  495. height: 53px;
  496. }
  497. .pc .salary-city-search .el-input__inner {
  498. height: 53px;
  499. }
  500. .mobile .salary-job-search .el-input__inner {
  501. height: .85rem;
  502. }
  503. .mobile .salary-city-search .el-input__inner {
  504. height: .85rem;
  505. }
  506. </style>