<template>
	<view class="towerManage">
		<levitatedsphere :x="100" :y="80"></levitatedsphere>
		<headers :showBack="true">
			<view class="headerName">
				项目塔吊
			</view>
		</headers>
		<view class="">
			<!-- <image src="../../../static/bg1.png"></image> -->
			<view>

			</view>
		</view>
		<view class="item_list">
			<view class="item" v-if="listData.length>0" v-for="(item,index) in listData" :key="index" @click="goDetails(item)">
				<view class="item_title flex2">
					<text class="name">{{item.devName}}</text>
					<text class="state1" v-if="item.devonline==1">在线</text>
					<text class="state2" v-else>离线</text>
				</view>
				<view class="type">塔机臂长：{{item.forearmLength}}米</view>
				<view class="type flex"><text>塔机编号：</text><view style="width:75%; word-wrap: break-word; line-height: initial;">{{item.devSn}}</view></view>
				<view class="type">最后数据时间：{{timestampToTime(item.realTime,'time')}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { timestampToTime } from '../../../static/js/util.js'
	export default {
		data() {
			return {
			projectSn:'',
			listData:[],
			timestampToTime: timestampToTime
			}
		},
		onLoad(){
			this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
			this.getListData();
		},
		methods: {
			//获取列表数据
			getListData(){
				this.sendRequest({
					url:'xmgl/tower/list',
					method:"post",
					data:{
						projectSn:this.projectSn
					},
					success:res=>{
						if(res.code==200){
							this.listData = res.result
						}
					}
				})
			},
			
			//详情
			goDetails(val){
				uni.navigateTo({
					url:'./towerDetails?devSn='+val.devSn+'&id='+val.id+'&forearmLength='+val.forearmLength+'&towerHeight='+val.towerHeight
				})
			}
		}
	}
</script>

<style>
	.flex {
		display: flex;
		align-items: center;
	}

	.flex2 {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.item_list {
		width: 100%;
		padding: 10px 30rpx;
		box-sizing: border-box;
	}

	.item_list .item {
		width: 100%;
		padding: 12px 30rpx;
		box-sizing: border-box;
		box-shadow: 0px 0px 10px #dedede;
		border-radius: 5px;
		font-size: 30rpx;
		margin-bottom: 15px;
	}

	.item_title {
		padding: 0px 0px 8px;
		border-bottom: 1px solid #DEDEDE;
		margin-bottom: 5px;
	}

	.item .state1 {
		color: #fff;
		padding: 4px 12px;
		font-size: 24rpx;
		background-color: #06c232;
		border-radius: 30px;
		
	}
	
	.item .state2 {
		color: #fff;
		padding: 4px 12px;
		font-size: 24rpx;
		background-color: #999;
		border-radius: 30px;
		
	}

	.item_title .name {
		font-weight: 700;
	}

	.type {
		line-height: 28px;
		color: #999;
		font-size: 28rpx;
	}

	
</style>
