<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>
uinapp下拉刷新,更新列表数据
最新推荐文章于 2024-06-20 16:36:13 发布