index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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" :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. };
  40. },
  41. onLoad() {
  42. this.getData();
  43. this.initData();
  44. uni.$on('select_city', (res) => {
  45. this.param.cityName = res.title;
  46. this.param.regionId = res.id;
  47. this.getData();
  48. });
  49. },
  50. methods: {
  51. initData() {
  52. //轮播图
  53. this.http.request({
  54. url: '/app/home/banner/0',
  55. success: (res) => {
  56. this.bannerList = res.data.data;
  57. }
  58. });
  59. //初始化所有地区
  60. this.http.request({
  61. url: '/app/common/column/city/all',
  62. success: (res) => {
  63. uni.setStorageSync('city_all', res.data.data);
  64. }
  65. });
  66. // #ifdef MP-WEIXIN
  67. //授权获取位置
  68. uni.authorize({
  69. scope: 'scope.userLocation',
  70. success: (s) => {
  71. uni.getLocation({
  72. type: 'wgs84',
  73. success: (res) => {
  74. uni.setStorageSync('location', res);
  75. this.param.latitude = res.latitude;
  76. this.param.longitude = res.longitude;
  77. this.getData();
  78. }
  79. });
  80. },
  81. fail(res) {
  82. uni.showModal({ title: '提示', content: '定位失败,请检查是否允许定位', showCancel: false });
  83. }
  84. });
  85. // #endif
  86. },
  87. getData() {
  88. this.http.request({
  89. url: '/app/position/list',
  90. data: this.param,
  91. success: (res) => {
  92. this.list = res.data.rows;
  93. }
  94. });
  95. },
  96. tabClick(e) {
  97. this.param.orderBy = e.orderBy;
  98. this.param.type = e.type;
  99. this.param.recommend = e.recommend;
  100. this.getData();
  101. },
  102. //点击轮播图
  103. BannerClick(index) {
  104. let item = this.bannerList[index];
  105. if (item.contentType == '新闻资讯') {
  106. uni.navigateTo({ url: '/pages/news/detail?id=' + item.contentId });
  107. }
  108. if (item.contentType == '通知公告') {
  109. uni.navigateTo({ url: '/pages/notice/detail?id=' + item.contentId });
  110. }
  111. if (item.contentType == '工作职位') {
  112. uni.navigateTo({ url: '/pages/job/detail?id=' + item.contentId });
  113. }
  114. },
  115. go(url) {
  116. uni.navigateTo({ url: url });
  117. }
  118. }
  119. };
  120. </script>
  121. <style lang="scss">
  122. .banner {
  123. margin-top: 15px;
  124. box-shadow: $box-shadow;
  125. }
  126. .tab {
  127. background-color: white;
  128. margin-top: 10px;
  129. border-radius: 5px;
  130. box-shadow: $box-shadow;
  131. }
  132. </style>