red.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: #fb9f3c;width: 46vw;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 #fb9f3c; border-bottom: 10px solid transparent;}
  11. .msg .nickname{font-size: 12px;margin-bottom:6px;}
  12. .msg .red_envelope{background: #fb9f3c;}
  13. .msg.no-msg .content{background-color:rgba(251,159,60,0.6);}
  14. .msg.no-msg .red_envelope{background-color:transparent;}
  15. .msg .red_envelope .red-view{padding-bottom: 10px;}
  16. .msg .red_envelope .red-view image{width: 30px;height: 30px;}
  17. .msg .red_envelope .red-view .text{font-size: 14px;color: #fff;}
  18. .msg .red_envelope .tag{padding-top: 10px;font-size: 12px;border-top: 1px solid rgba(255,255,255,0.6);color: #fff;}
  19. .me-msg{padding: 20rpx;}
  20. .msg-in{width: calc(100% - 140rpx); margin-right: 20rpx;}
  21. .me-msg .loading-msg{width:20px;height:20px;animation:rotate 1.5s linear infinite;margin-right: 20rpx;}
  22. .me-msg .msg-err{width:20px;height:20px;margin-right: 20rpx;}
  23. .me-msg .avatar{width: 80rpx;height: 80rpx;border-radius: 50%;overflow: hidden;}
  24. .me-msg .avatar image{width: 80rpx;height: 80rpx;border-radius: 50%;}
  25. .me-msg .content{position: relative;min-height: 20px;font-size: 16px;background-color: #fb9f3c;width: 46vw;padding: 20rpx;border-radius: 8rpx;word-break:break-all;display:inline-block;}
  26. .me-msg .content .i{width: 0;height: 0;right: -10px;position: absolute;border-top: 10px solid transparent; border-left: 10px solid #fb9f3c; border-bottom: 10px solid transparent;}
  27. .me-msg .red_envelope{background: #fb9f3c;}
  28. .me-msg .red_envelope .red-view{padding-bottom: 10px;}
  29. .me-msg .red_envelope .red-view image{width: 30px;height: 30px;}
  30. .me-msg .red_envelope .red-view .text{font-size: 14px;color: #fff;}
  31. .me-msg .red_envelope .tag{padding-top: 10px;font-size: 12px;border-top: 1px solid rgba(255,255,255,0.6);color: #fff;}
  32. .me-msg.no-msg .content{background-color:rgba(251,159,60,0.6);}
  33. .me-msg.no-msg .red_envelope{background-color:transparent;}
  34. .me-msg.no-msg .content .i{border-left-color:rgba(251,159,60,0.6);}
  35. .me-msg .nickname{font-size: 12px;margin-bottom:6px;margin-right: 6px;}
  36. /**结束**/
  37. </style>
  38. <template>
  39. <view>
  40. <view class="msg fx-r" :class="item.isReceiveRed ? 'no-msg' : ''" v-if="item.sendUser.uid != user.uid">
  41. <view class="avatar" @tap="tapUser(1)" hover-class="avatar-hover"><image :src="utils.getAvatar(item.sendUser.avatar,'chat')" mode="aspectFill" ></image></view>
  42. <view class="msg-in">
  43. <view class="nickname">{{item.sendUser.nickname}}</view>
  44. <view class="content" @tap="tapRedBack">
  45. <view class="i"></view>
  46. <view class="red_envelope">
  47. <view class="red-view fx-r">
  48. <image mode="widthFix" src="/static/img/chat-red-v2.svg"></image>
  49. <view class="text">{{inItem.name}}</view>
  50. </view>
  51. <view class="tag">普通红包</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="me-msg fx-r fx-ae" :class="item.isReceiveRed ? 'no-msg' : ''" v-else >
  57. <view class="msg-in fx-h fx-be fx-ae">
  58. <view class="nickname">{{item.sendUser.nickname}}</view>
  59. <view class="msg-in fx-r fx-bc fx-ae">
  60. <image v-if="item.isSend == 0" class="loading-msg" src="/static/img/xloading.png"></image>
  61. <image v-if="item.isSend == -1" @tap="tapRsend" class="msg-err" src="/static/img/waring.png"></image>
  62. <view class="content" @tap="tapRedBack">
  63. <view class="i"></view>
  64. <view class="red_envelope">
  65. <view class="red-view fx-r">
  66. <image mode="widthFix" src="/static/img/chat-red-v2.svg"></image>
  67. <view class="text">{{inItem.name}}</view>
  68. </view>
  69. <view class="tag">普通红包</view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="avatar" @tap="tapUser(0)" hover-class="avatar-hover"><image :src="utils.getAvatar(user.avatar,'chat')" mode="aspectFill" ></image></view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import {mapState,mapMutations } from 'vuex';
  80. export default {
  81. computed: mapState(['user','sysData']),
  82. name: 'red',
  83. props:{
  84. item : {
  85. type: Object,
  86. default: ()=>{return {data:{}} }
  87. }
  88. },
  89. watch:{
  90. item:{
  91. immediate:true,
  92. handler(val) {
  93. this.inItem = JSON.parse(val.data);
  94. }
  95. }
  96. },
  97. data() {
  98. return{
  99. inItem:{}
  100. }
  101. },
  102. created() {
  103. //console.log(this.item);
  104. },
  105. mounted() {
  106. },
  107. methods: {
  108. tapRsend:function() {
  109. this.$emit('rsend',this.item);
  110. },
  111. tapRedBack:function(){
  112. this.$emit('redItem',this.item);
  113. },
  114. tapUser:function(type){
  115. this.$emit('userItem',type == 0 ? this.user.uid : this.item.sendUser.uid);
  116. }
  117. }
  118. }
  119. </script>