explainJs.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <van-overlay z-index="10" :show="show">
  3. <div class="skills-box">
  4. <div class="skills">
  5. <div class="title">官方解释</div>
  6. <div class="text">{{ explainJs }}</div>
  7. <div class="btn">
  8. <span
  9. @click="
  10. () => {
  11. $emit('close');
  12. }
  13. "
  14. >
  15. 关闭
  16. </span>
  17. <span
  18. @click="
  19. () => {
  20. playExplainjsmp3();
  21. }
  22. "
  23. >
  24. 语音重播
  25. </span>
  26. </div>
  27. </div>
  28. </div>
  29. </van-overlay>
  30. </template>
  31. <script>
  32. import utils from "@/utils/index";
  33. export default {
  34. data() {
  35. return {};
  36. },
  37. methods: {
  38. playExplainjsmp3() {
  39. let audio = utils.wxUtils.getGlobAudio();
  40. audio.stop();
  41. audio.src = this.explainjsmp3;
  42. audio.onCanplay(() => {
  43. console.log("onCanplay");
  44. });
  45. audio.onPlay(() => {
  46. console.log("onPlay");
  47. });
  48. audio.onError((res) => {
  49. console.log(res);
  50. });
  51. //体验比较好
  52. setTimeout(() => {
  53. audio.play();
  54. }, 1000);
  55. },
  56. },
  57. watch: {
  58. show(newValue, oldValue) {
  59. let audio = utils.wxUtils.getGlobAudio();
  60. if (newValue) {
  61. audio.src = this.explainjsmp3;
  62. audio.play();
  63. } else {
  64. audio.stop();
  65. }
  66. },
  67. },
  68. props: {
  69. show: {
  70. type: Boolean,
  71. default: false,
  72. },
  73. explainJs: {
  74. type: String,
  75. default: "",
  76. },
  77. explainjsmp3: {
  78. type: String,
  79. default: "",
  80. },
  81. },
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .skills-box {
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. height: 100%;
  90. .skills {
  91. width: 290px;
  92. background: #ffffff;
  93. box-shadow: 0px 0px 8px rgba(124, 129, 136, 0.16);
  94. border-radius: 10px;
  95. display: flex;
  96. flex-direction: column;
  97. align-items: center;
  98. padding: 20px 16px;
  99. box-sizing: border-box;
  100. .title {
  101. font-size: 15px;
  102. font-family: PingFang SC;
  103. font-weight: bold;
  104. line-height: 21px;
  105. color: #0a1a33;
  106. }
  107. .img {
  108. width: 258px;
  109. height: 129px;
  110. border: 1px solid #e8e8e8;
  111. margin-top: 16px;
  112. }
  113. .divider {
  114. margin-top: 20px;
  115. color: #0a1a33;
  116. background: #ffffff;
  117. }
  118. .text {
  119. font-size: 13px;
  120. font-family: PingFang SC;
  121. font-weight: 400;
  122. line-height: 19px;
  123. color: #5c6066;
  124. margin-top: 10px;
  125. }
  126. .btn {
  127. width: 100%;
  128. display: flex;
  129. justify-content: space-between;
  130. padding: 0 40px;
  131. box-sizing: border-box;
  132. margin-top: 20px;
  133. span {
  134. width: 76px;
  135. height: 30px;
  136. border-radius: 15px;
  137. font-size: 13px;
  138. display: flex;
  139. justify-content: center;
  140. align-items: center;
  141. &:active {
  142. background-color: #afaaaa;
  143. filter: brightness(50%);
  144. }
  145. &:nth-of-type(1) {
  146. border: 1px solid #707070;
  147. color: #5c6066;
  148. }
  149. &:nth-of-type(2) {
  150. background: #498ef5;
  151. border: 1px solid #498ef5;
  152. color: #ffffff;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. </style>