<template>
	<view class="status">
		<!-- header -->
		<cu-custom bgColor="bg-gradual-blue" isBack><view slot="content">设备状态</view></cu-custom>
		<!-- section -->
		<view v-for="(item, index) in value.value" :key="index" class="bg-white  padding-top-sm radius margin-lr margin-top">
			<view class="padding-sm">
				<view class="padding-bottom-sm text-black text-bold ">车辆状态：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">电源是否欠压：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">GPS位置信息：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">视频信息：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">疲劳驾驶：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">驾驶辅助（ADAS）：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">预警信息（DMS）：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">压胎信息：即将上线</view>
				<view class="padding-bottom-sm text-black text-bold ">油耗信息：即将上线</view>
			</view>
		</view>
		<van-empty v-if="value.value.length == 0 && value.no_more" description="暂无设备" />
		<view v-else :class="!value.no_more && value.pageCount <= value.totalPage ? 'cu-load bg-grey loading margin-top' : 'cu-load bg-grey over margin-top'"></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			value: {
				no_more: false, //没有更多
				pageCount: 1,
				totalPage: 1,
				value: []
			}
		};
	},
	onLoad() {
		this.request()
	},
	// 页面上拉触底事件
	onReachBottom: function() {
		this.request();
	},
	methods: {
		async request() {
			var { pageCount, totalPage, no_more, value } = JSON.parse(JSON.stringify(this.value));
			if(pageCount>totalPage) return false;
			var res = await this.$global.request({
				url: '/customer/vehicle/',
				method: 'get',
				header: {
					'Content-Type': 'application/x-www-form-urlencoded',
					Authorization: uni.getStorageSync('token')
				},
				data: { page: pageCount, limit: 20 }
			});
			pageCount++;
			totalPage=res.totalPage;
			if(pageCount>totalPage) no_more=true;
			value=value.concat(res.data);
			this.value={pageCount, totalPage, no_more, value};
		}
	}
};
</script>

<style lang="scss" scoped></style>
