backgroundMusicSettings.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="background-music-settings">
  3. <span class="title">设置背景音乐</span>
  4. <br>
  5. <button v-if="!(info && info.backgroundMusic && info.backgroundMusic.name)" @click="onClickMusicSelectionBtn">
  6. <i class="iconfont icon-editor_add"></i>
  7. 添加音频
  8. </button>
  9. <template v-else>
  10. <div class="music-display" @click.self="onClickCurrentMusic">
  11. <Audio ref="my-audio" class="audio-control" :backgroundColor="'#1A1B1D'" :myAudioUrl="info.backgroundMusic.ossPath"></Audio>
  12. <div class="name" v-title="info.backgroundMusic.name" @click="onClickCurrentMusic">{{info.backgroundMusic.name}}</div>
  13. <i class="iconfont icon-editor_list_delete" @click.stop="onClickDeleteMusicBtn"></i>
  14. </div>
  15. <button @click="onClickMusicSelectionBtn">
  16. <i class="iconfont icon-editor_update"></i>
  17. 更换音频
  18. </button>
  19. </template>
  20. <div class="dialog" style="z-index: 2000" v-if="isShowSelectionWindow">
  21. <MaterialSelectorForEditor
  22. title="选择素材"
  23. @cancle="isShowSelectionWindow = false"
  24. @submit="handleSubmitFromMaterialSelector"
  25. :selectableType="['audio']"
  26. initialMaterialType="audio"
  27. />
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { mapGetters } from "vuex";
  33. import MaterialSelectorForEditor from "@/components/materialSelectorForEditor.vue";
  34. import Audio from "@/components/audio/audioButton.vue";
  35. export default {
  36. components: {
  37. MaterialSelectorForEditor,
  38. Audio,
  39. },
  40. data() {
  41. return {
  42. isShowSelectionWindow: false,
  43. }
  44. },
  45. computed: {
  46. ...mapGetters({
  47. info:'info'
  48. }),
  49. },
  50. methods: {
  51. onClickMusicSelectionBtn() {
  52. this.isShowSelectionWindow = true
  53. },
  54. onClickDeleteMusicBtn() {
  55. this.info.backgroundMusic.id = null
  56. this.info.backgroundMusic.name = null
  57. this.info.backgroundMusic.ossPath = null
  58. },
  59. handleSubmitFromMaterialSelector(selected) {
  60. this.isShowSelectionWindow = false
  61. this.info.backgroundMusic.id = selected[0].id
  62. this.info.backgroundMusic.name = selected[0].name
  63. this.info.backgroundMusic.ossPath = selected[0].ossPath
  64. },
  65. onClickCurrentMusic() {
  66. if (this.$refs['my-audio']) {
  67. this.$refs['my-audio'].switchPlayPause()
  68. }
  69. }
  70. },
  71. mounted() {
  72. if (!this.info.backgroundMusic) {
  73. this.info.backgroundMusic = {
  74. id: '',
  75. name: '',
  76. ossPath: '',
  77. }
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="less" scoped>
  83. .background-music-settings {
  84. padding: 24px 30px;
  85. background: #252526;
  86. height: 546px;
  87. > .title {
  88. font-size: 18px;
  89. color: #FFFFFF;
  90. }
  91. > button {
  92. margin-top: 16px;
  93. width: 234px;
  94. height: 40px;
  95. background: #1A1B1D;
  96. border-radius: 2px;
  97. border: 1px solid #404040;
  98. display: block;
  99. color: #0076F6;
  100. font-size: 14px;
  101. cursor: pointer;
  102. &:hover {
  103. border-color: @color;
  104. }
  105. i {
  106. font-size: 14px;
  107. }
  108. }
  109. > .music-display {
  110. cursor: pointer;
  111. margin-top: 16px;
  112. width: 234px;
  113. height: 40px;
  114. background: #1A1B1D;
  115. border-radius: 2px;
  116. border: 1px solid #404040;
  117. color: #fff;
  118. font-size: 14px;
  119. position: relative;
  120. text-align: center;
  121. &:hover {
  122. color: #0076F6;
  123. border-color: @color;
  124. > .audio-control {
  125. display: inline-block;
  126. }
  127. > i {
  128. display: inline-block;
  129. }
  130. }
  131. > .audio-control {
  132. position: absolute;
  133. top: 50%;
  134. transform: translateY(-50%);
  135. left: 18px;
  136. display: none;
  137. }
  138. > .name {
  139. position: absolute;
  140. left: 50%;
  141. top: 50%;
  142. transform: translate(-50%, -50%);
  143. width: 65%;
  144. text-overflow: ellipsis;
  145. overflow: hidden;
  146. white-space: nowrap;
  147. display: inline-block;
  148. }
  149. > i {
  150. display: none;
  151. position: absolute;
  152. top: 50%;
  153. transform: translateY(-50%);
  154. right: 18px;
  155. &:hover {
  156. color: #FA5555;
  157. }
  158. }
  159. }
  160. }
  161. </style>