index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 && param.recommend == 1"></jobIndex>
  23. <job :list="list" v-if="list.length > 0 && param.recommend == ''"></job>
  24. <u-empty v-if="list.length === 0" text="该城市暂无工作"></u-empty>
  25. <button class="btn" v-if="list.length == 8" @click="go('/pages/job/list?type=' + param.type + '&current=' + param.current)">
  26. <text>查看更多</text>
  27. <text class="icon">&#xe62b;</text>
  28. </button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. tab: [
  37. { name: '推荐工作', orderBy: 'id', type: 0, recommend: 1, current: 1 },
  38. { name: '身边工作', orderBy: 'distance', type: 0, recommend: '', current: 2 },
  39. { name: '现结工作', orderBy: 'id', type: 1, recommend: 1, current: 0 }
  40. ],
  41. list: [],
  42. param: { pageNum: 1, pageSize: 8, type: 0, recommend: 1, current: 1 },
  43. bannerList: []
  44. };
  45. },
  46. onLoad() {
  47. this.getData();
  48. this.initData();
  49. uni.$on('select_city', (res) => {
  50. this.param.cityName = res.title;
  51. this.param.regionId = res.id;
  52. this.getData();
  53. });
  54. },
  55. methods: {
  56. initData() {
  57. //轮播图
  58. this.http.request({
  59. url: '/app/home/banner/0',
  60. success: (res) => {
  61. this.bannerList = res.data.data;
  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.param.current = e.current;
  106. this.getData();
  107. },
  108. //点击轮播图
  109. BannerClick(index) {
  110. let item = this.bannerList[index];
  111. if (item.contentType == '新闻资讯') {
  112. uni.navigateTo({ url: '/pages/news/detail?id=' + item.contentId });
  113. }
  114. if (item.contentType == '通知公告') {
  115. uni.navigateTo({ url: '/pages/notice/detail?id=' + item.contentId });
  116. }
  117. if (item.contentType == '工作职位') {
  118. uni.navigateTo({ url: '/pages/job/detail?id=' + item.contentId });
  119. }
  120. },
  121. go(url) {
  122. uni.navigateTo({ url: url });
  123. }
  124. }
  125. };
  126. </script>
  127. <style lang="scss">
  128. .banner {
  129. margin-top: 15px;
  130. box-shadow: $box-shadow;
  131. }
  132. .tab {
  133. background-color: white;
  134. margin-top: 10px;
  135. border-radius: 5px;
  136. box-shadow: $box-shadow;
  137. }
  138. .list {
  139. padding-top: 10px;
  140. }
  141. .btn {
  142. width: 60%;
  143. margin-top: 10px;
  144. }
  145. </style>