<template> <view class="main pt0"> <view class="search"> <u-search placeholder="搜索工作" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/job/search')"></u-search> </view> <view class="tab"> <u-tabs :list="tab" @click="tabClick"></u-tabs> <view class="city" @click="go('/pages/job/position/city')"> <text class="icon"></text> <text>{{ param.cityName || '南宁市' }}</text> </view> <view class="filters" @click="show = true"> <text class="icon"></text> <text>筛选</text> </view> </view> <view class="list"> <job :list="list"></job> <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view> <u-empty v-if="!loadMore && list.length == 0"></u-empty> </view> <filters v-model="show" @confirm="confirm"></filters> </view> </template> <script> export default { data() { return { tab: [ { name: '最新', orderBy: 'id' }, { name: '附近', orderBy: 'distance' } ], list: [], param: { pageNum: 1, pageSize: 10, orderBy: 'id' }, loadMore: true, show: false }; }, onLoad(e) { if (this.getLocation()) { this.param.latitude = this.getLocation().latitude; this.param.longitude = this.getLocation().longitude; } this.param.type = e.type || 0; setTimeout(() => { uni.setNavigationBarTitle({ title: this.param.type == 0 ? '全职' : '兼职' }); }, 300); uni.$on('select_city', (res) => { this.param.cityName = res.title; this.param.regionId = res.id; this.refresh(); }); this.getData(); }, methods: { getData() { this.http.request({ url: '/app/position/list', data: this.param, loading: 'false', success: (res) => { this.loadMore = res.data.pages > this.param.pageNum ? true : false; this.list.push(...res.data.rows); } }); }, tabClick(e) { this.param.orderBy = e.orderBy; this.refresh(); }, confirm(e) { Object.assign(this.param, e); this.refresh(); }, go(url) { uni.navigateTo({ url: url }); }, //刷新数据 refresh() { this.loadMore = true; this.param.pageNum = 1; this.list = []; this.getData(); } }, //下拉刷新 onPullDownRefresh() { setTimeout(() => { this.refresh(); uni.stopPullDownRefresh(); }, 1000); }, //上拉加载 onReachBottom() { if (this.loadMore) { this.param.pageNum++; this.getData(); } } }; </script> <style lang="scss"></style>