list.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="main pt0">
  3. <view class="tab">
  4. <u-tabs :list="tab" @click="tabClick"></u-tabs>
  5. <view class="filters" @click="show = true">
  6. <text class="icon">&#xe68c;</text>
  7. <text>筛选</text>
  8. </view>
  9. </view>
  10. <view class="list">
  11. <job :list="list"></job>
  12. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  13. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  14. </view>
  15. <filters v-model="show" @confirm="confirm"></filters>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. tab: [
  23. { name: '最新', orderBy: 'id' },
  24. { name: '附近', orderBy: 'distance' }
  25. ],
  26. list: [],
  27. param: { pageNum: 1, pageSize: 10, type: 0, orderBy: 'id' },
  28. loadMore: true,
  29. show: false
  30. };
  31. },
  32. onLoad(e) {
  33. this.param.enterpriseId = e.id;
  34. if (this.getLocation()) {
  35. this.param.latitude = this.getLocation().latitude;
  36. this.param.longitude = this.getLocation().longitude;
  37. }
  38. setTimeout(() => {
  39. uni.setNavigationBarTitle({ title: e.name });
  40. }, 300);
  41. this.getData();
  42. },
  43. methods: {
  44. getData() {
  45. this.http.request({
  46. url: '/app/position/list',
  47. data: this.param,
  48. loading: 'false',
  49. success: (res) => {
  50. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  51. this.list.push(...res.data.rows);
  52. }
  53. });
  54. },
  55. tabClick(e) {
  56. this.param.orderBy = e.orderBy;
  57. this.refresh();
  58. },
  59. confirm(e) {
  60. this.param.experience = e.experience.map((item) => item.name).toString() || '';
  61. this.param.salary = e.salary.map((item) => item.name).toString() || '';
  62. this.param.positionId = e.positionId || '';
  63. this.refresh();
  64. },
  65. go(url) {
  66. uni.navigateTo({ url: url });
  67. },
  68. //刷新数据
  69. refresh() {
  70. this.loadMore = true;
  71. this.param.pageNum = 1;
  72. this.list = [];
  73. this.getData();
  74. }
  75. },
  76. //下拉刷新
  77. onPullDownRefresh() {
  78. setTimeout(() => {
  79. this.refresh();
  80. uni.stopPullDownRefresh();
  81. }, 1000);
  82. },
  83. //上拉加载
  84. onReachBottom() {
  85. if (this.loadMore) {
  86. this.param.pageNum++;
  87. this.getData();
  88. }
  89. }
  90. };
  91. </script>
  92. <style lang="scss"></style>