<template>
	<!-- 选择弹窗 -->
	<view class="selectPopup" @touchmove.stop.prevent="onTouchMove">
		<u-popup :show="visible" round="32" mode="bottom" closeable @close="onCancel" duration="1">
			<view class="select-container">
				<view class="popTitle"> <text>{{popTitle}}</text> </view>
				<scroll-view scroll-y class="select-list">
					<u-radio-group v-model="currentChecked" placement="column" iconPlacement="right">
						<u-radio :customStyle="{margin: '22rpx 40rpx'}" :size="40" :iconSize="32" :labelSize="32"
							labelColor="#262626" v-for="(item, index) in selectEnum" :key="index" :label="item.label"
							:name="item.value" @change="onChange">
						</u-radio>
					</u-radio-group>
				</scroll-view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		name: "bs-selectPopup",
		options: { styleIsolation: 'shared' },
		props: {
			visible: { //弹窗显隐
				type: Boolean,
				default: false
			},
			selectEnum: { //选择项枚举
				type: Array,
				default: []
			},
			popTitle: { //弹窗标题
				type: String,
				default: ""
			}
		},
		data() {
			return {
				currentChecked: '', //当前选中类型
			};
		},
		methods: {
			setSelect(value) {
				this.currentChecked = value
			},

			onChange(value) {
				this.setSelect(value)
				setTimeout(() => {
					this.onConfirm()
				}, 350)
			},

			onCancel() {
				this.$emit('onVisible')
			},

			//确认选择
			onConfirm() {
				this.$emit('onConfirm', this.currentChecked)
			},

			//防止滚动穿透
			onTouchMove() {}
		}
	}
</script>

<style lang="scss">
	.selectPopup {
		.select-container {
			min-width: 70vw;
			height: 50vh;
			padding: 30rpx;
			font-weight: 400;

			.popTitle {
				color: #8C8C8C;
				font-size: 32rpx;
				text-align: center;
				margin-bottom: 44rpx;
			}
			
			.select-list{
				height: 460rpx;
			}
		}

		/deep/.uicon-close {
			font-size: 40rpx !important;
			width: 24rpx;
			height: 24rpx;
			margin-right: 20rpx;
		}
	}
</style>
