DealResultPopup.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <cwg-popup v-model:visible="visible" type="center" :mask-click="false" :showFooters="true" :title="title">
  3. <view class="popup-content">
  4. <uni-forms ref="formRef" :model="formData" :rules="rules" label-position="top">
  5. <uni-forms-item :label="t('PersonalManagement.Label.PinCode')" prop="pin" v-if="type === 3">
  6. <input type="password" v-model="formData.pin" placeholder="{{ t('placeholder.input') }}" />
  7. </uni-forms-item>
  8. <uni-forms-item :label="t('PersonalManagement.Label.OtpCode')" prop="otp" v-if="type === 4">
  9. <input type="text" v-model="formData.otp"
  10. :placeholder="$i18n.locale === 'es' ? 'Código de 6 dígitos' : t('placeholder.input')" />
  11. </uni-forms-item>
  12. <template v-if="type === 6">
  13. <uni-forms-item :label="t('ImproveImmediately.Label.CountryRegionOfResidence')" prop="country">
  14. <input type="text" v-model="formData.country" placeholder="{{ t('placeholder.input') }}" />
  15. </uni-forms-item>
  16. <uni-forms-item :label="t('ImproveImmediately.Label.ProvinceRegion')" prop="state">
  17. <input type="text" v-model="formData.state" placeholder="{{ t('placeholder.input') }}" />
  18. </uni-forms-item>
  19. <uni-forms-item :label="t('ImproveImmediately.Label.City')" prop="city">
  20. <input type="text" v-model="formData.city" placeholder="{{ t('placeholder.input') }}" />
  21. </uni-forms-item>
  22. <uni-forms-item :label="t('ImproveImmediately.Label.DetailedAddress')" prop="address">
  23. <input type="text" v-model="formData.address" placeholder="{{ t('placeholder.input') }}" />
  24. </uni-forms-item>
  25. <uni-forms-item :label="t('ImproveImmediately.Label.ZipCode')" prop="zipCode">
  26. <input type="text" v-model="formData.zipCode" placeholder="{{ t('placeholder.input') }}" />
  27. </uni-forms-item>
  28. </template>
  29. <uni-forms-item :label="t('PersonalManagement.Label.Phone')" prop="phone" v-if="type === 7">
  30. <input type="tel" v-model="formData.phone" placeholder="{{ t('placeholder.input') }}" />
  31. </uni-forms-item>
  32. </uni-forms>
  33. </view>
  34. <template #footer>
  35. <button @click="cancel">{{ t('Btn.Cancel') }}</button>
  36. <button type="primary" @click="submit">{{ t('Btn.Confirm') }}</button>
  37. </template>
  38. </cwg-popup>
  39. </template>
  40. <script setup>
  41. import { ref, computed } from 'vue';
  42. import { useI18n } from 'vue-i18n';
  43. const props = defineProps({
  44. visible: { type: Boolean, default: false },
  45. title: { type: String, default: '' },
  46. type: { type: Number, default: 0 }, // 3: pin, 4: otp, 6: address, 7: phone
  47. initialData: { type: Object, default: () => ({}) }
  48. });
  49. const emit = defineEmits(['update:visible', 'submit']);
  50. const { t } = useI18n();
  51. const visible = computed({
  52. get: () => props.visible,
  53. set: (val) => emit('update:visible', val)
  54. });
  55. const formData = ref({ ...props.initialData });
  56. const rules = ref({}); // 按需添加
  57. const formRef = ref(null);
  58. const cancel = () => { visible.value = false; };
  59. const submit = async () => {
  60. if (formRef.value) {
  61. try {
  62. await formRef.value.validate();
  63. visible.value = false;
  64. emit('submit', formData.value);
  65. } catch (error) {
  66. console.error('Form validation failed:', error);
  67. }
  68. } else {
  69. visible.value = false;
  70. emit('submit', formData.value);
  71. }
  72. };
  73. </script>
  74. <style lang="scss" scoped>
  75. @import "@/uni.scss";
  76. .popup-content {
  77. padding: px2rpx(20);
  78. input {
  79. width: 100%;
  80. height: px2rpx(40);
  81. padding: 0 px2rpx(12);
  82. border: 1px solid #dcdfe6;
  83. border-radius: px2rpx(4);
  84. font-size: px2rpx(14);
  85. transition: border-color 0.3s;
  86. &:focus {
  87. outline: none;
  88. border-color: #409eff;
  89. box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
  90. }
  91. }
  92. :deep(.uni-forms-item) {
  93. margin-bottom: px2rpx(16);
  94. :deep(.uni-forms-item__label) {
  95. font-size: px2rpx(14);
  96. color: #606266;
  97. margin-bottom: px2rpx(8);
  98. }
  99. :deep(.uni-forms-item__error) {
  100. font-size: px2rpx(12);
  101. color: #f56c6c;
  102. margin-top: px2rpx(4);
  103. }
  104. }
  105. }
  106. .title {
  107. font-size: px2rpx(18);
  108. font-weight: bold;
  109. margin-bottom: px2rpx(20);
  110. text-align: center;
  111. }
  112. </style>