telDialog.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <uni-popup ref="telPopup" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(0, 0, 0, 0.4)">
  4. <view class="phone-common-dialog">
  5. <view class="common-body-box">
  6. <view class="common-title">修改电话</view>
  7. <view class="common-input-box">
  8. <view class="common-input-row">
  9. <text class="common-input-label"><text class="common-label-require">*</text>新号码:</text>
  10. <input class="common-input" v-model="data.tel" placeholder="请输入新号码" />
  11. </view>
  12. </view>
  13. <view class="common-btn-box">
  14. <view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
  15. <view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. </uni-popup>
  20. </template>
  21. <script setup>
  22. import {ref,reactive} from "vue"
  23. const props = defineProps({
  24. notBtn: {
  25. type: String,
  26. require: true,
  27. default: '取消'
  28. },
  29. okBtn: {
  30. type: String,
  31. require: true,
  32. default: '确认'
  33. },
  34. });
  35. const data = reactive({
  36. tel: '',
  37. })
  38. const telPopup = ref(null); // 索引
  39. const $emit = defineEmits(['confirm-btn'])
  40. function passClear(){
  41. data.tel = '';
  42. }
  43. // 打开弹窗
  44. function handleShow() {
  45. telPopup.value.open();
  46. }
  47. // 取消
  48. function handleClose() {
  49. passClear();
  50. telPopup.value.close();
  51. }
  52. // 确认
  53. function confirmBtn(){
  54. let arr = [];
  55. if (!data.tel) {
  56. arr.push('新号码');
  57. }
  58. if (!data.tel) {
  59. uni.showToast({
  60. icon: 'none',
  61. title: `请输入${arr.join('、')}!`
  62. })
  63. return;
  64. }
  65. $emit('confirm-btn',data.tel);
  66. passClear();
  67. telPopup.value.close();
  68. }
  69. defineExpose({
  70. handleShow,
  71. handleClose
  72. })
  73. </script>
  74. <style>
  75. </style>