<template>
	<view>
		<view style="position: fixed;z-index: 100;">
			<uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="病虫害识别"></uni-nav-bar>
		</view>
		<image :src="path" mode="" class="image"></image>
		<view class="recognition" v-if="datasTF">
			<p class="recognition_title">{{name}}</p>
			<view class="recognition_img">
				<image :src="path2" mode=""></image>
			</view>
			<button class="recognition_details" v-if="tishi" @click="">查看详情</button>
		</view>
		<view class="datas" v-else>
			<p>{{prevention}}</p>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				path: "",
				path2:"",
				tishi: true,
				name:"",
				prevention:"",
				datasTF:true
			}
		},
		methods: {
			clickLeft() {
				uni.switchTab({
					url: "../index/index"
				})
			},
			examine(){
				this.datasTF = false
			}
		},
		onLoad(option) {
			this.path = option.path
			console.log(JSON.parse(option.datas).img_urls, option.path)
			if (JSON.parse(option.datas).img_urls== undefined ) {
				this.name = "识别失败，请换张图片"
				this.tishi = false
			} else {
				this.path2 = JSON.parse(option.datas).img_urls
				this.name = JSON.parse(option.datas).name
				this.tishi = true
				this.prevention =  JSON.parse(option.datas).prevention
			}

		}
	}
</script>

<style lang="scss">
	.image {
		position: absolute;
		top: 44px;
		width: 100%;
		height: 400rpx;
	}

	.recognition {
		position: absolute;
		top: 244px;
		width: 100%;
		height: 800rpx;

		.recognition_title {
			width: 100%;
			text-align: center;
			font-size: 36rpx;
			font-weight: 700;
			margin: 60rpx 0;
		}

		.recognition_img {
			border: 2rpx dashed #06B535;
			width: 450rpx;
			height: 450rpx;
			border-radius: 50%;
			margin: 0 auto;
			text-align: center;
			line-height: 450rpx;

			image {
				margin-top: 10rpx;
				width: 430rpx;
				height: 430rpx;
			}
		}

		.recognition_details {
			width: 400rpx;
			height: 80rpx;
			border-radius: 40rpx;
			margin: 30rpx auto;
			font-size: 30rpx;
			background-color: #67B25F;
			color: #FFFFFF;
		}
	}
	.datas{
		position: absolute;
		top: 244px;
		width: 90%;
		left: 5%;
		padding: 20rpx;
	}
</style>
