<template>
	<uni-popup ref="genderPopup" :animation="false" :is-mask-click="false"
	 mask-background-color="rgba(0, 0, 0, 0.4)">
	 <view class="phone-common-dialog">
		<view class="common-body-box">
			<view class="common-title">修改性别</view>
			<view class="common-input-box">
				<view class="common-input-row">
					<text class="common-input-label"><text class="common-label-require">*</text>性别：</text>
					<uni-data-select
						class="common-select"
					    v-model="data.gender"
					    :localdata="data.range"
					    @change="change"
					></uni-data-select>
				</view>
			</view>
			<view class="common-btn-box">
				<view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
				<view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
			</view>
		</view>
	 </view>
	</uni-popup>
</template>

<script setup>
	import {ref,reactive} from "vue"
	const props = defineProps({
	  notBtn: {
	    type: String,
	  	require: true,
	    default: '取消'
	  },
	  okBtn: {
	    type: String,
	  	require: true,
	    default: '确认'
	  },
	});
	const data = reactive({
		gender: '',
		range:[
		    { value: 0, text: "未知" },
		    { value: 1, text: "男" },
		    { value: 2, text: "女" },
		]
	})
	const genderPopup = ref(null); // 索引
	const $emit = defineEmits(['confirm-btn'])
	
	function change(data){
		console.log('changedata',data);
	}
	
	function passClear(){
		data.gender = '';
	}
	// 打开弹窗
	function handleShow() {
		genderPopup.value.open();
	}
	// 取消
	function handleClose() {
		passClear();
		genderPopup.value.close();
	}
	// 确认
	function confirmBtn(){
		$emit('confirm-btn',data.gender);
		passClear();
		genderPopup.value.close();
	}
	defineExpose({
			handleShow,
			handleClose
		})
</script>

<style>
</style>