Emotion.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div v-show="show" @click="close()">
  3. <div class="emotion-box" :style="{ 'left': x + 'px', 'top': y + 'px' }">
  4. <el-scrollbar style="height: 220px">
  5. <div class="emotion-items">
  6. <div class="emotion-item" v-for="(emoText, i) in $emo.emoTextList" :key="i"
  7. @click="onClickEmo(emoText)" v-html="$emo.textToImg(emoText,'emoji-large')">
  8. </div>
  9. </div>
  10. </el-scrollbar>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: "emotion",
  17. data() {
  18. return {
  19. show: false,
  20. pos: {
  21. x: 0,
  22. y: 0
  23. }
  24. }
  25. },
  26. methods: {
  27. onClickEmo(emoText) {
  28. let emotion = `#${emoText};`
  29. this.$emit('emotion', emotion)
  30. },
  31. open(pos) {
  32. this.pos = pos;
  33. this.show = true;
  34. },
  35. close() {
  36. this.show = false;
  37. }
  38. },
  39. computed: {
  40. x() {
  41. return this.pos.x - 22;
  42. },
  43. y() {
  44. return this.pos.y - 234;
  45. }
  46. }
  47. }
  48. </script>
  49. <style scoped lang="scss">
  50. .emotion-box {
  51. position: fixed;
  52. width: 372px;
  53. box-sizing: border-box;
  54. padding: 5px;
  55. background-color: #fff;
  56. box-shadow: var(--im-box-shadow);
  57. .emotion-items {
  58. display: flex;
  59. flex-wrap: wrap;
  60. .emotion-item {
  61. text-align: center;
  62. cursor: pointer;
  63. padding: 2px;
  64. }
  65. }
  66. }
  67. </style>