index.vue 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view class="TUI-faceMessage" @tap="previewImage"><image class="face-message" :src="renderDom.src"></image></view>
  3. </template>
  4. <script>
  5. export default {
  6. data() {
  7. return {
  8. renderDom: [],
  9. percent: 0,
  10. faceUrl: 'https://web.sdk.qcloud.com/im/assets/face-elem/'
  11. };
  12. },
  13. components: {},
  14. props: {
  15. message: {
  16. type: Object
  17. },
  18. isMine: {
  19. type: Boolean,
  20. default: true
  21. }
  22. },
  23. watch: {
  24. message: {
  25. handler: function(newVal) {
  26. this.renderDom=this.parseFace(newVal);
  27. // this.setData({
  28. // renderDom: this.parseFace(newVal)
  29. // });
  30. },
  31. immediate: true,
  32. deep: true
  33. }
  34. },
  35. methods: {
  36. // 解析face 消息
  37. parseFace(message) {
  38. const renderDom = {
  39. src: `${this.faceUrl + message.payload.data}@2x.png`
  40. };
  41. return renderDom;
  42. },
  43. previewImage() {
  44. uni.previewImage({
  45. current: this.renderDom[0].src,
  46. // 当前显示图片的http链接
  47. urls: [this.renderDom[0].src]
  48. });
  49. }
  50. }
  51. };
  52. </script>
  53. <style>
  54. @import './index.css';
  55. </style>