toolbar.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="tool-wrap" @click.stop v-show="toolShow">
  3. <div class="tool-item">
  4. <div class="icon-box" @click="$packetSend">
  5. <i class="packet-icon"></i>
  6. </div>
  7. <span class="type">{{ $t('chat.redpack') }}</span>
  8. </div>
  9. <div class="tool-item">
  10. <div class="icon-box">
  11. <i class="picture-icon"></i>
  12. <input type="file" ref="inputFile1" accept="image/*" @change="handleFile">
  13. </div>
  14. <span class="type">{{ $t('chat.image') }}</span>
  15. </div>
  16. <div class="tool-item">
  17. <div class="icon-box">
  18. <i class="audio-icon"></i>
  19. <input type="file" ref="inputFile2" accept="audio/*" @change="handleFile">
  20. </div>
  21. <span class="type">{{ $t('chat.audio') }}</span>
  22. </div>
  23. <div class="tool-item">
  24. <div class="icon-box">
  25. <i class="video-icon"></i>
  26. <input type="file" ref="inputFile3" accept="video/*" @change="handleFile">
  27. </div>
  28. <span class="type">{{ $t('chat.video') }}</span>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import { getMeechatType } from '@/util/util'
  34. export default {
  35. name: 'toolbar',
  36. props: {
  37. toolShow: Boolean,
  38. meechatType: getMeechatType()
  39. },
  40. methods: {
  41. handleFile (e) {
  42. this.$emit('handleFile', e)
  43. },
  44. resetInput () {
  45. if (this.$refs.inputFile1) {
  46. this.$refs.inputFile1.value = null
  47. }
  48. if (this.$refs.inputFile2) {
  49. this.$refs.inputFile2.value = null
  50. }
  51. if (this.$refs.inputFile3) {
  52. this.$refs.inputFile3.value = null
  53. }
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .tool-wrap {
  60. background-color: #f6f6f6;
  61. display: flex;
  62. padding: 16px 0;
  63. .tool-item {
  64. flex: 1;
  65. text-align: center;
  66. }
  67. .type {
  68. font-size: 14px;
  69. color: #666666;
  70. }
  71. .icon-box {
  72. width: 58px;
  73. height: 58px;
  74. margin: 0 auto;
  75. cursor: pointer;
  76. background-color: #ffffff;
  77. border-radius: 6px;
  78. border: 1px solid #efefef;
  79. box-sizing: border-box;
  80. margin-bottom: 6px;
  81. display: flex;
  82. justify-content: center;
  83. align-items: center;
  84. position: relative;
  85. &:hover {
  86. opacity: 0.8;
  87. }
  88. input[type="file"] {
  89. opacity: 0;
  90. position: absolute;
  91. top: 0;
  92. left: 0;
  93. width: 100%;
  94. height: 100%;
  95. cursor: pointer;
  96. z-index: 4;
  97. }
  98. i {
  99. display: inline-block;
  100. }
  101. .packet-icon {
  102. background: url("../../assets/packet-icon.png") no-repeat;
  103. background-size: 100%;
  104. width: 21px;
  105. height: 26px;
  106. }
  107. .picture-icon {
  108. background: url("../../assets/pic-icon.png") no-repeat;
  109. background-size: 100%;
  110. width: 27px;
  111. height: 21px;
  112. }
  113. .audio-icon {
  114. background: url("../../assets/audio-icon.png") no-repeat;
  115. background-size: 100%;
  116. width: 18px;
  117. height: 26px;
  118. }
  119. .video-icon {
  120. background: url("../../assets/video-icon.png") no-repeat;
  121. background-size: 100%;
  122. width: 30px;
  123. height: 18px;
  124. }
  125. }
  126. }
  127. </style>