<template>
	<view class="container">
		<view v-if="card[0]['title']['text']==null">
			<view>暂无设备</view>
		</view>
		<view v-else v-for="(item,index) in card" :key="item.id" style="padding-top: 26rpx;" @tap="showDetail(item.id)">
			<tui-card :title="item.title" :tag="item.tag">
				<template v-slot:body>
					<view class="tui-default" style="font-size: 28rpx;">
						最近操作时间：{{item.created_at}}
					</view>
				</template>
				<template v-slot:footer>
					<view class="tui-default">
						{{item.terminal_name}}--{{item.address}}
					</view>
				</template>
			</tui-card>
		</view>
	</view>
</template>

<script>
	import myapp from '@/common/js/myapp.js'
	export default {
		data() {
			return {
				card: []
			}
		},
		onShow: function() {		
			// 检验是否登录
			let user = myapp.checkLogin()
			uni.setStorageSync('lastPagePath', '/packagePage/pages/ctrllist/ctrllist')			
			
			// 获取项目中所有的曝气机
			let that = this;
			// 获取场站基本信息
			myapp.request('/?c=aerator&a=getAllAeratorList',function(res) {
				that.card = res.data.data
				console.info(res.data.data[0]['title']['text'])
			},{token:user.token})
		},
		methods: {
			showDetail: function(index) {
				uni.navigateTo({
					url:'/packagePage/pages/aerator_detail/aerator_detail?id=' + index
				})
			}
		}
	}
</script>

<style>
	@import '../../../static/style/thorui.css';
	
	page {
		background-color: #F5F6FA;
	}	
	
	.textleft, .textright {
		color: #949494;
		font-size: 20rpx;
		margin-bottom: 20rpx;
	}
	.textleft {
		float:left;
	}
	.textright {
		float:right;
	}
	
	.textleftright {
		border-top:3px solid #F5F6FA;
	}
	
	.tui-default {
		padding: 30rpx 10rpx 40rpx 10rpx;
	}
	
	.tui-item-box {
		width: 100%;
		display: flex;
		align-items: center;
		padding-bottom: 20rpx;
		padding-top: 20rpx;
	}
	
	.tui-msg-box {
		display: flex;
		align-items: center;
	}
	
	.tui-msg-item {
		max-width: 500rpx;
		min-height: 80rpx;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	
	.tui-msg-pic {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		display: block;
		margin-right: 24rpx;
		flex-shrink: 0;
	}	
	
	.tui-msg-name {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 32rpx;
		line-height: 1;
		color: #262b3a;
		font-weight: 600;
	}

	.tui-msg-content {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 24rpx;
		line-height: 1;
		color: #9397a4;
	}
	
	.tui-msg-right {
		max-width: 120rpx;
		height: 88rpx;
		margin-left: auto;
		text-align: right;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
		margin-top:30rpx;
		margin-right:30rpx;
	}
	
	.uni-tag--primary {
		background-color:#ADDEFF !important;
		border:none !important;
		color:#000 !important;
	}
	
	.uni-tag--success {
		background-color:#ADFFB5 !important;
		border:none !important;
		color:#000 !important;
	}
	
	.tui-content-box {
		width: 100%;
		height: 44px;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}
	
	.tui-avatar-box {
		width: 30px;
		height: 30px;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 1px solid #eaeef1;
		flex-shrink: 0;
	}
	.tui-avatar {
		width: 28px;
		height: 28px;
		border-radius: 50%;
	}
	
	.tui-search-text {
		padding-left: 10rpx;
	}
	
	.tui-notice-box {
		position: relative;
		flex-shrink: 0;
		font-size: 44rpx;
		color: #fff;
	}
	
	.tui-search-box {
		width: 100%;
		height: 32px;
		margin: 0 0rpx;
		border-radius: 18px;
		font-size: 14px;
		background-color: #f1f1f1;
		padding: 0 12px;
		box-sizing: border-box;
		color: #bfbfbf;
		display: flex;
		align-items: center;
	}
	
	.tui-default {
		padding: 20rpx 20rpx;
	}
</style>
