genderDialog.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <uni-popup ref="genderPopup" :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. <uni-data-select
  11. class="common-select"
  12. v-model="data.gender"
  13. :localdata="data.range"
  14. @change="change"
  15. ></uni-data-select>
  16. </view>
  17. </view>
  18. <view class="common-btn-box">
  19. <view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
  20. <view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
  21. </view>
  22. </view>
  23. </view>
  24. </uni-popup>
  25. </template>
  26. <script setup>
  27. import {ref,reactive} from "vue"
  28. const props = defineProps({
  29. notBtn: {
  30. type: String,
  31. require: true,
  32. default: '取消'
  33. },
  34. okBtn: {
  35. type: String,
  36. require: true,
  37. default: '确认'
  38. },
  39. });
  40. const data = reactive({
  41. gender: '',
  42. range:[
  43. { value: 0, text: "未知" },
  44. { value: 1, text: "男" },
  45. { value: 2, text: "女" },
  46. ]
  47. })
  48. const genderPopup = ref(null); // 索引
  49. const $emit = defineEmits(['confirm-btn'])
  50. function change(data){
  51. console.log('changedata',data);
  52. }
  53. function passClear(){
  54. data.gender = '';
  55. }
  56. // 打开弹窗
  57. function handleShow() {
  58. genderPopup.value.open();
  59. }
  60. // 取消
  61. function handleClose() {
  62. passClear();
  63. genderPopup.value.close();
  64. }
  65. // 确认
  66. function confirmBtn(){
  67. $emit('confirm-btn',data.gender);
  68. passClear();
  69. genderPopup.value.close();
  70. }
  71. defineExpose({
  72. handleShow,
  73. handleClose
  74. })
  75. </script>
  76. <style>
  77. </style>