list.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="main pt0">
  3. <view class="search">
  4. <view class="usearch">
  5. <u-search placeholder="搜索工作" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/job/search?type=' + param.type)"></u-search>
  6. </view>
  7. <view class="address omit" @click="go('/pages/job/position/city')">
  8. <text class="icon">&#xe64b;</text>
  9. <text>{{ param.cityName || '南宁市' }}</text>
  10. </view>
  11. </view>
  12. <view class="tab">
  13. <u-tabs :list="tab" :inactiveStyle="{ fontSize: '16px' }" :lineHeight="5" :activeStyle="{ color: '#3c9cff', fontSize: '16px' }" :current="current" @click="tabClick"></u-tabs>
  14. <view class="filters" @click="show = true">
  15. <text class="icon">&#xe68c;</text>
  16. <text>筛选</text>
  17. </view>
  18. </view>
  19. <view class="list">
  20. <job :list="list"></job>
  21. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  22. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  23. </view>
  24. <filters v-model="show" @confirm="confirm"></filters>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. tab: [
  32. { name: '最新', orderBy: 'id', recommend: '' },
  33. { name: '推荐', orderBy: 'id', recommend: 1 },
  34. { name: '附近', orderBy: 'distance', recommend: '' }
  35. ],
  36. current: 0,
  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. this.param.type = e.type || 0;
  49. this.current = e.current || 0;
  50. setTimeout(() => {
  51. uni.setNavigationBarTitle({ title: this.param.type == 0 ? '全职岗位' : '兼职岗位' });
  52. }, 300);
  53. uni.$on('select_city', (res) => {
  54. this.param.cityName = res.title;
  55. this.param.regionId = res.id;
  56. this.refresh();
  57. });
  58. this.getData();
  59. },
  60. methods: {
  61. getData() {
  62. this.http.request({
  63. url: '/app/position/list',
  64. data: this.param,
  65. loading: 'false',
  66. success: (res) => {
  67. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  68. this.list.push(...res.data.rows);
  69. }
  70. });
  71. },
  72. tabClick(e) {
  73. this.param.orderBy = e.orderBy;
  74. this.param.recommend = e.recommend;
  75. this.refresh();
  76. },
  77. confirm(e) {
  78. Object.assign(this.param, e);
  79. this.refresh();
  80. },
  81. go(url) {
  82. uni.navigateTo({ url: url });
  83. },
  84. //刷新数据
  85. refresh() {
  86. this.loadMore = true;
  87. this.param.pageNum = 1;
  88. this.list = [];
  89. this.getData();
  90. }
  91. },
  92. //下拉刷新
  93. onPullDownRefresh() {
  94. setTimeout(() => {
  95. this.refresh();
  96. uni.stopPullDownRefresh();
  97. }, 1000);
  98. },
  99. //上拉加载
  100. onReachBottom() {
  101. if (this.loadMore) {
  102. this.param.pageNum++;
  103. this.getData();
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss"></style>