list.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="main pt0">
  3. <view class="search">
  4. <u-search placeholder="搜索工作" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/job/search')"></u-search>
  5. </view>
  6. <view class="tab">
  7. <u-tabs :list="tab" @click="tabClick"></u-tabs>
  8. <view class="city" @click="go('/pages/job/position/city')">
  9. <text class="icon">&#xe62e;</text>
  10. <text>{{ param.cityName || '南宁市' }}</text>
  11. </view>
  12. <view class="filters" @click="show = true">
  13. <text class="icon">&#xe68c;</text>
  14. <text>筛选</text>
  15. </view>
  16. </view>
  17. <view class="list">
  18. <job :list="list"></job>
  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. <filters v-model="show" @confirm="confirm"></filters>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. tab: [
  30. { name: '最新', orderBy: 'id' },
  31. { name: '附近', orderBy: 'distance' }
  32. ],
  33. list: [],
  34. param: { pageNum: 1, pageSize: 10, orderBy: 'id' },
  35. loadMore: true,
  36. show: false
  37. };
  38. },
  39. onLoad(e) {
  40. if (this.getLocation()) {
  41. this.param.latitude = this.getLocation().latitude;
  42. this.param.longitude = this.getLocation().longitude;
  43. }
  44. this.param.type = e.type || 0;
  45. setTimeout(() => {
  46. uni.setNavigationBarTitle({ title: this.param.type == 0 ? '全职' : '兼职' });
  47. }, 300);
  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/position/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.refresh();
  70. },
  71. confirm(e) {
  72. Object.assign(this.param, e);
  73. this.refresh();
  74. },
  75. go(url) {
  76. uni.navigateTo({ url: url });
  77. },
  78. //刷新数据
  79. refresh() {
  80. this.loadMore = true;
  81. this.param.pageNum = 1;
  82. this.list = [];
  83. this.getData();
  84. }
  85. },
  86. //下拉刷新
  87. onPullDownRefresh() {
  88. setTimeout(() => {
  89. this.refresh();
  90. uni.stopPullDownRefresh();
  91. }, 1000);
  92. },
  93. //上拉加载
  94. onReachBottom() {
  95. if (this.loadMore) {
  96. this.param.pageNum++;
  97. this.getData();
  98. }
  99. }
  100. };
  101. </script>
  102. <style lang="scss"></style>