index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="emotion-box" :style="{height: height + 'px'}">
  3. <view class="emotion-box-line" v-for="(line, i) in list" :key="i">
  4. <view class="emotion-item" v-for="(item, index) in line" :key="index" @click="clickHandler(item)">
  5. <!-- <text>{{this.item}}</text> -->
  6. <rich-text :nodes="item.replace(/\S{1,3}/gi, emotion(item))"></rich-text>
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. height: {
  15. type: Number,
  16. default: 200
  17. }
  18. },
  19. data() {
  20. return {
  21. list: [
  22. ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴'],
  23. ['睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过'],
  24. ['酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢'],
  25. ['饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂'],
  26. ['疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见'],
  27. ['擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠'],
  28. ['鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀'],
  29. ['西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰', ],
  30. ['凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀'],
  31. ['足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强'],
  32. ['弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你'],
  33. ['NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈'],
  34. ['磕头', '回头', '跳绳', '挥手', '激动', '街舞', '左太极', '右太极'],
  35. ],
  36. reg: /\S{1,3}/gi,
  37. item: []
  38. }
  39. },
  40. methods: {
  41. clickHandler(i) {
  42. let emotion = `#${i};`
  43. this.$emit('emotion', emotion)
  44. },
  45. emotion(res) {
  46. //let word = res.replace(/\#|\;/gi,'')
  47. const list = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴', '睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过', '酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢', '饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂', '疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见', '擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠', '鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀', '西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰', '凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀', '足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强', '弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你', 'NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈', '磕头', '回头', '跳绳', '挥手', '激动', '街舞', '献吻', '左太极', '右太极']
  48. let index = list.indexOf(res)
  49. return `<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/${index}.gif" align="middle">`
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped>
  55. .emotion-box {
  56. margin: 0 auto;
  57. width: 95%;
  58. box-sizing: border-box;
  59. padding: 5px;
  60. border: 1px solid #b4b4b4;
  61. overflow: hidden;
  62. overflow-y: auto;
  63. }
  64. .emotion-box-line {
  65. display: flex;
  66. }
  67. .emotion-item {
  68. flex: 1;
  69. text-align: center;
  70. cursor: pointer;
  71. }
  72. </style>