123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <!-- -->
- <template>
- <div class="Big-Book-prev-Textdes SelectTone" v-if="curQue">
- <div
- class="aduioLine-box"
- v-if="
- curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].id
- "
- >
- <AudioLine
- audioId="sentenceListenAudio"
- :mp3="curQue.mp3_list[0].id"
- :getCurTime="getCurTime"
- :themeColor="themeColor"
- :ed="ed"
- type="audioLine"
- ref="audioLine"
- @handleListenRead="handleListenRead"
- />
- </div>
- <ul>
- <li v-for="(item, index) in curQue.option" :key="index">
- <a
- :class="[
- 'play-btn',
- curTime >= curQue.wordTime[index].bg &&
- curTime < curQue.wordTime[index].ed &&
- stopAudio
- ? 'active'
- : '',
- ]"
- @click="handleChangeTime(curQue.wordTime[index].bg,curQue.wordTime[index].ed)"
- ></a>
- <!-- <Audio
- :mp3="item.mp3_list.length > 0 ? item.mp3_list[0].url : ''"
- :themeColor="themeColor"
- class="audio-play"
- /> -->
- <div v-html="item.con" class="con"></div>
- <a
- v-for="(itmes, indexs) in toneList"
- :key="indexs"
- :class="['tone-item', curQue.Bookanswer[index] === indexs ? 'active' : '']"
- @click="handleClick(index, indexs)"
- >
- <img :src="itmes" />
- </a>
- </li>
- </ul>
- </div>
- </template>
- <script>
- import Audio from "../preview/components/AudioRed.vue"; // 音频播放
- import AudioLine from "../preview/AudioLine.vue";
- export default {
- components: { Audio, AudioLine },
- props: ["curQue", "themeColor","TaskModel"],
- data() {
- return {
- toneList: [
- require("../../../assets/NPC/tone1.png"),
- require("../../../assets/NPC/tone2.png"),
- require("../../../assets/NPC/tone3.png"),
- require("../../../assets/NPC/tone4.png"),
- require("../../../assets/NPC/tone0.png"),
- ],
- userSelect: [],
- curTime: "",
- stopAudio: false,
- timer: null,
- ed: null,
- };
- },
- computed: {},
- watch: {},
- //方法集合
- methods: {
- // 处理数据
- handleData() {
- let _this = this;
- let userSelect = [];
- _this.curQue.option.forEach((item) => {
- userSelect.push("");
- });
- if (!this.curQue.Bookanswer) {
- this.$set(this.curQue, "Bookanswer", userSelect);
- }
- },
- handleClick(index, indexs) {
- if(!this.TaskModel||this.TaskModel!='ANSWER'){
- this.$set(this.curQue.Bookanswer, index, indexs);
- }
- },
- handleChangeTime(time,edTime) {
- let _this = this;
- // if(!_this.stopAudio){
- // _this.timer = setInterval(() => {
- // if(_this.curTime >= edTime){
- // _this.stopAudio = false
- // _this.$refs.audioLine.onTimeupdateTime(_this.curTime / 1000, false);
- // clearInterval(_this.timer);
- // }
- // }, 200);
- // }
- _this.curTime = time;
- _this.stopAudio = true
- _this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
- _this.ed = edTime
- },
- getCurTime(curTime) {
- this.curTime = curTime * 1000;
- },
- handleListenRead(playFlag) {
- this.stopAudio = playFlag;
- if(this.timer){
- clearInterval(this.timer);
- }
- },
- emptyEd(){
- this.ed = null;
- }
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- if(this.timer){
- clearInterval(this.timer);
- }
- this.handleData()
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {
- if(this.timer){
- clearInterval(this.timer);
- }
- }, //生命周期 - 销毁之前
- destroyed() {
- if(this.timer){
- clearInterval(this.timer);
- }
- }, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='scss' scoped>
- //@import url(); 引入公共css类
- .Big-Book-prev-Textdes {
- width: 100%;
- background: #f7f7f7;
- border: 1px solid rgba(0, 0, 0, 0.1);
- box-sizing: border-box;
- border-radius: 8px;
- overflow: hidden;
- ul {
- display: flex;
- flex-flow: wrap;
- justify-content: space-between;
- align-items: flex-start;
- padding: 24px 12px;
- li {
- width: 363px;
- background: #ffffff;
- border: 1px solid rgba(0, 0, 0, 0.1);
- box-sizing: border-box;
- border-radius: 8px;
- display: flex;
- align-items: center;
- padding: 8px 12px 8px 16px;
- margin: 8px 0;
- .play-btn {
- width: 16px;
- height: 16px;
- background: url("../../../assets/NPC/play-red.png") center no-repeat;
- background-size: cover;
- margin-right: 8px;
- &.active {
- background-image: url("../../../assets/NPC/icon-voice-play-red.png");
- background-size: cover;
- }
- }
- .audio-play {
- width: 16px;
- margin-right: 12px;
- }
- > div.con {
- font-size: 16px;
- line-height: 1.5;
- flex: 1;
- margin: 0;
- }
- a {
- margin-left: 8px;
- font-size: 0;
- &.active {
- background: #98d1eb;
- border-radius: 4px;
- }
- img {
- width: 24px;
- }
- }
- }
- }
- }
- .NPC-Big-Book-preview-green {
- .Big-Book-prev-Textdes {
- li {
- b {
- background: #24b99e;
- }
- .play-btn {
- background: url("../../../assets/NPC/play-green.png") center no-repeat;
- background-size: cover;
- &.active {
- background-image: url("../../../assets/NPC/icon-voice-play-green.png");
- background-size: cover;
- }
- }
- }
- }
- }
- .NPC-Big-Book-preview-brown {
- .Big-Book-prev-Textdes {
- li {
- b {
- background: #bd8865;
- }
- .play-btn {
- background: url("../../../assets/NPC/play-brown.png") center no-repeat;
- background-size: cover;
- &.active {
- background-image: url("../../../assets/NPC/icon-voice-play-brown.png");
- background-size: cover;
- }
- }
- }
- }
- }
- </style>
- <style lang="scss">
- .SelectTone.Big-Book-prev-Textdes {
- ul {
- li {
- div.con {
- margin: 0;
- > p {
- margin: 0;
- }
- }
- }
- }
- }
- </style>
|