Dialogue.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-prev-Textdes" v-if="curQue">
  4. <div
  5. :class="item.site == 'left' ? 'left' : 'right'"
  6. v-for="(item, index) in curQue.option"
  7. :key="item.hanzi + index"
  8. >
  9. <template v-if="item.site == 'left'">
  10. <img
  11. v-if="item.img_list.length > 0"
  12. :src="item.img_list[0].url"
  13. alt=""
  14. />
  15. <div>
  16. <p>{{ item.hanzi }}</p>
  17. <div @click="playAudio(item.mp3_list[0], index)" class="audioList">
  18. <img src="../../../assets/adult/Dialogue-audio.png" alt="" />
  19. <span>3s</span>
  20. <audio
  21. :id="item.mp3_list[0].name + index"
  22. v-if="item.mp3_list.length > 0"
  23. :src="item.mp3_list[0].url"
  24. ></audio>
  25. </div>
  26. <div class="imglist">
  27. <img
  28. v-for="it in item.img_list"
  29. :key="it.id"
  30. :src="it.url"
  31. class="img"
  32. />
  33. </div>
  34. </div>
  35. </template>
  36. <template v-else>
  37. <div>
  38. <p>{{ item.hanzi }}</p>
  39. <div @click="playAudio(item.mp3_list[0], index)" class="audioList">
  40. <img src="../../../assets/adult/Dialogue-audio.png" alt="" />
  41. <span>3s</span>
  42. <audio
  43. :id="item.mp3_list[0].name + index"
  44. v-if="item.mp3_list.length > 0"
  45. :src="item.mp3_list[0].url"
  46. ></audio>
  47. </div>
  48. <div class="imglist">
  49. <img
  50. v-for="it in item.img_list"
  51. :key="it.id"
  52. :src="it.url"
  53. class="img"
  54. />
  55. </div>
  56. </div>
  57. </template>
  58. </div>
  59. <div class="clear"></div>
  60. </div>
  61. </template>
  62. <script>
  63. export default {
  64. components: {},
  65. props: ["curQue"],
  66. data() {
  67. return {};
  68. },
  69. computed: {},
  70. watch: {},
  71. //方法集合
  72. methods: {
  73. playAudio(item, index) {
  74. let audioplay = document.getElementById(`${item.name}${index}`);
  75. audioplay.play();
  76. },
  77. },
  78. //生命周期 - 创建完成(可以访问当前this实例)
  79. created() {
  80. console.log(this.curQue);
  81. },
  82. //生命周期 - 挂载完成(可以访问DOM元素)
  83. mounted() {},
  84. beforeCreate() {}, //生命周期 - 创建之前
  85. beforeMount() {}, //生命周期 - 挂载之前
  86. beforeUpdate() {}, //生命周期 - 更新之前
  87. updated() {}, //生命周期 - 更新之后
  88. beforeDestroy() {}, //生命周期 - 销毁之前
  89. destroyed() {}, //生命周期 - 销毁完成
  90. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  91. };
  92. </script>
  93. <style lang='scss' scoped>
  94. //@import url(); 引入公共css类
  95. .Big-Book-prev-Textdes {
  96. width: 1000px;
  97. > .left {
  98. margin-top: 16px;
  99. display: flex;
  100. > img {
  101. width: 40px;
  102. height: 40px;
  103. border-radius: 50%;
  104. }
  105. > div {
  106. margin-left: 16px;
  107. padding: 16px;
  108. background: #ffffff;
  109. border: 1px solid rgba(0, 0, 0, 0.1);
  110. box-sizing: border-box;
  111. box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
  112. border-radius: 4px;
  113. .audioList {
  114. width: 144px;
  115. height: 40px;
  116. background: #ffffff;
  117. border: 1px solid rgba(0, 0, 0, 0.1);
  118. box-sizing: border-box;
  119. border-radius: 4px;
  120. display: flex;
  121. justify-content: space-between;
  122. align-items: center;
  123. padding: 0 5px;
  124. cursor: pointer;
  125. span {
  126. opacity: 0.4;
  127. }
  128. }
  129. .imglist {
  130. margin-top: 8px;
  131. img {
  132. margin-right: 2px;
  133. }
  134. }
  135. }
  136. }
  137. > .right {
  138. float: right;
  139. margin-top: 16px;
  140. display: flex;
  141. > img {
  142. width: 40px;
  143. height: 40px;
  144. border-radius: 50%;
  145. }
  146. > div {
  147. margin-right: 16px;
  148. padding: 16px;
  149. background: #eff9ff;
  150. border: 1px solid rgba(0, 0, 0, 0.1);
  151. box-sizing: border-box;
  152. box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
  153. border-radius: 4px;
  154. .audioList {
  155. width: 144px;
  156. height: 40px;
  157. background: #eff9ff;
  158. border: 1px solid rgba(0, 0, 0, 0.1);
  159. box-sizing: border-box;
  160. border-radius: 4px;
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. padding: 0 5px;
  165. cursor: pointer;
  166. span {
  167. opacity: 0.4;
  168. }
  169. }
  170. .imglist {
  171. margin-top: 8px;
  172. img {
  173. margin-right: 2px;
  174. }
  175. }
  176. }
  177. }
  178. .clear {
  179. clear: both;
  180. }
  181. }
  182. </style>