index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="main">
  3. <!--搜索-->
  4. <view class="search">
  5. <view class="usearch">
  6. <u-search placeholder="搜索工作" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/job/search')"></u-search>
  7. </view>
  8. <view class="address omit" @click="go('/pages/job/position/city')">
  9. <text class="icon">&#xe64b;</text>
  10. <text>{{ param.cityName || '南宁市' }}</text>
  11. </view>
  12. </view>
  13. <!--轮播图-->
  14. <view class="banner">
  15. <u-swiper circular :radius="5" :indicator="true" keyName="pic" :list="bannerList" :height="160" class="uni-swiper" @click="click"></u-swiper>
  16. </view>
  17. <view class="tab">
  18. <u-tabs :scrollable="false" :inactiveStyle="{ fontSize: '17px' }" :activeStyle="{ color: '#3c9cff', fontSize: '17px' }" :list="tab" @click="tabClick"></u-tabs>
  19. </view>
  20. <!--职位列表-->
  21. <view class="list">
  22. <jobIndex :list="list" v-if="list.length > 0"></jobIndex>
  23. <u-empty v-else text="该城市暂无工作"></u-empty>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. tab: [
  32. { name: '推荐工作', orderBy: 'id', type: 0, recommend: 1 },
  33. { name: '身边工作', orderBy: 'distance', type: 0, recommend: 1 },
  34. { name: '现结工作', orderBy: 'id', type: 1, recommend: 1 }
  35. ],
  36. list: [],
  37. param: { pageNum: 1, pageSize: 8, type: 0, recommend: 1 },
  38. bannerList: [],
  39. noticeList: []
  40. };
  41. },
  42. onLoad() {
  43. this.getData();
  44. this.initData();
  45. uni.$on('select_city', (res) => {
  46. this.param.cityName = res.title;
  47. this.param.regionId = res.id;
  48. this.getData();
  49. });
  50. },
  51. methods: {
  52. initData() {
  53. //首页数据
  54. this.http.request({
  55. url: '/app/home/index',
  56. success: (res) => {
  57. this.contract = res.data.data.contract;
  58. this.bannerList = res.data.data.bannerList;
  59. res.data.data.noticeList.forEach((item) => {
  60. this.noticeList.push(item.title);
  61. });
  62. }
  63. });
  64. //初始化所有地区
  65. this.http.request({
  66. url: '/app/common/column/city/all',
  67. success: (res) => {
  68. uni.setStorageSync('city_all', res.data.data);
  69. }
  70. });
  71. // #ifdef MP-WEIXIN
  72. //授权获取位置
  73. uni.authorize({
  74. scope: 'scope.userLocation',
  75. success: (s) => {
  76. uni.getLocation({
  77. type: 'wgs84',
  78. success: (res) => {
  79. uni.setStorageSync('location', res);
  80. this.param.latitude = res.latitude;
  81. this.param.longitude = res.longitude;
  82. this.getData();
  83. }
  84. });
  85. },
  86. fail(res) {
  87. uni.showModal({ title: '提示', content: '定位失败,请检查是否允许定位', showCancel: false });
  88. }
  89. });
  90. // #endif
  91. },
  92. getData() {
  93. this.http.request({
  94. url: '/app/position/list',
  95. data: this.param,
  96. success: (res) => {
  97. this.list = res.data.rows;
  98. }
  99. });
  100. },
  101. tabClick(e) {
  102. this.param.orderBy = e.orderBy;
  103. this.param.type = e.type;
  104. this.param.recommend = e.recommend;
  105. this.getData();
  106. },
  107. go(url) {
  108. uni.navigateTo({ url: url });
  109. }
  110. }
  111. };
  112. </script>
  113. <style lang="scss">
  114. .banner {
  115. margin-top: 15px;
  116. box-shadow: $box-shadow;
  117. }
  118. .tab {
  119. background-color: white;
  120. margin-top: 10px;
  121. border-radius: 5px;
  122. box-shadow: $box-shadow;
  123. }
  124. </style>