<template>
	<view class="search">
		<picker style="width: 50%;" @change="bindPickerChange($event,1)" :value="typeIndex" :range="typeList">
			<view class="search-type">
				{{typeList[typeIndex]}}
				<div class="search-type-img">
					<img src="../static/bottom.png">
				</div>
			</view>
		</picker>

		<picker style="width: 50%;" @change="bindPickerChange($event,2)" :value="timeIndex" :range="timeList">
			<view class="search-time">
				{{timeList[timeIndex]}}
				<div class="search-time-img">
					<img src="../static/bottom.png">
				</div>
			</view>
		</picker>
	</view>
</template>

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

	defineProps({
		typeList: Array,
		timeList: Array
	})

	const typeIndex = ref(0)
	const timeIndex = ref(0)

	const conveyData = defineEmits(["handLeConveyData"])

	const bindPickerChange = (e, type) => {
		if (type === 1) {
			typeIndex.value = e.detail.value
		} else {
			timeIndex.value = e.detail.value
		}

		conveyData("handLeConveyData", {
			typeIndex: typeIndex.value,
			timeIndex: timeIndex.value,
		})
	}
</script>

<style lang="scss" scoped>
	.search {
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin-bottom: 20rpx;
		height: 100rpx;
		font-size: 28rpx;
		background-color: #fff;

		.search-type {
			flex: 1;
			display: flex;
			justify-content: space-evenly;

			.search-type-img {
				margin-top: -5rpx;
				width: 17rpx;
				height: 12rpx;

				img {
					width: 100%;
					height: 100%;
				}
			}
		}

		.search-time {
			flex: 1;
			display: flex;
			justify-content: space-evenly;

			.search-time-img {
				margin-top: -5rpx;
				width: 17rpx;
				height: 12rpx;

				img {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
</style>