explanationSettings.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <div class="explanation-settings" app-border dir-left>
  3. <div class="title">
  4. 语音讲解
  5. <i class="iconfont icon-material_prompt tool-tip-for-editor" v-tooltip="'您可以为当前全景图添加语音讲解音频。'"/>
  6. </div>
  7. <button
  8. v-if="!currentScene.explanation.audioId"
  9. class="ui-button submit"
  10. :class="{
  11. disable: !currentScene || currentScene.type ==='4dkk',
  12. }"
  13. @click="isShowSelectionWindow = true"
  14. >
  15. <i class="iconfont icon-editor_add"></i>
  16. 添加音频
  17. </button>
  18. <template v-else>
  19. <div class="music-display" @click.self="onClickCurrentMusic">
  20. <Audio ref="my-audio" class="audio-control" :backgroundColor="'#1A1B1D'" :myAudioUrl="currentScene.explanation.audioUrl"></Audio>
  21. <div class="name" :key="currentScene.explanation.audioName" v-title="currentScene.explanation.audioName" @click="onClickCurrentMusic">{{currentScene.explanation.audioName}}</div>
  22. <i class="iconfont icon-editor_list_delete" @click.stop="onClickDeleteMusicBtn"></i>
  23. </div>
  24. <button class="ui-button" @click="isShowSelectionWindow = true">
  25. <i class="iconfont icon-editor_update"></i>
  26. 更换音频
  27. </button>
  28. </template>
  29. <div class="switch-wrapper">
  30. <span class="label">默认开启</span>
  31. <Switcher
  32. :disable="!currentScene || currentScene.type ==='4dkk'"
  33. :value="currentScene.explanation.openByDefault" @change="currentScene.explanation.openByDefault = !currentScene.explanation.openByDefault"
  34. />
  35. </div>
  36. <div class="switch-wrapper">
  37. <span class="label">循环播放</span>
  38. <Switcher
  39. :disable="!currentScene || currentScene.type ==='4dkk'"
  40. :value="currentScene.explanation.repeat" @change="currentScene.explanation.repeat = !currentScene.explanation.repeat"
  41. />
  42. </div>
  43. <div class="dialog" style="z-index: 2000" v-if="isShowSelectionWindow">
  44. <MaterialSelectorForEditor
  45. title="选择素材"
  46. @cancle="isShowSelectionWindow = false"
  47. @submit="handleSubmitFromMaterialSelector"
  48. :selectableType="['audio']"
  49. initialMaterialType="audio"
  50. />
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import { mapGetters } from "vuex";
  56. import Switcher from "@/components/shared/Switcher";
  57. import MaterialSelectorForEditor from "@/components/materialSelectorForEditor.vue";
  58. import Audio from "@/components/audio/audioButton.vue";
  59. export default {
  60. components: {
  61. Switcher,
  62. MaterialSelectorForEditor,
  63. Audio,
  64. },
  65. computed: {
  66. ...mapGetters({
  67. info: "info",
  68. currentScene: "scene/currentScene",
  69. }),
  70. },
  71. data() {
  72. return {
  73. isShowSelectionWindow: false,
  74. }
  75. },
  76. methods: {
  77. onClickCurrentMusic() {
  78. if (this.$refs['my-audio']) {
  79. this.$refs['my-audio'].switchPlayPause()
  80. }
  81. },
  82. onClickDeleteMusicBtn() {
  83. this.currentScene.explanation.audioId = ''
  84. this.currentScene.explanation.audioUrl = ''
  85. this.currentScene.explanation.audioName = ''
  86. },
  87. handleSubmitFromMaterialSelector(selected) {
  88. this.currentScene.explanation.audioId = selected[0].id
  89. this.currentScene.explanation.audioName = selected[0].name
  90. this.currentScene.explanation.audioUrl = selected[0].ossPath
  91. this.isShowSelectionWindow = false
  92. },
  93. },
  94. watch: {
  95. currentScene: {
  96. immediate: true,
  97. handler: function (newVal) {
  98. if (!newVal.explanation) {
  99. this.$set(newVal, 'explanation', {
  100. audioId: '',
  101. audioName: '',
  102. audioUrl: '',
  103. openByDefault: true,
  104. repeat: true,
  105. })
  106. }
  107. },
  108. },
  109. },
  110. }
  111. </script>
  112. <style lang="less" scoped>
  113. .explanation-settings {
  114. padding: 20px;
  115. > .title {
  116. font-size: 18px;
  117. color: #fff;
  118. > i {
  119. font-size: 12px;
  120. position: relative;
  121. top: -2px;
  122. }
  123. }
  124. > button {
  125. width: 100%;
  126. margin-top: 16px;
  127. &:hover {
  128. border-color: @color;
  129. }
  130. i {
  131. font-size: 14px;
  132. }
  133. }
  134. > .music-display {
  135. cursor: pointer;
  136. margin-top: 16px;
  137. width: 234px;
  138. height: 36px;
  139. background: #1A1B1D;
  140. border-radius: 2px;
  141. border: 1px solid #404040;
  142. color: #fff;
  143. font-size: 14px;
  144. text-align: center;
  145. position: relative;
  146. &:hover {
  147. color: #0076F6;
  148. border-color: @color;
  149. > .audio-control {
  150. display: inline-block;
  151. }
  152. > i {
  153. display: inline-block;
  154. }
  155. }
  156. > .audio-control {
  157. position: absolute;
  158. top: 50%;
  159. transform: translateY(-50%);
  160. left: 18px;
  161. display: none;
  162. }
  163. > .name {
  164. position: absolute;
  165. left: 50%;
  166. top: 50%;
  167. transform: translate(-50%, -50%);
  168. width: 65%;
  169. text-overflow: ellipsis;
  170. overflow: hidden;
  171. white-space: nowrap;
  172. display: inline-block;
  173. }
  174. > i {
  175. display: none;
  176. position: absolute;
  177. top: 50%;
  178. transform: translateY(-50%);
  179. right: 18px;
  180. &:hover {
  181. color: #FA5555;
  182. }
  183. }
  184. }
  185. .switch-wrapper {
  186. display: flex;
  187. align-items: center;
  188. justify-content: space-between;
  189. margin-top: 18px;
  190. .label {
  191. color: rgba(255, 255, 255, 0.6);
  192. font-size: 14px;
  193. }
  194. }
  195. }
  196. </style>