messageshow.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="m-item" :id="'message'+cid">
  3. <view class="m-left">
  4. <image class="head_icon" src="/static/img/img004.png" v-if="message.user=='home'"></image>
  5. </view>
  6. <view class="m-content">
  7. <view class="m-content-head" :class="{'m-content-head-right':message.user=='customer'}">
  8. <view :class="'m-content-head-'+message.user">
  9. <rich-text :nodes="message.content.replace(this.reg, emotion)"></rich-text></view>
  10. </view>
  11. </view>
  12. <view class="m-right">
  13. <image class="head_icon" src="/static/img/img004.png" v-if="message.user=='customer'"></image>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. props: {
  20. message: {
  21. type: Object,
  22. default () {
  23. return {};
  24. }
  25. },
  26. cid: {
  27. type: [Number, String],
  28. default: ''
  29. }
  30. },
  31. data() {
  32. return {
  33. reg: /\#[\S]{1,3}\;/gi
  34. }
  35. },
  36. methods: {
  37. emotion(res) {
  38. //console.log('mess', res)
  39. let word = res.replace(/\#|\;/gi, '')
  40. //console.log(word)
  41. const list = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴', '睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过', '酷',
  42. '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢', '饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂', '疑问', '嘘', '晕', '折磨', '衰',
  43. '骷髅', '敲打', '再见', '擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠', '鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜',
  44. '菜刀', '西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰', '凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀', '足球', '瓢虫',
  45. '便便', '月亮', '太阳', '礼物', '拥抱', '强', '弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你', 'NO', 'OK', '爱情', '飞吻', '跳跳',
  46. '发抖', '怄火', '转圈', '磕头', '回头', '跳绳', '挥手', '激动', '街舞', '献吻', '左太极', '右太极'
  47. ]
  48. let index = list.indexOf(word)
  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>
  55. .m-item {
  56. display: flex;
  57. flex-direction: row;
  58. padding-top: 40upx;
  59. }
  60. .m-left {
  61. display: flex;
  62. width: 120upx;
  63. justify-content: center;
  64. align-items: flex-start;
  65. }
  66. .m-content {
  67. display: flex;
  68. flex: 1;
  69. flex-direction: column;
  70. justify-content: center;
  71. word-break: break-all;
  72. }
  73. .m-right {
  74. display: flex;
  75. width: 120upx;
  76. justify-content: center;
  77. align-items: flex-start;
  78. }
  79. .head_icon {
  80. width: 80upx;
  81. height: 80upx;
  82. border-radius: 100%;
  83. }
  84. .m-content-head {
  85. position: relative;
  86. }
  87. .m-content-head-right {
  88. display: flex;
  89. justify-content: flex-end;
  90. }
  91. .m-content-head-home {
  92. text-align: left;
  93. background: #1482d1;
  94. border: 1px #1482d1 solid;
  95. border-radius: 20upx;
  96. padding: 20upx 25rpx;
  97. font-size: 26rpx !important;
  98. color: white;
  99. display: inline-block;
  100. }
  101. .m-content-head-home:before {
  102. border: 15upx solid transparent;
  103. border-right: 15upx solid #1482d1;
  104. left: -26upx;
  105. width: 0;
  106. height: 0;
  107. position: absolute;
  108. content: ' '
  109. }
  110. .m-content-head-customer {
  111. border: 1upx white solid;
  112. font-size: 26rpx !important;
  113. background: white;
  114. border-radius: 20upx;
  115. padding: 20upx;
  116. background-color: #F7F7FB;
  117. }
  118. .m-content-head-customer:after {
  119. border: 15upx solid transparent;
  120. border-left: 15upx solid #F7F7FB;
  121. top: 20upx;
  122. right: -26upx;
  123. width: 0;
  124. height: 0;
  125. position: absolute;
  126. content: ' '
  127. }
  128. </style>