backgroundMusicSettings.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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/audioForEditor.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. }
  73. }
  74. </script>
  75. <style lang="less" scoped>
  76. .background-music-settings {
  77. padding: 24px 30px;
  78. background: #252526;
  79. height: 546px;
  80. > .title {
  81. font-size: 18px;
  82. color: #FFFFFF;
  83. }
  84. > button {
  85. margin-top: 16px;
  86. width: 234px;
  87. height: 40px;
  88. background: #1A1B1D;
  89. border-radius: 2px;
  90. border: 1px solid #404040;
  91. display: block;
  92. color: #0076F6;
  93. font-size: 14px;
  94. cursor: pointer;
  95. i {
  96. font-size: 14px;
  97. }
  98. }
  99. > .music-display {
  100. cursor: pointer;
  101. margin-top: 16px;
  102. width: 234px;
  103. height: 40px;
  104. background: #1A1B1D;
  105. border-radius: 2px;
  106. border: 1px solid #404040;
  107. color: #fff;
  108. font-size: 14px;
  109. position: relative;
  110. &:hover {
  111. color: #0076F6;
  112. > .audio-control {
  113. display: inline-block;
  114. }
  115. > i {
  116. display: inline-block;
  117. }
  118. }
  119. > .audio-control {
  120. position: absolute;
  121. top: 50%;
  122. transform: translateY(-50%);
  123. left: 18px;
  124. display: none;
  125. }
  126. > .name {
  127. position: absolute;
  128. left: 50%;
  129. top: 50%;
  130. transform: translate(-50%, -50%);
  131. width: 65%;
  132. text-overflow: ellipsis;
  133. overflow: hidden;
  134. white-space: nowrap;
  135. display: inline-block;
  136. }
  137. > i {
  138. display: none;
  139. position: absolute;
  140. top: 50%;
  141. transform: translateY(-50%);
  142. right: 18px;
  143. &:hover {
  144. color: #FA5555;
  145. }
  146. }
  147. }
  148. }
  149. </style>