index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <div>
  3. <div class="wrapper pc" v-if="screenWidth > 960">
  4. <div class="header">
  5. <div class="title">查岗位薪资 就上程序员客栈</div>
  6. <div class="search-wrapper">
  7. <div class="search-content">
  8. <input type="text" @keyup.enter="search" v-model="searchJob" placeholder="请输入您需要查询的岗位名称,如c++软件工程师" class="search-input">
  9. <el-dropdown @command="handleCommand">
  10. <div class="search-city">
  11. <span>{{searchCity}}</span>
  12. <img src="@/assets/img/salary/icon_arrow_down.png" alt="">
  13. </div>
  14. <el-dropdown-menu slot="dropdown">
  15. <el-dropdown-item v-for="citys in cityList" :command="citys.city">{{citys.city}}</el-dropdown-item>
  16. </el-dropdown-menu>
  17. </el-dropdown>
  18. </div>
  19. <div @click="search" class="search-btn">查询</div>
  20. </div>
  21. <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>
  22. </div>
  23. <div class="content">
  24. <div class="info">截至2019年9月6日,调查了全国的开发者的工资数据后发现,{{city}}开发者平均工资最高达¥{{citySalary}}元/月,{{job}}开发者的平均工资最高达{{jobSalary}}元/月,本数据仅供参考。</div>
  25. <div class="module-wrapper">
  26. <div class="module-title">开发者薪资排行城市TOP10</div>
  27. <div id="city-chart" class="city-chart"></div>
  28. </div>
  29. <div class="module-wrapper">
  30. <div class="module-title">开发者薪资岗位TOP10</div>
  31. <div id="job-chart" class="job-chart"></div>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="wrapper mobile" v-else-if="screenWidth > 0">
  36. <div class="header">
  37. <div class="title">查岗位薪资<br/>就上程序员客栈</div>
  38. <div class="search-wrapper">
  39. <div class="search-content">
  40. <input type="text" @keyup.enter="search" v-model="searchJob" placeholder="岗位名称,如c++软件工程师" class="search-input">
  41. <el-dropdown>
  42. <div class="search-city">
  43. <span>{{searchCity}}</span>
  44. <img src="@/assets/img/salary/icon_arrow_down.png" alt="">
  45. </div>
  46. <el-dropdown-menu slot="dropdown">
  47. <el-dropdown-item v-for="citys in cityList" :command="citys.city">{{citys.city}}</el-dropdown-item>
  48. </el-dropdown-menu>
  49. </el-dropdown>
  50. </div>
  51. <div @click="search" class="search-btn">查询</div>
  52. </div>
  53. <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>
  54. </div>
  55. <div class="content">
  56. <div class="info">截至2019年9月6日,调查了全国38749756名开发者的工资数据后发现,上海开发者平均工资最高达¥97974元/月,Python开发者的平均工资最高达66666元/月,本数据仅供参考。</div>
  57. <div class="module-wrapper">
  58. <div class="module-title">开发者薪资排行城市TOP10</div>
  59. <div id="city-chart" class="city-chart"></div>
  60. </div>
  61. <div class="module-wrapper">
  62. <div class="module-title">开发者薪资岗位TOP10</div>
  63. <div id="job-chart" class="job-chart"></div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. screenWidth: 0,
  74. cityChart : [],
  75. jobChart : [],
  76. jobList :[],
  77. city:'',
  78. citySalary:0,
  79. cityList:[],
  80. job:'',
  81. jobSalary:0,
  82. cityTick:0,
  83. jobTick:0,
  84. searchJob:'',
  85. searchCity:'杭州',
  86. }
  87. },
  88. mounted() {
  89. this.screenWidth = window.screen.width
  90. this.$nextTick(()=>{
  91. this.getData()
  92. })
  93. },
  94. methods: {
  95. async getData(){
  96. let res = await this.$axios.$post('/api/salary/index_info');
  97. this.cityChart = res.data.sortOfCity;
  98. this.jobChart = res.data.sortOfJob;
  99. this.jobList = res.data.allJobType;
  100. this.city = res.data.sortOfCity[0].city;
  101. this.citySalary = res.data.sortOfCity[0].salary;
  102. this.job = res.data.sortOfJob[0].job;
  103. this.jobSalary = res.data.sortOfJob[0].salary;
  104. this.cityTick = res.data.cityTick;
  105. this.jobTick = res.data.jobTick;
  106. this.cityList = res.data.cityList;
  107. console.log(this.cityList);
  108. for (let i=0 ;i < this.cityChart.length ;i++){
  109. this.cityChart[i].salary = parseInt(this.cityChart[i].salary);
  110. }
  111. for (let i=0 ;i < this.jobChart.length ;i++){
  112. this.jobChart[i].salary = parseInt(this.jobChart[i].salary);
  113. }
  114. //开发者薪资排行城市TOP10
  115. const chart1 = new G2.Chart({
  116. container: 'city-chart',
  117. forceFit: true,
  118. height: 400,
  119. });
  120. chart1.source(this.cityChart);
  121. chart1.scale('salary', {
  122. tickInterval: this.cityTick
  123. });
  124. chart1.interval().position('city*salary');
  125. chart1.render()
  126. //开发者薪资岗位TOP10
  127. const chart2 = new G2.Chart({
  128. container: 'job-chart',
  129. forceFit: true,
  130. height: 400,
  131. });
  132. chart2.source(this.jobChart);
  133. chart2.scale('salary', {
  134. tickInterval: this.jobTick
  135. });
  136. chart2.interval().position('job*salary');
  137. chart2.render()
  138. },
  139. handleCommand(command) {
  140. this.searchCity = command;
  141. },
  142. search(){
  143. if(this.searchJob.length === 0){
  144. this.$message('请输入查询岗位名称');
  145. return false;
  146. }
  147. this.searchJob = this.searchJob.replace(/c#/, "c%23");
  148. this.searchJob = this.searchJob.replace(/c\+\+*/, "c%24");
  149. this.$router.push('/salary/detail?job='+encodeURI(this.searchJob)+'&city='+encodeURI(this.searchCity));
  150. },
  151. inVal(val){
  152. this.searchJob = val;
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scope>
  158. .wrapper {
  159. overflow: hidden;
  160. }
  161. .main {
  162. margin: 0;
  163. width: 100%;
  164. }
  165. .pc {
  166. .header {
  167. overflow: hidden;
  168. width: 100%;
  169. height: 450px;
  170. background-image: url('~@/assets/img/salary/background.png');
  171. background-size: 1920px 533px;
  172. background-repeat: no-repeat;
  173. background-position: top center;
  174. }
  175. .title {
  176. margin-top: 104px;
  177. line-height: 53px;
  178. text-align: center;
  179. font-weight: 600;
  180. font-size: 38px;
  181. color: #FFFFFF;
  182. }
  183. .search-wrapper {
  184. margin-top: 50px;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. }
  189. .search-content {
  190. width: 578px;
  191. height: 53px;
  192. border-radius: 4px 0px 0px 4px;
  193. background-color: #FFFFFF;
  194. display: flex;
  195. align-items: center;
  196. }
  197. .search-input {
  198. flex: 1;
  199. padding-left: 14px;
  200. padding-right: 14px;
  201. font-size: 16px;
  202. color: #999999;
  203. }
  204. .search-city {
  205. margin-right: 18px;
  206. display: flex;
  207. align-items: center;
  208. }
  209. .search-city span {
  210. line-height: 14px;
  211. font-weight: 600;
  212. font-size: 16px;
  213. color: #919AA7;
  214. }
  215. .search-city img {
  216. margin-left: 4px;
  217. width: 11px;
  218. height: 7px;
  219. }
  220. .search-btn {
  221. width: 104px;
  222. height: 53px;
  223. border-radius: 0px 4px 4px 0px;
  224. background-color: #147EFF;
  225. line-height: 53px;
  226. text-align: center;
  227. font-weight:600;
  228. font-size: 20px;
  229. color: #FFFFFF;
  230. cursor: pointer;
  231. }
  232. .hot-search {
  233. margin: 15px auto 0;
  234. width: 700px;
  235. line-height: 20px;
  236. font-weight: 500;
  237. font-size: 14px;
  238. color: #FFFFFF;
  239. }
  240. .hot-search span {
  241. margin-right: 20px;
  242. }
  243. .content {
  244. overflow: hidden;
  245. margin-top: 20px;
  246. margin-bottom: 20px;
  247. background-color: #FFFFFF;
  248. }
  249. .info {
  250. margin: 40px auto 0;
  251. width: 807px;
  252. line-height: 26px;
  253. font-size: 15px;
  254. color: #666666;
  255. }
  256. .module-wrapper {
  257. margin: 50px auto 0;
  258. width: 1000px;
  259. }
  260. .module-title {
  261. margin-left: 47px;
  262. line-height: 25px;
  263. font-weight:600;
  264. font-size: 18px;
  265. color: #000000;
  266. }
  267. .city-chart, .job-chart {
  268. margin: 50px auto 0;
  269. width: 950px;
  270. }
  271. }
  272. .mobile {
  273. .header {
  274. overflow: hidden;
  275. width: 100%;
  276. height: 6.5rem;
  277. background-image: url('~@/assets/img/salary/background.png');
  278. background-size: auto 6.5rem;
  279. background-repeat: no-repeat;
  280. background-position: top center;
  281. }
  282. .title {
  283. margin-top: 1.16rem;
  284. line-height: .92rem;
  285. text-align: center;
  286. font-weight: 600;
  287. font-size: .66rem;
  288. color: #FFFFFF;
  289. }
  290. .search-wrapper {
  291. margin-top: .66rem;
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. }
  296. .search-content {
  297. width: 5.3rem;
  298. height: .85rem;
  299. border-radius: .06rem 0 0 .06rem;
  300. background-color: #FFFFFF;
  301. display: flex;
  302. align-items: center;
  303. }
  304. .search-input {
  305. flex: 1;
  306. padding-left: .22rem;
  307. padding-right: .22rem;
  308. font-size: .26rem;
  309. color: #999999;
  310. }
  311. .search-city {
  312. margin-right: .32rem;
  313. display: flex;
  314. align-items: center;
  315. }
  316. .search-city span {
  317. font-weight: 600;
  318. font-size: .26rem;
  319. color: #919AA7;
  320. }
  321. .search-city img {
  322. margin-left: .06rem;
  323. width: .2rem;
  324. height: .12rem;
  325. }
  326. .search-btn {
  327. width: 1.66rem;
  328. height: .85rem;
  329. border-radius: .06rem 0 0 .06rem;
  330. background-color: #147EFF;
  331. line-height: .85rem;
  332. text-align: center;
  333. font-weight:600;
  334. font-size: .32rem;
  335. color: #FFFFFF;
  336. }
  337. .hot-search {
  338. margin-top: .22rem;
  339. margin-left: .26rem;
  340. line-height: .34rem;
  341. font-weight: 500;
  342. font-size: .24rem;
  343. color: #FFFFFF;
  344. }
  345. .hot-search span {
  346. margin-right: .2rem;
  347. }
  348. .content {
  349. overflow: hidden;
  350. }
  351. .info {
  352. margin-bottom: .12rem;
  353. padding: .5rem .28rem .48rem;
  354. background-color: #ffffff;
  355. line-height: .44rem;
  356. font-size: .26rem;
  357. color: #666666;
  358. }
  359. .module-wrapper {
  360. overflow: hidden;
  361. background-color: #ffffff;
  362. }
  363. .module-title {
  364. margin-top: .44rem;
  365. margin-left: .36rem;
  366. line-height: .44rem;
  367. font-weight: 600;
  368. font-size: .32rem;
  369. color: #000000;
  370. }
  371. .city-chart, .job-chart {
  372. margin: .48rem auto 0;
  373. width: 100%;
  374. }
  375. .dropdown{
  376. //设置高度才能显示出滚动条 !important
  377. height:300px;
  378. overflow: auto;
  379. }
  380. .dropdown::-webkit-scrollbar
  381. {
  382. width: 5px;
  383. height: 5px;
  384. background-color: #F5F5F5;
  385. }
  386. .dropdown::-webkit-scrollbar-track
  387. {
  388. //-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  389. border-radius: 10px;
  390. background-color: #F5F5F5;
  391. }
  392. }
  393. </style>