index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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: 1 }
  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. if (!uni.getStorageSync('city_all')) {
  66. this.http.request({
  67. url: '/app/common/column/city/all',
  68. success: (res) => {
  69. uni.setStorageSync('city_all', res.data.data);
  70. }
  71. });
  72. }
  73. // #ifdef MP-WEIXIN
  74. //授权获取位置
  75. uni.authorize({
  76. scope: 'scope.userLocation',
  77. success: (s) => {
  78. uni.getLocation({
  79. type: 'wgs84',
  80. success: (res) => {
  81. uni.setStorageSync('location', res);
  82. this.param.latitude = res.latitude;
  83. this.param.longitude = res.longitude;
  84. this.getData();
  85. }
  86. });
  87. },
  88. fail(res) {
  89. uni.showModal({ title: '提示', content: '定位失败,请检查是否允许定位', showCancel: false });
  90. }
  91. });
  92. // #endif
  93. },
  94. getData() {
  95. this.http.request({
  96. url: '/app/position/list',
  97. data: this.param,
  98. success: (res) => {
  99. this.list = res.data.rows;
  100. }
  101. });
  102. },
  103. tabClick(e) {
  104. this.param.orderBy = e.orderBy;
  105. this.param.type = e.type;
  106. this.param.recommend = e.recommend;
  107. this.param.current = e.current;
  108. this.getData();
  109. },
  110. //点击轮播图
  111. bannerClick(index) {
  112. let item = this.bannerList[index];
  113. if (item.contentType == '新闻资讯') {
  114. uni.navigateTo({ url: '/pages/news/detail?id=' + item.contentId });
  115. }
  116. if (item.contentType == '通知公告') {
  117. uni.navigateTo({ url: '/pages/notice/detail?id=' + item.contentId });
  118. }
  119. if (item.contentType == '工作职位') {
  120. uni.navigateTo({ url: '/pages/job/detail?id=' + item.contentId });
  121. }
  122. },
  123. go(url) {
  124. uni.navigateTo({ url: url });
  125. }
  126. },
  127. //下拉刷新
  128. onPullDownRefresh() {
  129. setTimeout(() => {
  130. this.getData();
  131. this.initData();
  132. uni.stopPullDownRefresh();
  133. }, 1000);
  134. }
  135. };
  136. </script>
  137. <style lang="scss">
  138. .banner {
  139. margin-top: 15px;
  140. box-shadow: $box-shadow;
  141. }
  142. .tab {
  143. background-color: white;
  144. margin-top: 10px;
  145. border-radius: 5px;
  146. box-shadow: $box-shadow;
  147. }
  148. .list {
  149. padding-top: 10px;
  150. }
  151. .btn {
  152. width: 60%;
  153. margin-top: 10px;
  154. }
  155. </style>