cimg.vue 4.3 KB

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