<template>
	<uni-popup ref="realNamePopup" :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>
					<input class="common-input" v-model="data.realName"  placeholder="请输入真实姓名" />
				</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({
		realName: '',
	})
	const realNamePopup = ref(null); // 索引
	const $emit = defineEmits(['confirm-btn'])
	
	function passClear(){
		data.realName = '';
	}
	// 打开弹窗
	function handleShow() {
		realNamePopup.value.open();
	}
	// 取消
	function handleClose() {
		passClear();
		realNamePopup.value.close();
	}
	// 确认
	function confirmBtn(){
		let arr = [];
		if (!data.realName) {
			arr.push('真实姓名');
		}
		if (!data.realName) {
			uni.showToast({
				icon: 'none',
				title: `请输入${arr.join('、')}信息！`
			})
			return;
		}
		$emit('confirm-btn',data.realName);
		passClear();
		realNamePopup.value.close();
	}
	defineExpose({
			handleShow,
			handleClose
		})
</script>

<style>
</style>