messageInput.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="send-wrap ss-flex">
  3. <view class="left ss-flex ss-flex-1">
  4. <optimize-input
  5. class="ss-flex-1 ss-p-l-22"
  6. :inputBorder="false"
  7. :clearable="false"
  8. v-model="message"
  9. placeholder="请输入你要咨询的问题"
  10. ></optimize-input>
  11. </view>
  12. <text class="sicon-basic bq" @tap.stop="onTools('emoji')"></text>
  13. <text
  14. v-if="!message"
  15. class="sicon-edit"
  16. :class="{ 'is-active': toolsMode === 'tools' }"
  17. @tap.stop="onTools('tools')"
  18. />
  19. <button
  20. v-if="message"
  21. class="ss-reset-button send-btn"
  22. @tap="sendMessage"
  23. :disabled="isDisabled || sending"
  24. :class="{ disabled: isDisabled || sending }"
  25. >
  26. <text v-if="sending">发送中</text>
  27. <text v-else>发送</text>
  28. </button>
  29. </view>
  30. </template>
  31. <script setup>
  32. import { computed, ref, onUnmounted } from 'vue';
  33. import OptimizeInput from '@/pages/chat/components/optimize-input.vue';
  34. /**
  35. * 消息发送组件
  36. */
  37. const props = defineProps({
  38. // 消息
  39. modelValue: {
  40. type: String,
  41. default: '',
  42. },
  43. // 工具模式
  44. toolsMode: {
  45. type: String,
  46. default: '',
  47. },
  48. });
  49. const emits = defineEmits(['update:modelValue', 'onTools', 'sendMessage']);
  50. const message = computed({
  51. get() {
  52. return props.modelValue;
  53. },
  54. set(newValue) {
  55. emits(`update:modelValue`, newValue);
  56. }
  57. });
  58. // 打开工具菜单
  59. function onTools(mode) {
  60. emits('onTools', mode);
  61. }
  62. // 发送消息
  63. function sendMessage() {
  64. emits('sendMessage');
  65. }
  66. </script>
  67. <style scoped lang="scss">
  68. .send-wrap {
  69. padding: 18rpx 20rpx;
  70. background: #fff;
  71. .left {
  72. height: 64rpx;
  73. border-radius: 32rpx;
  74. background: var(--ui-BG-1);
  75. }
  76. .bq {
  77. font-size: 50rpx;
  78. margin-left: 10rpx;
  79. }
  80. .sicon-edit {
  81. font-size: 50rpx;
  82. margin-left: 10rpx;
  83. transform: rotate(0deg);
  84. transition: all linear 0.2s;
  85. &.is-active {
  86. transform: rotate(45deg);
  87. }
  88. }
  89. .send-btn {
  90. width: 100rpx;
  91. height: 60rpx;
  92. line-height: 60rpx;
  93. border-radius: 30rpx;
  94. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  95. font-size: 26rpx;
  96. color: #fff;
  97. margin-left: 11rpx;
  98. }
  99. }
  100. </style>