<template>
	<view>
		<view class="top">
			<image src="./icon/top.png" mode="widthFix"></image>
		</view>

		<view class="total">
			<view class="title">分站总数</view>
			<view class="num">
				<text>{{total}}</text>个
			</view>
		</view>

		<view class="section">
			<view class="title">
				<view class="line"></view>
				<view class="text">分站信息列表</view>
			</view>
			<view class="table">
				<uni-table emptyText="暂无更多数据">
					<uni-tr>
						<uni-th align="center">编号</uni-th>
						<uni-th align="center">状态</uni-th>
					</uni-tr>
					<uni-tr v-for="(item,index) in table" :key="index">
						<uni-td style="text-align: center;vertical-align: middle;">{{item.site_num}}</uni-td>
						<uni-td style="text-align: center;vertical-align: middle;">
							<view class="state">
								<image src="./icon/icon_1.png" mode="widthFix" v-if="item.site_status == '通讯正常'"></image>
								<image src="./icon/icon_2.png" mode="widthFix" v-if="item.site_status == '通迅故障'"></image>
								<text>{{item.site_status}}</text>
							</view>
						</uni-td>
					</uni-tr>
				</uni-table>
			</view>
		</view>
	</view>
</template>

<script>
	import "@/common/time.js"
	export default {
		data() {
			return {
				total: 0,
				single: "",

				chartData_1: {},
				chartData_2: {},

				table: [],
				opts_1: {
					color: ["#FF7C7C", "#FCC524"],
					legend: {},
					extra: {
						column: {
							width: 15,
						}
					}
				},
				opts_2: {
					color: ["#00A1E9"],
					legend: {
						show: false
					},
					extra: {
						column: {
							width: 25,
						}
					}
				}
			};
		},
		onLoad() {
			console.log()
			// 获取今天的日期
			this.single = new Date().format("yyyy-MM-dd");

			this.getServerData()
		},
		methods: {
			getServerData() {
				setTimeout(() => {
					uni.showLoading({
						mask: true
					})
					this.$api.getSiteCurrInfoList({
						mine_code: "zaoquan",
					}).then((res) => {
						uni.hideLoading()
						console.log(res)
						this.total = res.data.total
						this.table = res.data.list
					})
				}, 10);
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F5F6F8;
	}

	.top {
		margin-top: -60rpx;

		image {
			width: 750rpx;
		}
	}

	.total {
		position: relative;
		z-index: 1;
		margin: -200rpx auto 60rpx;
		width: 440rpx;
		height: 80rpx;
		background: rgba(0, 161, 233, 0.3);
		border: 2rpx solid #FFFFFF;
		border-radius: 40px;

		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: 700;
		color: #fff;

		.title {
			margin-right: 20rpx;
		}

		.num {
			text {
				font-size: 42rpx;
			}
		}
	}

	.section {
		position: relative;
		z-index: 1;
		margin: 0rpx auto 30rpx;
		width: 680rpx;
		min-height: 400rpx;
		background: #FFFFFF;
		border-radius: 30rpx;
		box-sizing: border-box;
		padding: 20rpx;
		box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
		
		.title {
			height: 60rpx;
			line-height: 60rpx;
			font-size: 30rpx;
			font-weight: 700;
			display: flex;
			align-items: center;

			.line {
				width: 8rpx;
				height: 30rpx;
				background-color: #00A1E9;
				border-radius: 20rpx;
				margin-right: 10rpx;
			}

			.text {}
		}

		.table {
			margin: 20rpx 0;

			.state{
				display: flex;
				align-items: center;
				justify-content: center;
				image{
					margin-right: 10rpx;
					width: 34rpx;
					height: 34rpx;
				}
			}
			/deep/.uni-table-tr {
				background-color: #F2FAFE;
			}

			/deep/.uni-table-th {
				border: none;
				background-color: #fff;
			}

			/deep/.uni-table-td {
				color: #000;
				font-size: 28rpx;
				font-weight: 700;
				padding: 30rpx 0;
				border-bottom: 8rpx solid #fff;
			}

			/deep/.table--border {
				border: none;
			}
		}
	}
</style>