openingAnimationSettings.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="opening-animation-settings">
  3. <span class="title">{{ $i18n.t(`edit_settings.opening_setting`) }}</span>
  4. <br />
  5. <div class="switch-wrapper">
  6. <span class="label">{{
  7. $i18n.t("edit_settings.opening_animation_show")
  8. }}</span>
  9. <Switcher
  10. :value="info.isShowOpeningAnimation"
  11. @change="onSwitcherChange"
  12. ></Switcher>
  13. </div>
  14. <div class="btns-and-video">
  15. <div class="btn-wrapper">
  16. <button
  17. v-for="item of openingTypeList"
  18. :key="item"
  19. class="opening-selection-btn"
  20. :class="{ 'active-opening-type': info.openingAnimationType === item }"
  21. @click="info.openingAnimationType = item"
  22. >
  23. {{ $i18n.t(`baseSetting.opa${item}`) }}
  24. </button>
  25. </div>
  26. <div class="video-wrapper">
  27. <video
  28. ref="opvideo"
  29. :src="
  30. require(`@/assets/videos/opa${fallbackOpeningAnimationType(
  31. info.openingAnimationType
  32. )}_x264.mp4`)
  33. "
  34. autoplay
  35. loop
  36. ></video>
  37. <i
  38. v-if="playing"
  39. @click="bofang"
  40. class="iconfont iconshow_playback"
  41. ></i>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import { mapGetters } from "vuex";
  48. import Switcher from "@/components/shared/Switcher";
  49. export default {
  50. components: {
  51. Switcher,
  52. },
  53. data() {
  54. return {
  55. // openingTypeList: [
  56. // '小行星开场',
  57. // '小行星巡游开场',
  58. // '小行星缩放开场',
  59. // '水平巡游开场',
  60. // '水晶球开场',
  61. // ],
  62. openingTypeList: [1, 2, 3, 4, 5],
  63. playing: true,
  64. };
  65. },
  66. computed: {
  67. ...mapGetters({
  68. info: "info",
  69. }),
  70. fallbackOpeningAnimationType() {
  71. return (val) => {
  72. if (!val) {
  73. return 1;
  74. } else {
  75. if (typeof val === "string") {
  76. if (val.match(/[\u3400-\u9FBF]/)) {
  77. return 1;
  78. } else {
  79. return Number(val.replace("opa", ""));
  80. }
  81. } else {
  82. return val;
  83. }
  84. }
  85. };
  86. },
  87. },
  88. methods: {
  89. bofang() {
  90. this.$refs.opvideo.play();
  91. },
  92. onSwitcherChange(data) {
  93. this.info.isShowOpeningAnimation = data;
  94. },
  95. },
  96. mounted() {
  97. if (this.info.isShowOpeningAnimation === undefined) {
  98. this.$set(this.info, "isShowOpeningAnimation", false);
  99. }
  100. if (
  101. !this.info.openingAnimationType ||
  102. (typeof this.info.openingAnimationType === "string" &&
  103. this.info.openingAnimationType.match(/[\u3400-\u9FBF]/))
  104. ) {
  105. this.$set(this.info, "openingAnimationType", this.openingTypeList[0]);
  106. }
  107. this.$nextTick(() => {
  108. // console.log(this.$refs.opvideo);
  109. this.$refs.opvideo &&
  110. this.$refs.opvideo.addEventListener("playing", () => {
  111. if (this.playing) {
  112. this.playing = false;
  113. }
  114. });
  115. });
  116. },
  117. };
  118. </script>
  119. <style lang="less" scoped>
  120. .opening-animation-settings {
  121. padding: 24px 30px;
  122. background: #252526;
  123. height: 546px;
  124. .title {
  125. font-size: 18px;
  126. color: #ffffff;
  127. }
  128. .switch-wrapper {
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. margin-top: 18px;
  133. .label {
  134. color: rgba(255, 255, 255, 0.6);
  135. font-size: 14px;
  136. }
  137. }
  138. .btns-and-video {
  139. margin-top: 16px;
  140. display: flex;
  141. align-items: flex-start;
  142. .btn-wrapper {
  143. .opening-selection-btn {
  144. width: 210px;
  145. height: 40px;
  146. background: #1a1b1d;
  147. border-radius: 2px;
  148. border: 1px solid #404040;
  149. margin-bottom: 16px;
  150. text-align: center;
  151. font-size: 14px;
  152. color: #fff;
  153. cursor: pointer;
  154. display: block;
  155. &::after {
  156. content: "";
  157. height: 100%;
  158. vertical-align: middle;
  159. display: inline-block;
  160. }
  161. }
  162. .active-opening-type {
  163. color: #0076f6;
  164. }
  165. }
  166. .video-wrapper {
  167. width: 469px;
  168. height: 264px;
  169. margin-left: 20px;
  170. position: relative;
  171. video {
  172. width: 100%;
  173. height: 100%;
  174. object-fit: cover;
  175. }
  176. .iconfont {
  177. position: absolute;
  178. font-size: 36px;
  179. top: 50%;
  180. left: 50%;
  181. transform: translate(-50%, -50%);
  182. cursor: pointer;
  183. }
  184. }
  185. }
  186. }
  187. </style>