index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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="BannerClick"></u-swiper>
  16. </view>
  17. <view class="tab">
  18. <u-tabs :scrollable="false" :lineHeight="5" :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. <button class="btn" v-if="list.length == 8" @click="go('/pages/job/list?type=' + param.type + '&current=' + param.current)">
  25. <text>查看更多</text>
  26. <text class="icon">&#xe62b;</text>
  27. </button>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. tab: [
  36. { name: '推荐工作', orderBy: 'id', type: 0, recommend: 1, current: 1 },
  37. { name: '身边工作', orderBy: 'distance', type: 0, recommend: 1, current: 2 },
  38. { name: '现结工作', orderBy: 'id', type: 1, recommend: 1, current: 0 }
  39. ],
  40. list: [],
  41. param: { pageNum: 1, pageSize: 8, type: 0, recommend: 1, current: 1 },
  42. bannerList: []
  43. };
  44. },
  45. onLoad() {
  46. this.getData();
  47. this.initData();
  48. uni.$on('select_city', (res) => {
  49. this.param.cityName = res.title;
  50. this.param.regionId = res.id;
  51. this.getData();
  52. });
  53. },
  54. methods: {
  55. initData() {
  56. //轮播图
  57. this.http.request({
  58. url: '/app/home/banner/0',
  59. success: (res) => {
  60. this.bannerList = res.data.data;
  61. }
  62. });
  63. //初始化所有地区
  64. this.http.request({
  65. url: '/app/common/column/city/all',
  66. success: (res) => {
  67. uni.setStorageSync('city_all', res.data.data);
  68. }
  69. });
  70. // #ifdef MP-WEIXIN
  71. //授权获取位置
  72. uni.authorize({
  73. scope: 'scope.userLocation',
  74. success: (s) => {
  75. uni.getLocation({
  76. type: 'wgs84',
  77. success: (res) => {
  78. uni.setStorageSync('location', res);
  79. this.param.latitude = res.latitude;
  80. this.param.longitude = res.longitude;
  81. this.getData();
  82. }
  83. });
  84. },
  85. fail(res) {
  86. uni.showModal({ title: '提示', content: '定位失败,请检查是否允许定位', showCancel: false });
  87. }
  88. });
  89. // #endif
  90. },
  91. getData() {
  92. this.http.request({
  93. url: '/app/position/list',
  94. data: this.param,
  95. success: (res) => {
  96. this.list = res.data.rows;
  97. }
  98. });
  99. },
  100. tabClick(e) {
  101. this.param.orderBy = e.orderBy;
  102. this.param.type = e.type;
  103. this.param.recommend = e.recommend;
  104. this.param.current = e.current;
  105. this.getData();
  106. },
  107. //点击轮播图
  108. BannerClick(index) {
  109. let item = this.bannerList[index];
  110. if (item.contentType == '新闻资讯') {
  111. uni.navigateTo({ url: '/pages/news/detail?id=' + item.contentId });
  112. }
  113. if (item.contentType == '通知公告') {
  114. uni.navigateTo({ url: '/pages/notice/detail?id=' + item.contentId });
  115. }
  116. if (item.contentType == '工作职位') {
  117. uni.navigateTo({ url: '/pages/job/detail?id=' + item.contentId });
  118. }
  119. },
  120. go(url) {
  121. uni.navigateTo({ url: url });
  122. }
  123. }
  124. };
  125. </script>
  126. <style lang="scss">
  127. .banner {
  128. margin-top: 15px;
  129. box-shadow: $box-shadow;
  130. }
  131. .tab {
  132. background-color: white;
  133. margin-top: 10px;
  134. border-radius: 5px;
  135. box-shadow: $box-shadow;
  136. }
  137. .btn {
  138. width: 60%;
  139. margin-top: 10px;
  140. }
  141. </style>