list.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. setTimeout(() => {
  42. uni.setNavigationBarTitle({ title: this.param.type == 0 ? '全职' : '兼职' });
  43. }, 300);
  44. this.getData();
  45. },
  46. methods: {
  47. getData() {
  48. this.http.request({
  49. url: '/app/position/list',
  50. data: this.param,
  51. loading: 'false',
  52. success: (res) => {
  53. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  54. this.list.push(...res.data.rows);
  55. }
  56. });
  57. },
  58. tabClick(e) {
  59. this.param.orderBy = e.orderBy;
  60. this.refresh();
  61. },
  62. confirm(e) {
  63. Object.assign(this.param, e);
  64. this.refresh();
  65. },
  66. go(url) {
  67. uni.navigateTo({ url: url });
  68. },
  69. //刷新数据
  70. refresh() {
  71. this.loadMore = true;
  72. this.param.pageNum = 1;
  73. this.list = [];
  74. this.getData();
  75. }
  76. },
  77. //下拉刷新
  78. onPullDownRefresh() {
  79. setTimeout(() => {
  80. this.refresh();
  81. uni.stopPullDownRefresh();
  82. }, 1000);
  83. },
  84. //上拉加载
  85. onReachBottom() {
  86. if (this.loadMore) {
  87. this.param.pageNum++;
  88. this.getData();
  89. }
  90. }
  91. };
  92. </script>
  93. <style lang="scss"></style>