message-branch.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div class="branch-card">
  3. <p
  4. v-if="content.header || content.title"
  5. class="branch-title"
  6. >
  7. {{ content.header || content.title}}
  8. </p>
  9. <div
  10. v-for="(item, index) in content.items"
  11. :key="index"
  12. class="branch-item"
  13. :style="{ borderWidth: content.header ? '1px 0 0px 0' : '0px 0 1px 0' }"
  14. @click="handleContentListItemClick(item)"
  15. >
  16. {{ item.content }}
  17. <Icon :src="iconRight" />
  18. </div>
  19. </div>
  20. </template>
  21. <script lang="ts">
  22. import vue from '../adapter-vue';
  23. import { customerServicePayloadType } from '../interface';
  24. import iconRight from '../assets/iconRight.svg';
  25. import Icon from './customer-icon.vue';
  26. const { computed } = vue;
  27. interface Props {
  28. payload: customerServicePayloadType;
  29. }
  30. interface branchItem {
  31. content: string;
  32. desc: string;
  33. }
  34. export default {
  35. components: {
  36. Icon,
  37. },
  38. props: {
  39. payload: {
  40. type: Object as () => customerServicePayloadType,
  41. default: () => ({}),
  42. },
  43. },
  44. emits: ['sendMessage'],
  45. setup(props: Props, { emit }) {
  46. const content = computed(() => {
  47. return props?.payload?.content || {
  48. header: undefined,
  49. items: [],
  50. };
  51. });
  52. const handleContentListItemClick = (branch: branchItem) => {
  53. emit('sendMessage', { text: branch.content });
  54. };
  55. return {
  56. content,
  57. handleContentListItemClick,
  58. iconRight,
  59. };
  60. },
  61. };
  62. </script>
  63. <style lang="scss">
  64. .branch-card {
  65. min-width: 250px;
  66. max-width: 350px;
  67. .branch-title {
  68. margin-bottom: 8px;
  69. border-radius: 0 10px 10px;
  70. }
  71. .branch-item {
  72. display: flex;
  73. justify-content: space-between;
  74. border-style: dotted;
  75. border-color: #d8d8d8;
  76. font-weight: 400;
  77. color: rgba(54, 141, 255, 1);
  78. padding-top: 5px;
  79. cursor: pointer;
  80. padding-bottom: 5px;
  81. }
  82. }
  83. </style>