toolbar.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. export default {
  34. name: 'toolbar',
  35. props: {
  36. toolShow: Boolean
  37. },
  38. methods: {
  39. handleFile (e) {
  40. this.$emit('handleFile', e)
  41. },
  42. resetInput () {
  43. if (this.$refs.inputFile1) {
  44. this.$refs.inputFile1.value = null
  45. }
  46. if (this.$refs.inputFile2) {
  47. this.$refs.inputFile2.value = null
  48. }
  49. if (this.$refs.inputFile3) {
  50. this.$refs.inputFile3.value = null
  51. }
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .tool-wrap {
  58. background-color: #f6f6f6;
  59. display: flex;
  60. padding: 16px 0;
  61. .tool-item {
  62. flex: 1;
  63. text-align: center;
  64. }
  65. .type {
  66. font-size: 14px;
  67. color: #666666;
  68. }
  69. .icon-box {
  70. width: 58px;
  71. height: 58px;
  72. margin: 0 auto;
  73. cursor: pointer;
  74. background-color: #ffffff;
  75. border-radius: 6px;
  76. border: 1px solid #efefef;
  77. box-sizing: border-box;
  78. margin-bottom: 6px;
  79. display: flex;
  80. justify-content: center;
  81. align-items: center;
  82. position: relative;
  83. &:hover {
  84. opacity: 0.8;
  85. }
  86. input[type="file"] {
  87. opacity: 0;
  88. position: absolute;
  89. top: 0;
  90. left: 0;
  91. width: 100%;
  92. height: 100%;
  93. cursor: pointer;
  94. z-index: 4;
  95. }
  96. i {
  97. display: inline-block;
  98. }
  99. .packet-icon {
  100. background: url("../../assets/packet-icon.png") no-repeat;
  101. background-size: 100%;
  102. width: 21px;
  103. height: 26px;
  104. }
  105. .picture-icon {
  106. background: url("../../assets/pic-icon.png") no-repeat;
  107. background-size: 100%;
  108. width: 27px;
  109. height: 21px;
  110. }
  111. .audio-icon {
  112. background: url("../../assets/audio-icon.png") no-repeat;
  113. background-size: 100%;
  114. width: 18px;
  115. height: 26px;
  116. }
  117. .video-icon {
  118. background: url("../../assets/video-icon.png") no-repeat;
  119. background-size: 100%;
  120. width: 30px;
  121. height: 18px;
  122. }
  123. }
  124. }
  125. </style>