messageInput.vue 2.1 KB

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