vant上拉加载下拉刷新

<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
	<van-list v-model="loading" :finished="finished" finished-text="没有更多了!" @load="onLoad">
		 <div class="clockBox2" v-for="(item,index) in filterDetail" :key="index"></div>
	</van-list>
</van-pull-refresh>   
<van-popup v-model="popupShow" position="top">
    <div class="search_form">
        <van-form ref="clockForm" alidate-first @submit="onSubmit">
            <van-field
                style="border-style: solid;border-color:#D5D5D5;border-width:1px;margin-top:10px"
                readonly
                clickable
                is-link
                required
                v-model="orgName"
                name="orgName"
                label="机构:"
                placeholder="请选择机构"
                @click="chooseOrgan"
                :rules="[{ required: true, message: '请选择机构' }]"
            />
             <van-field
                style="border-style: solid;border-color:#D5D5D5;border-width:1px;margin-top:10px"
                readonly
                clickable
                required
                is-link
                v-model="managerName"
                name="managerName"
                label="客户经理:"
                placeholder="请选择客户经理"
                @click="chooseManager"
                :rules="[{ required: true, message: '请选择客户经理' }]"
            />
        </van-form>
        <div class="searchBtn">
            <van-button  block type="info" @click="toSearch">查询</van-button>
            <van-button  type="info" @click="toClear">清空</van-button>
        </div>
    </div>
</van-popup>
export default {
    data() {
        return {
            refreshing:false,
            finished: false,
            loading: false,
            popupShow:false,
            pIndex:0,
            filterDetail:[]
        }
    },
    mounted() {
    
    },
    methods: {
    	//刷新
        onRefresh() {
            this.pIndex = 1;
            this.finished = false;
            this.loading = true;
            this.getData();//获取列表数据
        },
        //自动加载更多
        onLoad() {
            console.log("xxxxxx666666xxxxxxxx",this.finished,this.loading,this.refreshing)
            this.pIndex += 1;
            if (this.refreshing) {
                this.filterDetail = [];
                this.refreshing = false;
            }
            this.getData()
        },
         toSearch(){
          	this.popupShow = false;
            this.pIndex = 1;
            this.filterDetail = [];
            this.getData();

            this.finished = false;
            this.loading = true;
        },
        //重置
        toClear() {
            this.popupShow = false;
            this.orgName = "";
            this.managerName = "";
            this.filterDetail = [];
            this.managerColumns = [];//清空客户经理列表
            this.pIndex = 1;
            this.getData();

            this.finished = false;
            this.loading = true;
        },
        getData(){
            if(this.finished){
                this.finished = false;
                this.loading = true;
            }
            const toast = this.$toast.loading({
                duration: 0,
                message: '加载中...',
                forbidClick: true,
                loadingType: 'spinner',
            });
            var params = Object.assign(
                {userId:this.userIdSelect},
                {date:this.dateTime},
                {orgId:this.orgIdParam},
                {pidx:this.pIndex},
                {psize:10}
            )
            console.log("params====",params)
            searchLocationTracking(params).then(res => {
                toast.clear()
                let num = res.data.data.data.total;
                let list = res.data.data.data["locationTracking"];
                if (this.refreshing) {
                    this.filterDetail = [];
                    this.refreshing = false;
                }
                for (let i in list) {
                    this.filterDetail.push(list[i]);
                }
                this.loading = false;
                console.log(this.filterDetail)
                console.log(this.filterDetail.length,num)
                if (this.filterDetail.length >= num) {
                    this.finished = true;
                }
                console.log("this.finished-----------",this.finished,this.loading,this.refreshing)
            })
        },
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值