美文网首页
vant 下拉刷新 上拉加载

vant 下拉刷新 上拉加载

作者: X_y_bfc1 | 来源:发表于2020-09-02 19:29 被阅读0次

<template>
<div class="joblist_cotainer">
<nav-bar :title="t('title.jobListTitle')" :is-left="true" :is-right="true" :icon-name="'search'" @goSearch="goSearch" @goBack="goBack"/> <div class="joblist_cotainer_search"> <div class="joblist_cotainer_tab"> <span v-for="(item, index) in tabTitle" :key="index" :class="{ active: numTime == index }" @click="clickTabTime(index, item.status)"> {{ item.name }} </span> </div> </div> <div class="refresh_box"> <van-pull-refresh v-model="refreshingTime" :loosing-text="t('tipObj.loosing')"
:pulling-text="t('tipObj.pulling')" @refresh="onRefreshTime"> <template #loading> <img class="doge" :src="require('@img/logoicon.png')" /> </template> <van-list v-if="listTimeShow" v-model="loadingTime" :finished="finishedTime" :loading-text="t('recruit.employer.jobList.loading')"
:finished-text="t('recruit.employer.jobList.nomore')" :immediate-check="false" @load="onLoadTime" > <div v-for="(item , index ) in listTime" :key="index" class="joblistItem"> <div :class="{offline:item.status === 0}" @click="goJobDetailsTime(item.id)"> <div class="title"> <h2>{{ item.jobTitle }} </h2> <span class="type">{{ item.status === 1 ?t('recruit.employer.jobList.on') : t('recruit.employer.jobList.off') }}</span> </div> <div class="info"> <p>{{item.unitName}} {{ item.salaryFormat }}/{{item.salaryUnitName}}</p> <p class="tip"> <span v-if="item.workFromHome == 1">{{t('recruit.employer.jobList.workHome')}}</span>
<span v-else>{{item.countyName}}wewqewqewqewqewqwqewqe</span>
<span class="createTime">{{item.createTimeFormat}}</span>
</p>
</div>
</div>
</div>
</van-list>
</van-pull-refresh>
</div>
<div v-if="!listTimeShow" class="company_list">
<img class="no_img" src="@img/nojob.png" alt="">
<p class="no_text">{{t('recruit.employer.jobList.txt')}}</p> </div> <foot-btn :confirm-txt="t('recruit.employer.jobList.postJob')" :isclick="true" @ConfirmClick="ConfirmClick" />
</div>
</template>

<script>
import NavBar from '@/components/common/NavBar'
import FootBtn from '@/components/common/FootBtn'
import PositionApi from '@/api/employer/position'
import { mapGetters } from 'vuex'
export default {
name: 'JobList',
components: {
NavBar,
FootBtn
},
data() {
return {
SearchValue: '',
numTime: 0,
tabNum: 1,
tabTitle: [
{ name: this.t('recruit.employer.jobList.all'), status: null }, { name: this.t('recruit.employer.jobList.on'), status: 1 },
{ name: this.t('recruit.employer.jobList.off'), status: 0 } ], isShow: true, isShowdown: true, statusTime: null, pageNumTime: 0, // 兼职当前页 pageSizeTime: 10, // 兼职一页展示10条 totalNumTime: null, // 总页数兼职 listTime: [], listTimeShow: true, loadingTime: false, // 是否处于加载状态 finishedTime: false, // 是否已加载完成 refreshingTime: false, // 加载完成后的提示文案 overlayShow: false, // 弹出层 from: '' // 从哪来 } }, beforeRouteEnter(to, from, next) { to.query.from = from.name next() }, computed: { ...mapGetters(['isEdit']) }, watch: { 'route'(to, from) {
if (from.path === '/jobtimedetails' && this.isEdit) {
this.reloadPart()
}
}
},
mounted() {
window.createPartTimeJobBack = this.reloadPart
},
created() {
this.from = this.route.query.from || '' this.getListTime() }, methods: { reloadPart() { // 重新加载全职 this.pageNumTime = 0 this.pageSizeTime = 10 this.tabNum = 1 this.listTime = [] this.getListTime() }, goBack() { this.bridge.close('{ "method": "close", "data": "joblist" }')
},
ConfirmClick() { // 兼职
this.emit('closeLay', false) this.bridge.editJobPartTime('{ "method": "editJobPartTime", "data": {"jobId": "" }}')
},
goSearch() { // 跳到原生页面去搜索,从职位列表进入的
this.$bridge.jobSearch('{ "method": "jobSearch" }')
},
clickTabTime(index, status) { // 上线下线兼职
if (index === this.numTime) {
return
}
this.numTime = index
this.pageNumTime = 1
this.statusTime = status
this.getListTime()
},
getListTime() { // 兼职列表
const data = {
currentPage: this.pageNumTime,
pageSize: this.pageSizeTime,
status: this.statusTime
}
PositionApi.getJobByConPartTime(data).then(res => {
if (res.code === 0) {
this.loadingTime = false // 加载状态结束
this.totalNumTime = res.body.total
const records = res.body.records

      if (records === 0 || records === null) {
        // 加载结束
        this.finishedTime = true
        return
      }
      if (records.length < this.pageSizeTime) {
        // 不足10条
        this.finishedTime = true
      }

      // 处理数据
      if (this.pageNumTime === 1) {
        this.listTime = records
      } else {
        this.listTime = this.listTime.concat(records)
        this.listTime = this.$unique(this.listTime)
      }
      if (this.listTime.length >= this.totalNumTime) {
        this.finishedTime = true
      }
      if (this.listTime.length === 0) {
        this.listTimeShow = false
      } else {
        this.listTimeShow = true
      }
    } else {
      this.$toast.fail(res.message)
    }
  }).catch(() => {
    this.$toast.fail(this.$t('tipObj.failed'))
  }).finally(() => {
    this.refreshingTime = false
    this.loadingTime = false
  })
},
onRefreshTime() { // 下拉刷新兼职
  this.pageNumTime = 1
  this.finishedTime = false
  this.getListTime()
},
onLoadTime() { // 上拉加载兼职
  this.pageNumTime++
  this.getListTime()
},
goJobDetailsTime(id) {
  this.$store.dispatch('app/setIsEdit', false)
  this.$router.push({ path: '/jobtimedetails', query: { id: id, from: 'list' }})
}

}
}
</script>
export function unique(newarr) {
const res = new Map()
return newarr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1))
}

