<template>
	<view class="">
		<view class="tit">
			<view class="">
				监管详情
			</view>
			<view class="">
				<view class="updata-btn">
					查看全部监管记录<u--image src="/static/img/CKGD.png" style="margin-left: 5rpx;" width="28.04rpx"
						height="28.04rpx"></u--image>
				</view>
			</view>
		</view>
		<view class="card">
			<view class="card-tit">
				<view class="">
					1号土地
				</view>
				<view class="">
					溯源码: 123148
				</view>
			</view>
			<view class="card-li">
				<view class="">
					当前种植: 土豆
				</view>
				<view class="">
					标志品种: 土豆大煞风景
				</view>
			</view>
			<view class="card-li">
				<view class="select">
					监管状况: <up-input readonly placeholder="请选择" style="margin-top: 20rpx;width: 600rpx;"
						border="surround" @click.capture="selectFoucsFn" @blur="selectAct=false" v-model="value">
					</up-input>
					<view class="JT" :class="{actJT:selectAct}">
						<u--image src="/static/img/XLJT.png" width="24.53rpx" height="24.53rpx"></u--image>
					</view>
					<view class="selectvalue" v-show="selectAct">
						<view class="select-li" v-for="(item,index) in selectList" :key="index"
							@click="changSelectfn(index)" :style="{color:indexs==index?'black':'#B3B3B3'}">
							{{item}}
							<view class="" v-show='indexs==index'>
								<u--image src="/static/img/XLZZ.png" width="24.53rpx" height="24.53rpx"></u--image>
							</view>
						</view>
					</view>
				</view>

			</view>
			<view>
				<view class="">
					监管图片
				</view>
				<view class="code-img">
					<view class="carime-icon" @click="updateImgFn">
						<u--image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u--image>
						<view class="">
							点击上传图片
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		reactive,
		ref
	} from "vue"


	const selectList = reactive([
		"正常", "未及时更新生产状况", "生产状况与实际不符"
	])

	const value = ref("")
	const selectAct = ref(false)
	const selectAct1 = ref(false)
	const selectFoucsFn = (e) => {
		selectAct.value = true
	}
	const indexs = ref(0)
	const changSelectfn = (index) => {
		indexs.value = index
		value.value = selectList[index]
		selectAct.value = false
	}
	const updateImgFn = () => {
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'],
			sourceType: ['album'],
			success: (res) => {
				console.log('chooseImage success, temp path is', res.tempFilePaths[0])
				var imageSrc = res.tempFilePaths[0]
				uni.showLoading({
					title: '上传中'
				})
				this.task = uni.uploadFile({
					url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例，非真实的接口地址
					filePath: imageSrc,
					name: 'file',
					formData: {
						'user': 'test'
					},
					success: (res) => {
						if (this.pageVisible) {
							console.log('uploadImage success, res is:', res)
							uni.hideLoading();
							uni.showToast({
								title: '上传成功',
								icon: 'success',
								duration: 1000
							})
							this.imageSrc = imageSrc
						}
					},
					fail: (err) => {
						if (this.pageVisible) {
							console.log('uploadImage fail', err);
							uni.hideLoading();
							uni.showModal({
								content: err.errMsg,
								showCancel: false
							});
						}
					},
				});
			},
			fail: (err) => {
				console.log('chooseImage fail', err)
			}
		})
	}
</script>

<style lang='scss' scoped>
	.tit {
		display: flex;
		justify-content: space-between;
		margin: 20rpx;
	}

	.updata-btn {
		display: flex;
		align-items: center;
	}

	.card-tit {
		display: flex;
		justify-content: space-between;
		border-bottom: 1px solid #F4F4F4;
		padding-bottom: 20rpx;
	}

	.card-li {
		margin: 20rpx 0;
		display: flex;
		justify-content: space-between;
	}

	.select {

		position: relative;

		.JT {
			position: absolute;
			right: 20rpx;
			top: 60%;
			z-index: 9999;
			transition: .2s;
		}

		.actJT {
			transition: .2s;
			transform: rotate(180deg);
		}



		.selectvalue {
			position: absolute;
			width: 608.53rpx;
			background-color: white;
			z-index: 99;
			font-size: 26.29rpx;
			left: 0rpx;
			bottom: -200rpx;
			border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
			padding: 0 20rpx;
			border: 1px solid #F4F4F4;

			.select-li {
				margin: 20rpx 0;
				display: flex;
				justify-content: space-between;
				align-items: center;

			}
		}
	}

	.code-img {
		margin-top: 20rpx;
		background-color: #F4F4F4;
		height: 196.26rpx;
		position: relative;

		.carime-icon {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			display: flex;
			flex-direction: column;
			align-items: center;
		}

	}
</style>