<template>
	<uni-popup ref="telPopup" :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.tel"  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({
		tel: '',
	})
	const telPopup = ref(null); // 索引
	const $emit = defineEmits(['confirm-btn'])
	
	function passClear(){
		data.tel = '';
	}
	// 打开弹窗
	function handleShow() {
		telPopup.value.open();
	}
	// 取消
	function handleClose() {
		passClear();
		telPopup.value.close();
	}
	// 确认
	function confirmBtn(){
		let arr = [];
		if (!data.tel) {
			arr.push('新号码');
		}
		if (!data.tel) {
			uni.showToast({
				icon: 'none',
				title: `请输入${arr.join('、')}！`
			})
			return;
		}
		$emit('confirm-btn',data.tel);
		passClear();
		telPopup.value.close();
	}
	defineExpose({
			handleShow,
			handleClose
		})
</script>

<style>
</style>