BaseDialog.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <script setup lang="ts">
  2. import { useMessage } from 'naive-ui';
  3. const { apiBase: baseURL } = useRuntimeConfig().public;
  4. const message = useMessage();
  5. const { t } = useI18n();
  6. const params = ref({
  7. name: '',
  8. source: '官网',
  9. phoneNumber: '',
  10. remark: ''
  11. })
  12. const modelValue = defineModel<boolean>();
  13. const onClose = () => {
  14. modelValue.value = false;
  15. params.value = {
  16. name: '',
  17. source: '官网',
  18. phoneNumber: '',
  19. remark: ''
  20. }
  21. }
  22. const onSubmit = async () => {
  23. const { name, phoneNumber, remark } = params.value;
  24. if ( !name ) {
  25. return message.error(t('dialog.verifyEmptyName'));
  26. }
  27. if ( name.length > 10 ) {
  28. return message.error(t('dialog.verifyLengthName'));
  29. }
  30. if ( !phoneNumber ) {
  31. return message.error(t('dialog.verifyEmptyPhone'));
  32. }
  33. if (!/^(13[0-9]|14[01456789]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(phoneNumber)) {
  34. return message.error(t('dialog.verifyPhone'));
  35. }
  36. if ( remark.length > 200 ) {
  37. return message.error(t('dialog.verifyLengthTextarea'));
  38. }
  39. const response = await $fetch(baseURL + '/business/cooperation', {
  40. method: 'POST',
  41. body: JSON.stringify(params.value),
  42. headers: {
  43. 'Content-Type': 'application/json',
  44. },
  45. });
  46. message.success('提交成功');
  47. onClose();
  48. }
  49. </script>
  50. <template>
  51. <NModal v-model:show="modelValue" :close-on-esc="false" :mask-closable="false" style="max-width: 1440px">
  52. <div class="w-full h-full flex items-center justify-center">
  53. <div class="contact-modal_inner w-full h-[650px] md:w-[1440px] md:h-[810px] md:px-[60px] md:py-[56px]">
  54. <div class="header py-[30px] md:py-[0px]">
  55. <BaseIcon class="icon cursor-pointer" name="close-small" width="32" height="32" @click="onClose" />
  56. </div>
  57. <div class="main flex-col items-center px-[10px] py-[0px] md:flex-row md:items-start md:pt-[64px]">
  58. <div class="left w-full md:w-[380px] text-[#161616] mb-[20px] md:mt-[0px]">
  59. <p class="text-[30px] py-[20px] md:py-[44px] md:text-[56px] md:leading-[84px] font-bold">{{ $t('dialog.title') }}</p>
  60. <p class="text-[#565E66] leading-[24px]">{{ $t('dialog.content') }}</p>
  61. </div>
  62. <div class="right w-full md:w-[620px]">
  63. <ul class="inp-wrap flex flex-wrap md:flex-nowrap md:space-x-[8px]">
  64. <li class="w-[100%] mb-[10px] md:w-[50%]">
  65. <input type="text" :placeholder="$t('dialog.namePlaceholder')" v-model.trim="params.name">
  66. </li>
  67. <li class="w-[100%] md:w-[50%]">
  68. <input type="text" :placeholder="$t('dialog.phonePlaceholder')" v-model.trim="params.phoneNumber">
  69. </li>
  70. </ul>
  71. <div>
  72. <textarea cols="30" rows="10" class="w-full h-[150px] md:h-[300px] mt-[16px]" style="padding-top: 10px;"
  73. :placeholder="$t('dialog.textareaPlaceholder')" v-model="params.remark"></textarea>
  74. </div>
  75. <button class="sub-btn" @click="onSubmit">{{ $t('dialog.btnText') }}</button>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </NModal>
  81. </template>
  82. <style lang="scss" scoped>
  83. .contact-modal_inner {
  84. max-width: 1440px;
  85. background: #fff;
  86. .header {
  87. display: flex;
  88. justify-content: flex-end;
  89. }
  90. .main {
  91. display: flex;
  92. justify-content: space-between;
  93. .left {
  94. // width: 340px;
  95. border-top: 1px solid #000000;
  96. }
  97. .right {
  98. .inp-wrap {
  99. // height: 49px;
  100. input {
  101. width: 100%;
  102. height: 50px;
  103. }
  104. }
  105. .sub-btn {
  106. width: 144px;
  107. height: 48px;
  108. margin-top: 30px;
  109. border-radius: 8px;
  110. background: linear-gradient(87.67deg, #2A67F8 4.95%, #4892FF 93.07%);
  111. font-size: 18px;
  112. color: #fff;
  113. }
  114. input,
  115. textarea {
  116. outline: none;
  117. padding: 0 20px;
  118. border: 1px solid #EBEBEB;
  119. background: #FBFBFB;
  120. resize: none;
  121. }
  122. }
  123. }
  124. }
  125. </style>