list.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view class="main pt0">
  3. <view class="search">
  4. <view class="usearch">
  5. <u-search placeholder="搜索工作" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/job/search?type=' + param.type)"></u-search>
  6. </view>
  7. <view class="address omit" @click="go('/pages/job/position/city')">
  8. <text class="icon">&#xe64b;</text>
  9. <text>{{ param.cityName || '南宁市' }}</text>
  10. </view>
  11. </view>
  12. <view class="tab">
  13. <u-tabs :list="tab" :inactiveStyle="{ fontSize: '16px' }" :lineHeight="5" :activeStyle="{ color: '#3c9cff', fontSize: '16px' }" :current="current" @click="tabClick"></u-tabs>
  14. <view class="filters" @click="show = true" v-if="param.type == 0">
  15. <text class="icon">&#xe68c;</text>
  16. <text>筛选</text>
  17. </view>
  18. </view>
  19. <view class="list">
  20. <job :list="list"></job>
  21. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  22. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  23. </view>
  24. <filters v-model="show" @confirm="confirm"></filters>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. tab: [
  32. { name: '最新', orderBy: 'id', recommend: '' },
  33. { name: '推荐', orderBy: 'id', recommend: 1 },
  34. { name: '附近', orderBy: 'distance', recommend: '' }
  35. ],
  36. current: 0,
  37. list: [],
  38. param: { pageNum: 1, pageSize: 10, orderBy: 'id' },
  39. loadMore: true,
  40. show: false
  41. };
  42. },
  43. onLoad(e) {
  44. if (this.getLocation()) {
  45. this.param.latitude = this.getLocation().latitude;
  46. this.param.longitude = this.getLocation().longitude;
  47. }
  48. this.param.type = e.type || 0;
  49. this.current = e.current || 0;
  50. this.param.orderBy = this.tab[this.current].orderBy;
  51. setTimeout(() => {
  52. uni.setNavigationBarTitle({ title: this.param.type == 0 ? '全职岗位' : '兼职岗位' });
  53. }, 300);
  54. uni.$on('select_city', (res) => {
  55. this.param.cityName = res.title;
  56. this.param.regionId = res.id;
  57. this.refresh();
  58. });
  59. this.getData();
  60. },
  61. methods: {
  62. getData() {
  63. this.http.request({
  64. url: '/app/position/list',
  65. data: this.param,
  66. loading: 'false',
  67. success: (res) => {
  68. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  69. this.list.push(...res.data.rows);
  70. }
  71. });
  72. },
  73. tabClick(e) {
  74. this.param.orderBy = e.orderBy;
  75. this.param.recommend = e.recommend;
  76. this.refresh();
  77. },
  78. confirm(e) {
  79. Object.assign(this.param, e);
  80. this.refresh();
  81. },
  82. go(url) {
  83. uni.navigateTo({ url: url });
  84. },
  85. //刷新数据
  86. refresh() {
  87. this.loadMore = true;
  88. this.param.pageNum = 1;
  89. this.list = [];
  90. this.getData();
  91. }
  92. },
  93. //下拉刷新
  94. onPullDownRefresh() {
  95. setTimeout(() => {
  96. this.refresh();
  97. uni.stopPullDownRefresh();
  98. }, 1000);
  99. },
  100. //上拉加载
  101. onReachBottom() {
  102. if (this.loadMore) {
  103. this.param.pageNum++;
  104. this.getData();
  105. }
  106. }
  107. };
  108. </script>
  109. <style lang="scss"></style>