uinapp下拉刷新,更新列表数据

<template>
	<view class="index_container">
		<view class="index_search_con">
			<uni-search-bar v-model="condition" :radius="100" placeholder="车牌号/车辆VIN" cancelButton="none"
				@input="input">
			</uni-search-bar>
		</view>
		<view class="index_list_con">
			<uni-list-item v-for="(item,i) in gpsCarList" :key="i" @click="goDetails(item)">
				<view slot="body" class="slot-box slot-text" @tap="goDetails(item)">
					<view class="index_list_header">
						<view class="index_list_header_l">{{item.brand != '' ? item.brand : '未知'}}</view>
						<view class="index_list_header_r">{{item.presentPlateNo != '' ? item.presentPlateNo : '暂无车牌'}}</view>
					</view>
					<view class="index_list_body">
						<view class="index_list_body_l">车辆VIN:</view>
						<view class="index_list_body_r">{{item.vin != '' ? item.vin : '暂无车辆VIN'}}</view>
					</view>
					<view class="index_list_footer">
						<view class="index_list_footer_l">创建时间:</view>
						<view class="index_list_footer_r">{{item.createDate != '' ? item.createDate : '暂无创建时间'}}</view>
					</view>
				</view>
			</uni-list-item>
			<uni-load-more :status="loadStatus" :contentText="contentText"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import wxLoginVue from '../../components/wxLogin/wxLogin.vue';
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				gpsCarList: [], //GPS绑定数据列表
				loadStatus: 'more',
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				userInfo:{},
			};
		},
		onLoad() {
			this.userInfo = uni.getStorageSync("users");
			this.getGpsJobList();
		},
		/**
		 * 下拉刷新
		 */
		onPullDownRefresh() {
			this.page = 1;
			this.loadStatus = 'loading';
			// this.gpsCarList = [];
			this.getGpsJobList();
		},
		onReachBottom() {
			this.loadStatus = 'loading';
			this.getGpsJobList();
		},
		methods: {
			goDetails(item) {
				let _this = this;
				uni.navigateTo({
					url: '/pages/my/gpsBindJobDetails?checkSupplierClerkId='+                 _this.userInfo.id + '&id=' + item.id
				});
			},
			//获取小程序GPS任务列表
			getGpsJobList() {
				let _this = this;
				let params = {
					limit: _this.limit,
					page: _this.page,
				};
				_this.$http({
					url: `/check/api/gps/getGpsTaskPage`,
					method: 'GET'
				}, params).then((res) => {
						if (res.data.code !== 0) {
							return uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 3000
							})
						}
						// console.log(res);
						if (res.data.data.list.length !== 0) {
							let gpsCarList = res.data.data.list;
							let gpsCarList2 = _this.gpsCarList.concat(gpsCarList);
							_this.gpsCarList = _this.deWeightThree(gpsCarList2);
							_this.page++;
							_this.loadStatus = 'more';
						} else {
							_this.loadStatus = 'noMore';
						}
					},
					error => {
						console.log('网络请求错误,请稍后重试!');
						return;
					}
				);
			},
             //这一步就是往原数组加数据
			deWeightThree(gpsCarList2) {
				let map = new Map();
				for (let item of gpsCarList2) {
					if (!map.has(item.id)) {
						map.set(item.id, item);
					}
				}
				return [...map.values()];
			},
		}
	}
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值