SelectTone.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-prev-Textdes SelectTone" v-if="curQue">
  4. <ul>
  5. <li v-for="(item,index) in curQue.option" :key="index">
  6. <Audio
  7. :mp3="
  8. item.mp3_list.length > 0 ? item.mp3_list[0].url : ''"
  9. :themeColor="themeColor"
  10. class="audio-play"
  11. />
  12. <div v-html="item.con" class="con"></div>
  13. <a v-for="(itmes,indexs) in toneList" :key="indexs" :class="['tone-item',userSelect[index]===indexs?'active':'']" @click="handleClick(index,indexs)">
  14. <img :src="itmes">
  15. </a>
  16. </li>
  17. </ul>
  18. </div>
  19. </template>
  20. <script>
  21. import Audio from "../preview/components/AudioRed.vue"; // 音频播放
  22. export default {
  23. components: {Audio},
  24. props: ["curQue","themeColor"],
  25. data() {
  26. return {
  27. toneList: [
  28. require('../../../assets/NPC/tone1.png'),
  29. require('../../../assets/NPC/tone2.png'),
  30. require('../../../assets/NPC/tone3.png'),
  31. require('../../../assets/NPC/tone4.png'),
  32. require('../../../assets/NPC/tone0.png')
  33. ],
  34. userSelect:[]
  35. };
  36. },
  37. computed: {},
  38. watch: {},
  39. //方法集合
  40. methods: {
  41. // 处理数据
  42. handleData(){
  43. let _this = this
  44. _this.userSelect = []
  45. _this.curQue.option.forEach(item => {
  46. _this.userSelect.push('')
  47. });
  48. },
  49. handleClick(index,indexs){
  50. this.$set(this.userSelect,index,indexs)
  51. }
  52. },
  53. //生命周期 - 创建完成(可以访问当前this实例)
  54. created() {
  55. },
  56. //生命周期 - 挂载完成(可以访问DOM元素)
  57. mounted() {},
  58. beforeCreate() {}, //生命周期 - 创建之前
  59. beforeMount() {}, //生命周期 - 挂载之前
  60. beforeUpdate() {}, //生命周期 - 更新之前
  61. updated() {}, //生命周期 - 更新之后
  62. beforeDestroy() {}, //生命周期 - 销毁之前
  63. destroyed() {}, //生命周期 - 销毁完成
  64. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  65. };
  66. </script>
  67. <style lang='scss' scoped>
  68. //@import url(); 引入公共css类
  69. .Big-Book-prev-Textdes{
  70. width: 100%;
  71. ul{
  72. display: flex;
  73. flex-flow: wrap;
  74. justify-content: space-between;
  75. align-items: flex-start;
  76. li{
  77. width: 363px;
  78. background: #FFFFFF;
  79. border: 1px solid rgba(0, 0, 0, 0.1);
  80. box-sizing: border-box;
  81. border-radius: 8px;
  82. display: flex;
  83. align-items: center;
  84. padding: 8px 12px 8px 16px;
  85. margin: 8px 0;
  86. .audio-play{
  87. width: 16px;
  88. margin-right: 12px;
  89. }
  90. >div.con{
  91. font-size: 16px;
  92. line-height: 1.5;
  93. flex: 1;
  94. margin: 0;
  95. }
  96. a{
  97. margin-left: 8px;
  98. &.active{
  99. background: #98D1EB;
  100. border-radius: 4px;
  101. }
  102. img{
  103. width: 24px;
  104. }
  105. }
  106. }
  107. }
  108. }
  109. </style>
  110. <style lang="scss">
  111. .SelectTone.Big-Book-prev-Textdes{
  112. ul{
  113. li{
  114. div.con{
  115. margin: 0 ;
  116. >p{
  117. margin: 0;
  118. }
  119. }
  120. }
  121. }
  122. }
  123. </style>