<template>
	<view class="content">
		<view class="title">
			疫苗相关信息
		</view>
		<view class="card">
			<view class="card-li">
				<view class="card-li-tit">
					疫苗名称
				</view>
				<view class="">
					<up-input placeholder="请输入品种" border="surround" v-model="value" @change="change"></up-input>
				</view>
			</view>
			<view class="card-li">
				<view class="card-li-tit">
					疫苗品牌
				</view>
				<view class="">
					<up-input placeholder="请输入品种" border="surround" v-model="value" @change="change"></up-input>
				</view>
			</view>
			<view class="card-li">
				<view class="card-li-tit">
					操作人员
				</view>
				<view class="">
					<up-input placeholder="请输入品种" border="surround" v-model="value" @change="change"></up-input>
				</view>
			</view>

			<view class="card-li">
				<view class="card-li-tit">
					疫苗条形码
				</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 class="card-li">
				<view class="card-li-tit">
					注射对象
				</view>
				<view class="scan">
					扫描动物耳标/脚标
				</view>
			</view>

		</view>
		<view style="margin-bottom: 20rpx;" v-for="item in [1,1,1,1,1]">
			<u-swipe-action>
				<u-swipe-action-item :options="options1" style="border-radius: 20rpx;">
					<view class="" style="padding: 20rpx 30rpx;">
						<view class="swipe-action-tit">
							<view class="">
								编号: 123456
							</view>
							<view class="" style="color: #00A15E;" v-if="true">
								健康
							</view>
							<view class="" style="color: #FFD736;" v-if="0">
								怀孕中
							</view>
							<view class="" style="color: #3274F9;" v-if="0">
								可出栏
							</view>

						</view>
						<view class="swipe-action-li">
							<view class="">
								养殖品种:黑山猪
							</view>
							<view class="">
								年龄: 5年
							</view>
							<view class="">
								体重: 150kg
							</view>
						</view>
					</view>

				</u-swipe-action-item>
			</u-swipe-action>
		</view>

		<view class="ripe-btn">
			确认
		</view>

	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from "vue"
	const options1 = reactive([{
		text: '删除'
	}])

	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>
	.card-li-tit {
		margin-bottom: 20rpx;
	}

	.title {
		margin: 20rpx 0;
	}

	.code-img {
		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;
		}

	}


	.scan {
		// width: 623.83rpx;
		height: 80.61rpx;
		border: 2px solid #00A15E;
		border-radius: 50rpx;
		color: #00A15E;
		text-align: center;
		line-height: 80rpx;
	}

	.ripe-btn {
		width: 588.79rpx;
		height: 84.11rpx;
		background-color: #00A15E;
		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 85rpx auto;
		border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
		background: linear-gradient(to right, #00A15E, #4CC593);
	}

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

	.swipe-action-li {
		display: flex;
		justify-content: space-between;
		// align-items: ;
	}
</style>