list.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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="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, 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.param.type = e.type || 0;
  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. Object.assign(this.param,e);
  61. this.refresh();
  62. },
  63. go(url) {
  64. uni.navigateTo({ url: url });
  65. },
  66. //刷新数据
  67. refresh() {
  68. this.loadMore = true;
  69. this.param.pageNum = 1;
  70. this.list = [];
  71. this.getData();
  72. }
  73. },
  74. //下拉刷新
  75. onPullDownRefresh() {
  76. setTimeout(() => {
  77. this.refresh();
  78. uni.stopPullDownRefresh();
  79. }, 1000);
  80. },
  81. //上拉加载
  82. onReachBottom() {
  83. if (this.loadMore) {
  84. this.param.pageNum++;
  85. this.getData();
  86. }
  87. }
  88. };
  89. </script>
  90. <style lang="scss"></style>