card.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="main pt0">
  3. <view class="search">
  4. <u-search placeholder="搜索企业" v-model="param.name" bgColor="white" @search="refresh()" @clear="(param.name = ''), refresh()" :showAction="false"></u-search>
  5. </view>
  6. <view class="tab">
  7. <u-tabs :list="tab" @click="tabClick"></u-tabs>
  8. <view class="filters" @click="go('/pages/job/position/city')">
  9. <text class="icon">&#xe64b;</text>
  10. <text>{{ param.cityName || '南宁市' }}</text>
  11. </view>
  12. </view>
  13. <view class="list">
  14. <view class="item" v-for="(item, index) in list" :key="index" @click="go('/pages/job/enterprise/detail?id=' + item.id)">
  15. <view class="title omit">{{ item.name }}</view>
  16. <view class="desc">
  17. <text class="icon">&#xe64f;</text>
  18. <text>{{ item.regionName }} · 招聘岗位:{{ item.positions }}</text>
  19. </view>
  20. <view class="distance" v-if="item.distance">距离你{{ item.distance }}km</view>
  21. </view>
  22. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  23. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. ip: this.http.ip,
  32. tab: [
  33. { name: '最新', orderBy: 'id', recommend: '' },
  34. { name: '推荐', orderBy: 'id', recommend: 1 },
  35. { name: '附近', orderBy: 'distance', recommend: '' }
  36. ],
  37. list: [],
  38. param: { pageNum: 1, pageSize: 10, orderBy: 'id' },
  39. loadMore: true,
  40. show: false
  41. };
  42. },
  43. onLoad(e) {
  44. if (this.getLocation()) {
  45. this.param.latitude = this.getLocation().latitude;
  46. this.param.longitude = this.getLocation().longitude;
  47. }
  48. uni.$on('select_city', (res) => {
  49. this.param.cityName = res.title;
  50. this.param.regionId = res.id;
  51. this.refresh();
  52. });
  53. this.getData();
  54. },
  55. methods: {
  56. getData() {
  57. this.http.request({
  58. url: '/app/enterprise/list',
  59. data: this.param,
  60. loading: 'false',
  61. success: (res) => {
  62. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  63. this.list.push(...res.data.rows);
  64. }
  65. });
  66. },
  67. tabClick(e) {
  68. this.param.orderBy = e.orderBy;
  69. this.param.recommend = e.recommend;
  70. this.refresh();
  71. },
  72. go(url) {
  73. uni.navigateTo({ url: url });
  74. },
  75. //刷新数据
  76. refresh() {
  77. this.loadMore = true;
  78. this.param.pageNum = 1;
  79. this.list = [];
  80. this.getData();
  81. }
  82. },
  83. //下拉刷新
  84. onPullDownRefresh() {
  85. setTimeout(() => {
  86. this.refresh();
  87. uni.stopPullDownRefresh();
  88. }, 1000);
  89. },
  90. //上拉加载
  91. onReachBottom() {
  92. if (this.loadMore) {
  93. this.param.pageNum++;
  94. this.getData();
  95. }
  96. }
  97. };
  98. </script>
  99. <style lang="scss">
  100. .scroll {
  101. background-color: white;
  102. margin-bottom: 10px;
  103. overflow: hidden;
  104. border-radius: 5px;
  105. padding-top: 10px;
  106. .gg {
  107. .title {
  108. font-size: 15px;
  109. }
  110. }
  111. .sitem {
  112. float: left;
  113. width: 90px;
  114. text-align: center;
  115. font-size: 14px;
  116. padding: 8px;
  117. image {
  118. width: 60px;
  119. height: 60px;
  120. border-radius: 8px;
  121. }
  122. }
  123. }
  124. .item {
  125. background-color: white;
  126. border-radius: 5px;
  127. padding: 12px;
  128. margin-bottom: 10px;
  129. .title {
  130. font-weight: bold;
  131. .icon {
  132. color: $main-color;
  133. padding-right: 5px;
  134. }
  135. }
  136. .desc {
  137. font-size: 14px;
  138. color: $font-c;
  139. padding-top: 7px;
  140. .icon {
  141. color: $main-color;
  142. padding-right: 3px;
  143. }
  144. }
  145. .distance {
  146. float: right;
  147. margin-top: -18px;
  148. font-size: 14px;
  149. color: $font-c;
  150. }
  151. }
  152. </style>