<template>

	<view class="">
		<view class="cu-list menu-avatar">
			<view class="cu-item deviceTypeItem" v-for="(item,index) in deviceType" :key="index" @tap="goDeviceType(item)">
				<view class="cu-avatar round" >
					<image class="image-bg" :src=item.imgUrl />
				</view>
				<view class="content">
					<view class="title">{{item.title}}</view>
				</view>
				<view class="nav-right num">
					<view>
						共{{item.num}}个设备
						<text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
					</view>
				</view>
			</view>


		</view>
	</view>
</template>

<script>
	import json from '../../data/json.js';
	export default {
		data() {
			return {
				deviceType: json.deviceType,
				getData:{}
			};
		},
		onLoad: function(option) {
			this.getDeviceData({'company_code':uni.getStorageSync('selectedCode')})
		},

		methods: {
			goDeviceType(item) {
				uni.navigateTo({
					url: '/pages/device-Manage/device-Manage?dwtype='+item.dwtype,
				});
			},
			
			// 设备类型数据请求
			async getDeviceData(params = {}) {
				const res = await this.$myRequest({
					url: 'DeviceManagement/getDeviceCount',
					data:params,
					showLoading: true
				})
				
				this.getData=res.data.data[0];
				console.log(this.getData);
				this.deviceType[0].num=this.getData.pass_on_device_count;
				this.deviceType[1].num=this.getData.water_meter_device_count
				this.deviceType[2].num=this.getData.electrical_fire_device_count
				this.deviceType[3].num=this.getData.rtu_device_count
				
				this.deviceType[4].num=this.getData.smoke_sensation_device_count  //烟感
				this.deviceType[5].num=this.getData.video_device_count  //视频
				this.deviceType[6].num=this.getData.elevator_device_count   //电梯
				this.deviceType[7].num=this.getData.manhole_cover_device_count  //井盖
				
				this.deviceType[8].num=this.getData.fire_hydrant_device_count  //消防栓
				this.deviceType[9].num=this.getData.level_device_count  //液位
				// this.deviceType[10].num=this.getData.geomagnetism_device_count
				// this.deviceType[11].num=this.getData.access_control_device_count
				// this.deviceType[12].num=this.getData.gsa_device_count
				
			},

		}

	}
</script>

<style lang="scss">

</style>
