list.vue 2.2 KB

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