content-dialog.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <script setup>
  2. import { watch, watchEffect } from 'vue'
  3. import AnimatedOverlay from '../../components/dialog/AnimatedOverlay.vue'
  4. import { useContactMeLogic, usePreLeaveInfo } from '../../utils/hooks.js'
  5. import { showToast } from '../../utils/toast'
  6. import ContentCard from './components/content-card.vue'
  7. import PhoneConfirmDialog from './components/PhoneConfirmDialog.vue'
  8. import PhoneEditDialog from './components/PhoneEditDialog.vue'
  9. import SubMitSuccess from './components/SubMitSuccess.vue'
  10. const props = defineProps({
  11. source: {
  12. type: String,
  13. default: '',
  14. required: true,
  15. },
  16. sourceDesc: {
  17. type: String,
  18. default: '',
  19. },
  20. popupTitle: {
  21. type: String,
  22. default: '联系专属客服,申请免费体验'
  23. },
  24. type: {
  25. type: String,
  26. default: '1'
  27. }
  28. })
  29. const {
  30. updateVisible,
  31. close,
  32. visible,
  33. configInfo,
  34. } = usePreLeaveInfo({ props })
  35. const config = {
  36. configInfo,
  37. props,
  38. }
  39. const {
  40. confirmPhoneDialog,
  41. changePhoneDialog,
  42. successCheckDialog,
  43. dialogEvents,
  44. checkPhonePass,
  45. contactMe
  46. } = useContactMeLogic({
  47. configInfo,
  48. props,
  49. // popupVisible: visible,
  50. })
  51. function contactMeEvent(phone) {
  52. const phonePass = checkPhonePass(phone)
  53. if (!phonePass) {
  54. return showToast('联系电话格式不正确')
  55. }
  56. configInfo.phone = phone
  57. changePhoneDialog.phoneNumber = phone
  58. contactMe()
  59. }
  60. function phoneEditConfirm(phone) {
  61. changePhoneDialog.phoneNumber = phone
  62. dialogEvents.phoneChangeConfirm()
  63. }
  64. defineExpose({
  65. updateVisible
  66. })
  67. </script>
  68. <script>
  69. export default {
  70. name: 'PCContentDialog',
  71. }
  72. </script>
  73. <template>
  74. <AnimatedOverlay
  75. class="pc-leave-dialog"
  76. :class="`pc-leave-dialog-${props.type}`"
  77. :visible="visible"
  78. @update:visible="updateVisible"
  79. >
  80. <ContentCard
  81. :config="config"
  82. @contactMeEvent="contactMeEvent"
  83. @close="updateVisible(false)"
  84. />
  85. <!-- 确认手机弹窗 -->
  86. <PhoneConfirmDialog
  87. :visible="confirmPhoneDialog.show"
  88. :title="confirmPhoneDialog.title"
  89. :content-text="confirmPhoneDialog.contentText"
  90. :confirm-button-text="confirmPhoneDialog.confirmButtonText"
  91. :cancel-button-text="confirmPhoneDialog.cancelButtonText"
  92. @confirm="dialogEvents.confirmPhoneConfirm"
  93. @cancel="dialogEvents.confirmPhoneCancel"
  94. />
  95. <!-- 修改手机号弹窗 -->
  96. <PhoneEditDialog
  97. :visible="changePhoneDialog.show"
  98. :phone="changePhoneDialog.phoneNumber"
  99. @confirm="phoneEditConfirm"
  100. @cancel="dialogEvents.phoneChangeCancel"
  101. />
  102. <!-- 提交成功弹窗 -->
  103. <SubMitSuccess
  104. :visible="successCheckDialog.show"
  105. :title="successCheckDialog.title"
  106. :content-text="successCheckDialog.contentText"
  107. :confirm-button-text="successCheckDialog.confirmButtonText"
  108. @confirm="dialogEvents.successConfirm"
  109. />
  110. </AnimatedOverlay>
  111. </template>
  112. <style scoped lang="scss">
  113. .pc-leave-dialog {
  114. ::v-deep {
  115. .overlay-content {
  116. margin: 300px auto;
  117. width: 732px;
  118. // background: #fff;
  119. border-radius: 8px;
  120. }
  121. @import '../../assets/style/pc.scss';
  122. }
  123. &-2 {
  124. ::v-deep {
  125. .overlay-content {
  126. width: 480px;
  127. }
  128. }
  129. }
  130. }
  131. </style>