backgroundMusicSettings.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="background-music-settings">
  3. <span class="title">{{set_bgm}}</span>
  4. <br>
  5. <button v-if="!(info && info.workBackgroundMusic && info.workBackgroundMusic.name)" @click="onClickMusicSelectionBtn">
  6. <i class="iconfont icon-editor_add"></i>
  7. {{add_audio}}
  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.workBackgroundMusic.ossPath"></Audio>
  12. <div class="name" v-title="info.workBackgroundMusic.name" @click="onClickCurrentMusic">{{info.workBackgroundMusic.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. {{change_audio}}
  18. </button>
  19. </template>
  20. <div class="dialog" style="z-index: 2000" v-if="isShowSelectionWindow">
  21. <MaterialSelector
  22. :title="select_material"
  23. @cancel="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 MaterialSelector from "@/components/materialSelector.vue";
  34. import Audio from "@/components/audio/audioButton.vue";
  35. import {i18n} from "@/lang"
  36. export default {
  37. components: {
  38. MaterialSelector,
  39. Audio,
  40. },
  41. data() {
  42. return {
  43. set_bgm:i18n.t("edit_settings.set_bgm"),
  44. add_audio:i18n.t("edit_settings.add_audio"),
  45. change_audio:i18n.t("edit_settings.change_audio"),
  46. select_material:i18n.t("gather.select_material"),
  47. isShowSelectionWindow: false,
  48. }
  49. },
  50. computed: {
  51. ...mapGetters({
  52. // info:'info'
  53. info:'base/baseInfo'
  54. }),
  55. },
  56. methods: {
  57. onClickMusicSelectionBtn() {
  58. this.isShowSelectionWindow = true
  59. },
  60. onClickDeleteMusicBtn() {
  61. this.info.workBackgroundMusic.id = null
  62. this.info.workBackgroundMusic.name = null
  63. this.info.workBackgroundMusic.ossPath = null
  64. },
  65. handleSubmitFromMaterialSelector(selected) {
  66. this.isShowSelectionWindow = false
  67. this.info.workBackgroundMusic.fodderId = selected[0].id
  68. this.info.workBackgroundMusic.name = selected[0].name
  69. this.info.workBackgroundMusic.ossPath = selected[0].ossPath
  70. },
  71. onClickCurrentMusic() {
  72. if (this.$refs['my-audio']) {
  73. this.$refs['my-audio'].switchPlayPause()
  74. }
  75. }
  76. },
  77. mounted() {
  78. if (!this.info.workBackgroundMusic) {
  79. this.info.workBackgroundMusic = {
  80. id: '',
  81. name: '',
  82. ossPath: '',
  83. }
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="less" scoped>
  89. .background-music-settings {
  90. padding: 24px 30px;
  91. background: #252526;
  92. height: 546px;
  93. > .title {
  94. font-size: 18px;
  95. color: #FFFFFF;
  96. }
  97. > button {
  98. margin-top: 16px;
  99. width: 234px;
  100. height: 40px;
  101. background: #1A1B1D;
  102. border-radius: 2px;
  103. border: 1px solid #404040;
  104. display: block;
  105. color: #0076F6;
  106. font-size: 14px;
  107. cursor: pointer;
  108. &:hover {
  109. border-color: @color;
  110. }
  111. i {
  112. font-size: 14px;
  113. }
  114. }
  115. > .music-display {
  116. cursor: pointer;
  117. margin-top: 16px;
  118. width: 234px;
  119. height: 40px;
  120. background: #1A1B1D;
  121. border-radius: 2px;
  122. border: 1px solid #404040;
  123. color: #fff;
  124. font-size: 14px;
  125. position: relative;
  126. text-align: center;
  127. &:hover {
  128. color: #0076F6;
  129. border-color: @color;
  130. > .audio-control {
  131. display: inline-block;
  132. }
  133. > i {
  134. display: inline-block;
  135. }
  136. }
  137. > .audio-control {
  138. position: absolute;
  139. top: 50%;
  140. transform: translateY(-50%);
  141. left: 18px;
  142. display: none;
  143. }
  144. > .name {
  145. position: absolute;
  146. left: 50%;
  147. top: 50%;
  148. transform: translate(-50%, -50%);
  149. width: 65%;
  150. text-overflow: ellipsis;
  151. overflow: hidden;
  152. white-space: nowrap;
  153. display: inline-block;
  154. }
  155. > i {
  156. display: none;
  157. position: absolute;
  158. top: 50%;
  159. transform: translateY(-50%);
  160. right: 18px;
  161. &:hover {
  162. color: #FA5555;
  163. }
  164. }
  165. }
  166. }
  167. </style>