<template>
	<view class="container">
		<uNavBar dark :fixed="true" backgroundColor="#3F9EFF" status-bar left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view style="width: 100%;display: flex;flex-direction: row;justify-content: center;align-items: center;">
				<text style="color: white;font-size: 1rem;">{{title}}</text>
			</view>
		</uNavBar>
		<view>
			<uSection title="">
				<uni-table ref="table" :loading="loading" border stripe type="" emptyText="暂无更多数据">
					<uni-tr>
						<uni-th width="240" align="center">含水量</uni-th>
						<uni-th align="center">数值</uni-th>
					</uni-tr>
					<uni-tr v-for="(item,index) in tableData" :key="index">
						<uni-td>
							<view style="text-align: center;">{{ item.name }}</view>
						</uni-td>
						<uni-td align="center">
							<view style="text-align: center;color: coral;">{{ item.value }}</view>
						</uni-td>
					</uni-tr>
				</uni-table>
			</uSection>
		</view>
	</view>
</template>

<script>
	import uSearchBar from '@/uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.vue'
	import uNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
	import uDataPicker from '@/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue'
	import uGroup from '@/uni_modules/uni-group/uni-group.vue'
	import uSection from '@/uni_modules/uni-section/uni-section.vue'
	import uniTable from '@/uni_modules/uni-table/components/uni-table/uni-table.vue'
	import uPagination from '@/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue'
	import uBreadcrumb from '@/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue'
	import http from '@/http/api.js';

	export default {
		components: {
			uSearchBar,
			uDataPicker,
			uGroup,
			uSection,
			uniTable,
			uPagination,
			uBreadcrumb,
			uNavBar,
		},
		onLoad(option) {
			this.selectedIndexs = [];
			this.id = option.id;
			this.getData();
		},
		data() {
			return {
				id: '',
				title: '墒情详情',
				desc: '',
				tableData: [],
				// 每页数据量
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
				loading: false,
				selectedIndexs: [],
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			},
		},
		onShow() {},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 获取数据
			getData() {
				this.loading = true
				var formData = {};
				formData['id'] = this.id;
				var that = this;
				http.request({
					url: '/galaxy-test/rtu/data/ground/detail',
					method: 'GET',
					data: formData,
				}).then(res => {
					if (res.data != null) {
						var values = [];
						var v1 = {
							'name': '垂线平均含水量',
							'value': res.data.vtavslm
						};
						values.push(v1);
						var v2 = {
							'name': '表层含水量',
							'value': res.data.srlslm
						};
						values.push(v2);
						var slm10 = {
							'name': '10CM深度含水量',
							'value': res.data.slm10
						};
						values.push(slm10);
						var slm20 = {
							'name': '20CM深度含水量',
							'value': res.data.slm20
						};
						values.push(slm20);
						var slm30 = {
							'name': '30CM深度含水量',
							'value': res.data.slm30
						};
						values.push(slm30);
						var slm40 = {
							'name': '40CM深度含水量',
							'value': res.data.slm40
						};
						values.push(slm40);
						var slm60 = {
							'name': '60CM深度含水量',
							'value': res.data.slm60
						};
						values.push(slm60);
						var slm80 = {
							'name': '80CM深度含水量',
							'value': res.data.slm80
						};
						values.push(slm80);
						var slm100 = {
							'name': '100CM深度含水量',
							'value': res.data.slm100
						};
						values.push(slm100);
						that.tableData = values;
						that.total = values.length;

						console.log('data', values);
					}
					this.loading = false
				}).catch(err => {
					console.log(err)
					this.loading = false
				})
			},
		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>
	.container {
		background-color: #f7f7f7;
		min-height: 100vh;
		overflow: hidden;
	}


	.goods-carts {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		position: absolute;
		left: 0;
		right: 0;
		/* #ifdef H5 */
		left: var(--window-left);
		right: var(--window-right);
		/* #endif */
		top: 0;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		margin-left: 10px;
	}

	.u-cell-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}

	.slot-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
	}

	.slot-image {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		margin-right: 10px;
		width: 30px;
		height: 30px;
	}

	.slot-text {
		flex: 1;
		font-size: 14px;
		color: #4cd964;
		margin-right: 10px;
	}

	.content-box {
		flex: 1;
		/* #ifdef APP-NVUE */
		justify-content: center;
		/* #endif */
		height: 100%;
		line-height: 44px;
		padding: 0 15px;
		position: relative;
		background-color: #fff;
		border-bottom-color: #f5f5f5;
		border-bottom-width: 1px;
		border-bottom-style: solid;
	}

	.content-text {
		font-size: 15px;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		padding: 10px 0;
		background-color: #fff;
	}

	.button {
		border-color: #e5e5e5;
		border-style: solid;
		border-width: 1px;
		padding: 4px 8px;
		border-radius: 4px;
	}

	.button-text {
		font-size: 15px;
	}

	.slot-button {
		/* #ifndef APP-NVUE */
		display: flex;
		height: 100%;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		padding: 0 20px;
		background-color: #ff5a5f;
	}

	.slot-button-text {
		color: #ffffff;
		font-size: 14px;
	}

	.search-result {
		padding-top: 10px;
		padding-bottom: 20px;
		text-align: center;
	}

	.search-result-text {
		text-align: center;
		font-size: 14px;
		color: #666;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 0px;
	}

	.uni-mt-10 {
		margin-top: 10px;
	}

	.uni-group {
		display: flex;
		align-items: center;
	}

	.data-pickerview {
		height: 400px;
		border: 1px #e5e5e5 solid;
	}

	.popper__arrow {
		top: -6px;
		left: 50%;
		margin-right: 3px;
		border-top-width: 0;
		border-bottom-color: #EBEEF5;
	}

	.popper__arrow {
		top: -6px;
		left: 50%;
		margin-right: 3px;
		border-top-width: 0;
		border-bottom-color: #EBEEF5;
	}
</style>
