redPacket.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="red-packet" :class="info.userId == userId ? 'me' : 'you'">
  3. <slot></slot>
  4. <div class="top"
  5. :class="{'lose-bg': isLoseBg, 'unopen': info.ext.grabbed == 0}">
  6. <i class="red-packet-icon"></i>
  7. <div class="word">
  8. <p>{{info.content.title}}</p>
  9. <p class="bot-text" v-if="info.ext.grabbed == 1">{{$t('redPacket.received')}}</p>
  10. <p class="bot-text" v-else-if="info.ext.redpack_status == 1">{{$t('redPacket.lootAll')}}</p>
  11. <p class="bot-text" v-else-if="info.ext.redpack_status == 2">{{$t('redPacket.expired')}}</p>
  12. </div>
  13. </div>
  14. <div class="bot">
  15. {{info.content.tokenType || 'EOS'}}{{$t('chat.redpack')}}
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'redPacket',
  22. props: ['info'],
  23. computed: {
  24. userId () {
  25. return this.$store.state.userId
  26. },
  27. isLoseBg () {
  28. return this.info.ext.redpack_status != 0 || this.info.ext.grabbed == 1
  29. }
  30. }
  31. }
  32. </script>
  33. <style lang="scss" scoped>
  34. .red-packet{
  35. width: 210px;
  36. border-radius: 6px;
  37. margin: 3px 0;
  38. overflow: hidden;
  39. cursor: pointer;
  40. .top{
  41. height: 70px;
  42. line-height: 70px;
  43. font-size: 14px;
  44. padding-left: 14px;
  45. background-color: #e99c57;
  46. .word{
  47. color: #ffffff;
  48. display: inline-block;
  49. width: 140px;
  50. vertical-align: middle;
  51. p{
  52. @include ellipsis();
  53. line-height: 1.2;
  54. &:first-child{
  55. margin-bottom: 6px;
  56. }
  57. }
  58. }
  59. }
  60. .unopen {
  61. background-color: #e99c57;
  62. .red-packet-icon {
  63. background: url('./img/unopen-packet.png') no-repeat;
  64. width: 36px;
  65. height: 44px;
  66. background-size: 100%;
  67. }
  68. }
  69. .lose-bg{
  70. background-color: #f6d7bc !important;
  71. .red-packet-icon{
  72. background: url('./img/open-packet.png') no-repeat;
  73. width: 36px;
  74. height: 51px;
  75. background-size: 100%;
  76. }
  77. }
  78. .bot{
  79. background-color: #ffffff;
  80. color: #999999;
  81. padding-left: 14px;
  82. font-size: 12px;
  83. height: 26px;
  84. line-height: 26px;
  85. }
  86. &.you{
  87. float: left;
  88. }
  89. &.me{
  90. float: right;
  91. .top{
  92. text-align: left;
  93. }
  94. .bot{
  95. text-align: left;
  96. }
  97. }
  98. .tips{
  99. display: inline-block;
  100. }
  101. .red-packet-icon{
  102. display: inline-block;
  103. vertical-align: middle;
  104. margin-right: 8px;
  105. }
  106. }
  107. .bot-text{
  108. font-size: 12px;
  109. }
  110. </style>