<style scoped lang="scss">
.joblist_cotainer_search{
position: fixed;
width: 100%;
top: 46px;
/height: 110px;/
z-index: 20;
}
.job_type_title{
width: 100%;
padding: 0 15px;
height: 48px;
line-height: 48px;
background: colorfff; font-size:20px; color:colorText;
span{
margin-right: 40px;
}
.active {
color: colorInput; font-weight: bold; position: relative; &:after { content: ''; width: 38px; height: 3px; background-color:backgroundColor;
border-radius: 2px;
position: absolute;
bottom: -4px;
left: 50%;
margin-left: -22px;
}
}
}
.refresh_box{
margin-top: 48px;
}
.fade-enter-active, .fade-leave-active {
transition: opacity 3s;
}
.joblist_cotainer {
height: 100vh;
background: #f7f8fb;
display: flex;
flex-direction: column;
.van-search .van-cell {
height: 44px;
line-height: 44px;
border-radius: 8px;
padding: 0 10px 0 0;
}
&_tab {
padding: 0 20px;
font-size: 16px;
color: colorText; height: 42px; line-height: 42px; background: #f7f8fb; span { margin-right: 30px; } .active { color:backgroundColor;
font-weight: bold;
position: relative;
font-size: 18px;
}
}
/deep/ .van-list{
padding-bottom:btnHeight; } &_list { padding: 0 15px; margin-top: 15px; &_every { border: 1px solidcolorF7;
margin-top: 10px;
padding: 10px;
box-sizing: border-box;
color: color666; .title { font-size:font16;
color: color333; font-weight: bold; } .content { font-size:font14;
margin: 5px 0;
}
.tips {
font-size: font12; } } } .newjob { position: fixed; bottom: 35px; @include commonBtn(w: 300px, h: 46px,c: #fff, bg:backgroundColor);
left: 50%;
margin-left: -150px;
}
}
.joblistItem {
background-color: colorfff; padding: 20px 15px 10px 15px; min-height: 97px; font-size:font14;
color: #60666e;
border-bottom: 10px solid #f1f2f4;
.title {
@include flexbox(jc: space-between,ai: flex-start, fd: row); margin-bottom: 10px; h2 { font-size: 18px; color:colorInput;
line-height: 21px;
font-weight: bold;
}
.type {
min-width: 30px;
position: relative;
color: #fff;
display: inline-block;
padding: 2px 6px;
background: #7CBB53;
border-radius: 2px;
}
}
.info{
font-size: font14; color: #60666E; word-break: break-word; p{ margin-top:10px; } .tip{ display: flex; justify-content: space-between; align-items: center; .createTime{ width: 100px; text-align: right; } } } } .offline { color: #CDD2DB; .title { h2 { color: #CDD2DB; } .type { color: #fff; background: #CBCFD9; } } .info { color: #CDD2DB; } } .company_list { padding-top: 130px; height: 70vh; background:colorF7;
.no_img {
display: block;
width: 204px;
height: 172px;
margin: 0 auto;
}

.no_text {
  color: $colorInput;
  font-size: $font16;
  font-weight: bold;
  margin-top: 20px;
  text-align: center;
}

}
</style>