card.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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">&#xe62e;</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">{{ item.regionName }}</view>
  17. <view class="distance" v-if="item.distance">距离你{{ item.distance }}km</view>
  18. </view>
  19. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  20. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. tab: [
  29. { name: '最新', orderBy: 'id' },
  30. { name: '附近', orderBy: 'distance' }
  31. ],
  32. list: [],
  33. param: { pageNum: 1, pageSize: 10, orderBy: 'id' },
  34. loadMore: true,
  35. show: false
  36. };
  37. },
  38. onLoad(e) {
  39. if (this.getLocation()) {
  40. this.param.latitude = this.getLocation().latitude;
  41. this.param.longitude = this.getLocation().longitude;
  42. }
  43. uni.$on('select_city', (res) => {
  44. this.param.cityName = res.title;
  45. this.param.regionId = res.id;
  46. this.refresh();
  47. });
  48. this.getData();
  49. },
  50. methods: {
  51. getData() {
  52. this.http.request({
  53. url: '/app/enterprise/list',
  54. data: this.param,
  55. loading: 'false',
  56. success: (res) => {
  57. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  58. this.list.push(...res.data.rows);
  59. }
  60. });
  61. },
  62. tabClick(e) {
  63. this.param.orderBy = e.orderBy;
  64. this.refresh();
  65. },
  66. go(url) {
  67. uni.navigateTo({ url: url });
  68. },
  69. //刷新数据
  70. refresh() {
  71. this.loadMore = true;
  72. this.param.pageNum = 1;
  73. this.list = [];
  74. this.getData();
  75. }
  76. },
  77. //下拉刷新
  78. onPullDownRefresh() {
  79. setTimeout(() => {
  80. this.refresh();
  81. uni.stopPullDownRefresh();
  82. }, 1000);
  83. },
  84. //上拉加载
  85. onReachBottom() {
  86. if (this.loadMore) {
  87. this.param.pageNum++;
  88. this.getData();
  89. }
  90. }
  91. };
  92. </script>
  93. <style lang="scss">
  94. .item {
  95. background-color: white;
  96. border-radius: 5px;
  97. padding: 12px;
  98. margin-bottom: 10px;
  99. .title {
  100. font-weight: bold;
  101. }
  102. .desc {
  103. font-size: 14px;
  104. color: $font-c;
  105. padding-top: 7px;
  106. }
  107. .distance {
  108. float: right;
  109. margin-top: -18px;
  110. font-size: 14px;
  111. color: $font-c;
  112. }
  113. }
  114. </style>