CustomerServiceButton.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <button
  3. open-type="contact"
  4. :send-message-title="computedTitle"
  5. :send-message-path="computedPath"
  6. :send-message-img="img"
  7. :show-message-card="showMessageCard"
  8. @contact="onContact"
  9. class="contact-btn"
  10. :class="[mode]"
  11. hover-class="contact-btn-hover"
  12. >
  13. <slot />
  14. </button>
  15. </template>
  16. <script setup lang="ts">
  17. interface Props {
  18. title?: string
  19. path?: string
  20. img?: string
  21. showMessageCard?: boolean
  22. mode?: 'inline' | 'menu-item' | 'floating' | 'link'
  23. }
  24. const props = withDefaults(defineProps<Props>(), {
  25. title: '',
  26. path: '',
  27. img: '',
  28. showMessageCard: true,
  29. mode: 'inline'
  30. })
  31. const emit = defineEmits<{
  32. (e: 'contact', data: any): void
  33. }>()
  34. const computedTitle = `客服咨询 - ${props.title || 'AI零售柜'}`
  35. const computedPath = props.path || '/pages/index/index'
  36. const onContact = (e: any) => {
  37. emit('contact', e.detail)
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. .contact-btn {
  42. display: inline-flex;
  43. align-items: center;
  44. justify-content: center;
  45. padding: 0;
  46. margin: 0;
  47. background: transparent;
  48. border: none;
  49. line-height: inherit;
  50. font-size: inherit;
  51. color: inherit;
  52. font-weight: inherit;
  53. &::after {
  54. border: none;
  55. }
  56. &.inline {
  57. display: inline-flex;
  58. }
  59. &.menu-item {
  60. width: 100%;
  61. display: flex;
  62. align-items: center;
  63. justify-content: flex-start;
  64. padding: $spacing-md $spacing-lg;
  65. border-radius: 0;
  66. text-align: left;
  67. min-height: 88rpx;
  68. box-sizing: border-box;
  69. :deep(image),
  70. ::v-deep image,
  71. .menu-svg-icon {
  72. width: 40rpx !important;
  73. height: 40rpx !important;
  74. min-width: 40rpx !important;
  75. min-height: 40rpx !important;
  76. max-width: 40rpx !important;
  77. max-height: 40rpx !important;
  78. }
  79. &:active {
  80. background: $color-bg-secondary;
  81. }
  82. }
  83. &.floating {
  84. position: fixed;
  85. bottom: 120rpx;
  86. left: 50%;
  87. transform: translateX(-50%);
  88. background: $color-primary;
  89. color: $color-text-primary;
  90. padding: $spacing-md $spacing-xl;
  91. border-radius: $radius-xl;
  92. font-size: 28rpx;
  93. font-weight: 500;
  94. box-shadow: $shadow-primary;
  95. z-index: 100;
  96. white-space: nowrap;
  97. &:active {
  98. transform: translateX(-50%) scale(0.97);
  99. }
  100. }
  101. &.link {
  102. display: inline;
  103. color: $color-primary-dark;
  104. text-decoration: underline;
  105. font-size: 28rpx;
  106. }
  107. }
  108. .contact-btn-hover {
  109. opacity: 0.8;
  110. }
  111. </style>