msg.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <style>
  2. /**基本聊天数据**/
  3. .msg{padding: 20rpx;}
  4. .msg .msg-in{width: calc(100% - 160rpx); margin-left: 30rpx;}
  5. .msg .loading-msg{width:20px;height:20px;animation:rotate 1.5s linear infinite;margin-left: 20rpx;}
  6. .msg .msg-err{width:20px;height:20px;margin-left: 20rpx;}
  7. .msg .avatar{width: 80rpx;height: 80rpx;border-radius: 50%;overflow: hidden;margin-top: 6px;}
  8. .msg .avatar image{width: 80rpx;height: 80rpx;border-radius: 50%;}
  9. .msg .content{position: relative;min-height: 20px;font-size: 16px;background-color: #fff;max-width: calc(100% - 140rpx);padding: 20rpx;border-radius: 8rpx;word-break:break-all;display:inline-block;}
  10. .msg .content .i{width: 0;height: 0;left: -10px;position: absolute;border-top: 10px solid transparent; border-right: 10px solid #fff; border-bottom: 10px solid transparent;}
  11. .msg .content.remind{color: orange;}
  12. .msg .content .vimg{max-width: 200rpx;}
  13. .msg .msg-in .emojis{width: 180rpx;}
  14. .msg .nickname{font-size: 12px;margin-bottom:6px;}
  15. .me-msg{padding: 20rpx;}
  16. .msg-in{width: calc(100% - 140rpx); margin-right: 20rpx;}
  17. .me-msg .loading-msg{width:20px;height:20px;animation:rotate 1.5s linear infinite;margin-right: 20rpx;}
  18. .me-msg .msg-err{width:20px;height:20px;margin-right: 20rpx;}
  19. .me-msg .avatar{width: 80rpx;height: 80rpx;border-radius: 50%;overflow: hidden;}
  20. .me-msg .avatar image{width: 80rpx;height: 80rpx;border-radius: 50%;}
  21. .me-msg .content{position: relative;min-height: 20px;font-size: 16px;background-color: #cceaff;max-width: calc(100% - 140rpx);padding: 20rpx;border-radius: 8rpx;word-break:break-all;display:inline-block;}
  22. .me-msg .content .i{width: 0;height: 0;right: -10px;position: absolute;border-top: 10px solid transparent; border-left: 10px solid #cceaff; border-bottom: 10px solid transparent;}
  23. .me-msg .content .vimg{max-width: 200rpx;}
  24. .me-msg .msg-in .emojis{width: 180rpx;}
  25. .me-msg .content .up{position: absolute;width: calc(100% - 40rpx);height: calc(100% - 40rpx);top: 20rpx;left: 20rpx; background: rgba(0,0,0,0.4);color: #fff; font-size: 14px;}
  26. .me-msg .nickname{font-size: 12px;margin-bottom:6px;margin-right: 6px;}
  27. /**结束**/
  28. </style>
  29. <template>
  30. <view>
  31. <view class="msg fx-r" v-if="item.sendUser.uid != user.uid">
  32. <view class="avatar" @tap="tapUser(1)" @longtap="tapLongUserItem" hover-class="avatar-hover"><image :src="utils.getAvatar(item.sendUser.avatar,'chat')" mode="aspectFill" ></image></view>
  33. <view class="msg-in">
  34. <view class="nickname">{{item.sendUser.nickname}}</view>
  35. <view class="content" :class="item.is_remind == 1 ? 'remind': ''" @longtap="tapLongItem">
  36. <view class="i"></view>
  37. <!-- #ifdef H5 -->
  38. <text v-html="utils.toH5ml(item.data)"></text>
  39. <!-- #endif -->
  40. <!-- #ifndef H5 -->
  41. <rich-text :nodes="utils.toH5ml(item.data)"></rich-text>
  42. <!-- #endif -->
  43. </view>
  44. </view>
  45. </view>
  46. <view class="me-msg fx-r fx-ae" v-else>
  47. <view class="msg-in fx-h fx-be fx-ae">
  48. <view class="nickname">{{item.sendUser.nickname}}</view>
  49. <view class="msg-in fx-r fx-bc fx-ae">
  50. <u-loading-icon v-if="item.isSend == 0" style="margin-right: 10px;"></u-loading-icon>
  51. <image v-if="item.isSend == -1" @tap="tapRsend" class="msg-err" src="/static/chat/waring.png"></image>
  52. <view class="content" @longtap="tapLongItem">
  53. <view class="i"></view>
  54. <!-- #ifdef H5-->
  55. <text v-html="utils.toH5ml(item.data)"></text>
  56. <!-- #endif -->
  57. <!-- #ifndef H5 -->
  58. <rich-text :nodes="utils.toH5ml(item.data)"></rich-text>
  59. <!-- #endif -->
  60. </view>
  61. </view>
  62. </view>
  63. <view class="avatar" @tap="tapUser(0)" hover-class="avatar-hover"><image :src="utils.getAvatar(user.avatar,'chat')" mode="aspectFill" ></image></view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import {mapState,mapMutations } from 'vuex';
  69. export default {
  70. computed: mapState(['user','sysData']),
  71. name: 'msg',
  72. props:{
  73. item : {
  74. type: Object,
  75. default: ()=>{return {data:{}} }
  76. },
  77. chatUser:{
  78. type: Object,
  79. default: ()=>{return {data:{}} }
  80. }
  81. },
  82. data() {
  83. return{
  84. }
  85. },
  86. created() {
  87. //console.log(this.item);
  88. },
  89. mounted() {
  90. },
  91. methods: {
  92. tapRsend:function() {
  93. this.$emit('rsend',this.item);
  94. },
  95. tapLongItem:function(ev){
  96. this.$emit('longItem',{
  97. dom : ev,
  98. data : this.item
  99. });
  100. },
  101. tapLongUserItem:function(ev){
  102. this.$emit('longUserItem',{
  103. dom : ev,
  104. data : this.item
  105. });
  106. },
  107. tapUser:function(type){
  108. this.$emit('userItem',type == 0 ? this.user.uid : this.item.sendUser.uid);
  109. }
  110. }
  111. }
  112. </script>