index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <ToolbarItemContainer
  3. iconFile="https://qianzhiy-applet.oss-rg-china-mainland.aliyuncs.com/h5/images/homemaking/user/tool-icon3.png"
  4. title="常用语"
  5. :needBottomPopup="true"
  6. iconWidth="30px"
  7. iconHeight="30px"
  8. @onDialogShow="onDialogShow"
  9. @onDialogClose="onDialogClose"
  10. ref="container"
  11. >
  12. <div :class="['words', !isPC && 'words-h5']">
  13. <div :class="['words-header', !isPC && 'words-h5-header']">
  14. <span :class="['words-header-title', !isPC && 'words-h5-header-title']">
  15. {{ TUITranslateService.t("Words.常用语-快捷回复工具") }}
  16. </span>
  17. <span
  18. v-if="!isPC"
  19. :class="['words-header-close', !isPC && 'words-h5-header-close']"
  20. @click="closeDialog"
  21. >
  22. 关闭
  23. </span>
  24. </div>
  25. <ul :class="['words-list', !isPC && 'words-h5-list']">
  26. <li
  27. :class="['words-list-item', !isPC && 'words-h5-list-item']"
  28. v-for="(item, index) in wordsList"
  29. :key="index"
  30. @click="selectWord(item)"
  31. >
  32. {{ TUITranslateService.t(`Words.${item.value}`) }}
  33. </li>
  34. </ul>
  35. </div>
  36. </ToolbarItemContainer>
  37. </template>
  38. <script setup lang="ts">
  39. import {
  40. TUITranslateService,
  41. TUIStore,
  42. StoreName,
  43. IConversationModel,
  44. SendMessageParams,
  45. TUIChatService,
  46. } from "@tencentcloud/chat-uikit-engine";
  47. import { ref } from "../../../../adapter-vue";
  48. import ToolbarItemContainer from "../toolbar-item-container/index.vue";
  49. import { wordsList } from "../../utils/wordsList";
  50. import { isEnabledMessageReadReceiptGlobal } from "../../utils/utils";
  51. import { isPC, isUniFrameWork } from "../../../../utils/env";
  52. const emits = defineEmits(["onDialogPopupShowOrHide"]);
  53. const currentConversation = ref<IConversationModel>();
  54. const container = ref();
  55. TUIStore.watch(StoreName.CONV, {
  56. currentConversation: (conversation: IConversationModel) => {
  57. currentConversation.value = conversation;
  58. },
  59. });
  60. const selectWord = (item: any) => {
  61. const options = {
  62. to:
  63. currentConversation?.value?.groupProfile?.groupID ||
  64. currentConversation?.value?.userProfile?.userID,
  65. conversationType: currentConversation?.value?.type,
  66. payload: {
  67. text: TUITranslateService.t(`Words.${item.value}`),
  68. },
  69. needReadReceipt: isEnabledMessageReadReceiptGlobal(),
  70. } as SendMessageParams;
  71. TUIChatService.sendTextMessage(options);
  72. // 提交后关闭 dialog
  73. // close dialog after submit evaluate
  74. container?.value?.toggleDialogDisplay(false);
  75. };
  76. const closeDialog = () => {
  77. container?.value?.toggleDialogDisplay(false);
  78. };
  79. const onDialogShow = () => {
  80. emits("onDialogPopupShowOrHide", true);
  81. };
  82. const onDialogClose = () => {
  83. emits("onDialogPopupShowOrHide", false);
  84. };
  85. </script>
  86. <style scoped lang="scss" src="./style/index.scss"></style>