<template>
	<view class="">
		<view  class="data" v-for="(item, index) in list" :key="index">
			<view class="top">
				<view class="left">
					<view class="title">
						<text>IEMI：{{item.imei}}</text>
						<text @click.stop="copy(item.imei)" style="text-decoration: underline;" class="text-blue padding-left-20">复制</text>
					</view>
				</view>
				<view class="right">
					<view v-if="item.defenseStatus==1" class="radius sm cu-btn line-green">
						已上线
					</view>
					<view v-if="item.defenseStatus==2" class="radius sm cu-btn line-red">
						已下线
					</view>
				</view>
			</view>
			<view class="item">
				<view class="left">
					<view style="padding: 0 30rpx;">
						<view class="content flex">
							<u-icon  size="36" name="http://139.9.103.171:1888/miniofile/xlyq/xiaofangshuang.png"></u-icon>
							<text class="text-bold padding-left-10">设备名称：</text>
							<text>{{item.deviceName}}</text>
						</view>
						<view class="content flex">
							<view class="flex">
								<u-icon  size="36" name="http://139.9.103.171:1888/miniofile/xlyq/dianchi.png"></u-icon>
								<text class="text-bold padding-left-10">电池电量：</text>
							</view>
							<view class="striped active cu-progress round margin-top-sm " style="width: 60%;">
								<view :style="[{ width:loading?item.battery+'%':''}]" style="background-color: #16c60c;color: #FFFFFF;">
									{{item.battery?item.battery:0}}%
								</view>
							</view>
						</view>
						<view class="content flex">
							<view class="flex">
								<u-icon  size="36" name="http://139.9.103.171:1888/miniofile/xlyq/wifi.png"></u-icon>
								<text class="text-bold padding-left-10">信号强弱：</text>
							</view>
							<view class="striped active cu-progress round margin-top-sm " style="width: 60%;">
								<view :style="[{ width:loading?item.signalIntensity+'%':''}]" style="background-color: #fc5f44;color: #FFFFFF;">
									{{item.signalIntensity?item.signalIntensity:0}}%
								</view>
							</view>
						</view>
						<view  class="content flex">
							<u-icon  size="36" name="http://139.9.103.171:1888/miniofile/xlyq/jiance.png"></u-icon>
							<text class="text-bold padding-left-10">监测值：</text>
							<text class="text-bold" v-text="item.monitorValue?item.monitorValue:'未知'" style="color: #1296db;"></text>
						</view>
						<view  class="content flex">
							<u-icon  size="36" name="http://139.9.103.171:1888/miniofile/xlyq/updateTime2.png"></u-icon>
							<text class="text-bold padding-left-10">更新时间：</text>
							<text  v-text="item.lastUpdateTime?item.lastUpdateTime:'未知'"></text>
						</view>
					</view>
				</view>
			</view>
			<view class="bottom flex" >
				<view @click="goDetail(item)" class="cu-btn  sm round line-blue" >
					查看详情
				</view>
				<view @click="goAlarm(item)" class="cu-btn  sm round line-blue" style="margin: 0 20rpx;">
					告警记录
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'card',
	props:{
		list:{
			type:Array,
			default:()=>{
				[]
			}
		}
	},
	data() {
		return {
			loading:false
		};
	},
	created() {
		let that = this;
		setTimeout(function() {
			that.loading = true
		}, 500)
	},
	methods:{
		copy(data){
			uni.setClipboardData({
				data:data
			})
		},
		goDetail(item){
			getApp().globalData.fireHydrantDetail=item
			uni.navigateTo({
				url:'/pages/index/fire/detail'
			})
		},
		goAlarm(item){
			uni.navigateTo({
				url:"/pages/index/fire/alarm-record?imei="+item.imei
			})
		}
	}
};
</script>

<style lang="scss">
.data {
	width: 710rpx;
	background-color: #ffffff;
	margin: 20rpx auto;
	border-radius: 6rpx;
	box-sizing: border-box;
	padding: 20rpx 10rpx;
	font-size: 28rpx;
	.top {
		display: flex;
		justify-content: space-between;
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid $dt-border-color-sm;
		.left {
			display: flex;
			align-items: center;
			.title {
				margin: 0 10rpx;
				font-size: 30rpx;
			}
		}
		.right{
			margin-right: 10rpx;
		}
	}
	.item {
		margin: 5rpx 0 20rpx 0;
		.content {
			border-bottom: 1rpx dashed #DDDDDD;
			padding: 30rpx 0;
		}
	}
	.bottom {
		display: flex;
		margin-top: 30rpx;
		justify-content: flex-end;
		align-items: center;
	}
}
</style>