| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- <!-- -->
- <template>
- <div
- class="Big-Book-prev-Textdes SelectYinjie SelectYinjie-phone"
- v-if="isShowTemp"
- >
- <div class="SelectYinjie-inner">
- <div
- class="aduioLine-box"
- v-if="
- curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].id
- "
- :style="{ height: judgeAnswer == 'standardAnswer' ? '0px' : 'auto' }"
- >
- <AudioLine
- audioId="SelectYinjieAudio"
- :mp3="curQue.mp3_list[0].id"
- :getCurTime="getCurTime"
- :themeColor="themeColor"
- :ed="ed"
- type="audioLine"
- ref="audioLine"
- @handleListenRead="handleListenRead"
- :baseSizePhone="baseSizePhone"
- />
- </div>
- <div v-for="(item, index) in curQue.option" :key="index">
- <div class="item-box" v-if="isShowOption(item, index)">
- <a
- v-if="curQue.wordTime && curQue.wordTime.length > 0"
- :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>
- <b
- v-if="item.number"
- :style="{
- fontSize: baseSizePhone - 2 + 'px',
- width: 18 + (baseSizePhone - 14) * 2 + 'px',
- height: 18 + (baseSizePhone - 14) * 2 + 'px'
- }"
- >{{ item.number }}</b
- >
- <div class="zijie-box">
- <p
- :class="[
- !judgeAnswer ? 'exercise-model' : '',
- lookanswerClass(index, indexs)
- ]"
- v-for="(items, indexs) in item.option"
- :key="indexs"
- @click="handleClick(index, indexs)"
- :style="{ fontSize: baseSizePhone + 'px' }"
- >
- {{ items.pinyin }}
- </p>
- </div>
- <a
- v-if="!judgeAnswer"
- :class="[
- 'clear-btn',
- curQue.Bookanswer[index].length > 0 && TaskModel != 'ANSWER'
- ? 'active'
- : '',
- TaskModel == 'ANSWER' ? 'notAllow' : ''
- ]"
- @click="handleClear(index)"
- ></a>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import AudioLine from "../phonePreview/AudioLine.vue";
- export default {
- components: { AudioLine },
- props: ["curQue", "themeColor", "TaskModel", "judgeAnswer", "baseSizePhone"],
- data() {
- return {
- userList: [],
- curTime: 0,
- stopAudio: false,
- ed: null
- };
- },
- computed: {
- lookanswerClass() {
- return function(index, indexs) {
- let _this = this;
- let className = "";
- let userAnswer = this.curQue.Bookanswer[index].value.toString();
- if (this.curQue.option[index].answer) {
- let answer = (this.curQue.option[index].answer - 1).toString();
- if (_this.judgeAnswer == "standardAnswer") {
- if (indexs.toString() === answer) {
- className = "userRight";
- } else {
- className = "";
- }
- } else if (
- _this.judgeAnswer == "userAnswer" ||
- _this.judgeAnswer == "studentAnswer"
- ) {
- if (indexs.toString() === userAnswer) {
- if (answer === userAnswer) {
- className = "userRight";
- } else {
- className = "userError";
- }
- } else {
- className = "";
- }
- }
- } else {
- if (_this.judgeAnswer && userAnswer == indexs.toString()) {
- className = "userNoAnswer";
- }
- }
- if (!_this.judgeAnswer && userAnswer == indexs.toString()) {
- className = "active";
- }
- return className;
- };
- },
- isShowTemp() {
- let _this = this;
- let bool = false;
- if (_this.curQue && _this.curQue.Bookanswer) {
- if (_this.judgeAnswer == "standardAnswer") {
- if (_this.userErrorNumberTotal > 0) {
- bool = true;
- } else {
- bool = false;
- }
- } else {
- bool = true;
- }
- }
- return bool;
- },
- isShowOption() {
- return function(item, index) {
- let _this = this;
- let bool = true;
- if (_this.judgeAnswer == "standardAnswer") {
- if (!item.answer) {
- bool = false;
- } else if (
- _this.curQue.Bookanswer[index].userAnswerJudge ==
- "[JUDGE##T##JUDGE]"
- ) {
- bool = false;
- }
- }
- return bool;
- };
- }
- },
- watch: {},
- //方法集合
- methods: {
- // 处理数据
- handleData() {
- let _this = this;
- let option = JSON.parse(JSON.stringify(_this.curQue.option));
- option.forEach((item, index) => {
- item.answer = null;
- for (let i = 0; i < item.option.length; i++) {
- let oItem = item.option[i];
- if (oItem.isAnswer) {
- item.answer = i + 1;
- break;
- }
- }
- });
- _this.$set(_this.curQue, "option", JSON.parse(JSON.stringify(option)));
- if (!_this.curQue.Bookanswer) {
- let userSelect = [];
- _this.curQue.option.forEach(item => {
- let obj = {
- value: "",
- userAnswerJudge: item.answer ? "[JUDGE##F##JUDGE]" : ""
- };
- userSelect.push(JSON.parse(JSON.stringify(obj)));
- });
- _this.$set(this.curQue, "Bookanswer", userSelect);
- } else {
- let BookanswerStr = JSON.stringify(_this.curQue.Bookanswer);
- let errReg = /\[JUDGE##F##JUDGE\]/g;
- if (errReg.test(BookanswerStr)) {
- let errorArr = BookanswerStr.match(/\[JUDGE##F##JUDGE\]/g);
- _this.userErrorNumberTotal = errorArr.length;
- }
- }
- },
- handleClick(index, indexs) {
- let _this = this;
- if (
- !_this.TaskModel ||
- _this.TaskModel != "ANSWER" ||
- !_this.judgeAnswer
- ) {
- _this.$set(_this.curQue.Bookanswer[index], "value", indexs);
- if (_this.curQue.option[index].answer) {
- let answer = _this.curQue.option[index].answer - 1;
- if (indexs.toString() === answer.toString()) {
- _this.$set(
- _this.curQue.Bookanswer[index],
- "userAnswerJudge",
- "[JUDGE##T##JUDGE]"
- );
- } else {
- _this.$set(
- _this.curQue.Bookanswer[index],
- "userAnswerJudge",
- "[JUDGE##F##JUDGE]"
- );
- }
- }
- }
- _this.$forceUpdate();
- },
- handleClear(index) {
- let _this = this;
- _this.$set(_this.curQue.Bookanswer[index], "value", "");
- let userAnswerJudge = _this.curQue.option[index].answer
- ? "[JUDGE##F##JUDGE]"
- : "";
- _this.$set(
- _this.curQue.Bookanswer[index],
- "userAnswerJudge",
- userAnswerJudge
- );
- _this.$forceUpdate();
- },
- getCurTime(curTime) {
- this.curTime = curTime * 1000;
- },
- //点击播放某个句子
- handleChangeTime(time, edTime) {
- let _this = this;
- _this.curTime = time;
- _this.stopAudio = true;
- _this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
- _this.ed = edTime;
- },
- handleListenRead(playFlag) {
- this.stopAudio = playFlag;
- },
- emptyEd() {
- this.ed = null;
- }
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- this.handleData();
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang="scss" scoped>
- //@import url(); 引入公共css类
- .SelectYinjie {
- width: 100%;
- &-inner {
- width: 100%;
- // background: #f7f7f7;
- border: 1px solid rgba(0, 0, 0, 0.1);
- box-sizing: border-box;
- border-radius: 8px;
- padding: 10px;
- }
- .aduioLine-box {
- margin-bottom: 8px;
- }
- .item-box {
- display: flex;
- align-items: center;
- // background: #ffffff;
- padding: 4px 12px;
- border: 1px solid rgba(0, 0, 0, 0.1);
- border-radius: 8px;
- margin-bottom: 8px;
- .audio-play {
- width: 16px;
- margin-right: 8px;
- }
- b {
- background: #de4444;
- text-align: center;
- min-width: 14px;
- // min-height: 16px;
- max-width: 28px;
- max-height: 28px;
- color: #ffffff;
- border-radius: 50%;
- font-size: 12px;
- font-family: "robot";
- line-height: 1.3;
- padding: 2px;
- display: block;
- }
- .play-btn {
- width: 16px;
- height: 16px;
- margin-right: 8px;
- background: url("../../../assets/NPC/play-red.png") center no-repeat;
- background-size: cover;
- &.active {
- background-image: url("../../../assets/NPC/icon-voice-play-red.png");
- background-size: cover;
- }
- }
- .zijie-box {
- flex: 1;
- display: flex;
- padding: 0 4px;
- flex-flow: wrap;
- p {
- margin: 4px;
- font-size: 14px;
- line-height: 22px;
- color: rgba(0, 0, 0, 0.85);
- min-width: 56px;
- padding: 4px 12px;
- border-radius: 4px;
- border: 1px solid rgba(0, 0, 0, 0.1);
- text-align: center;
- cursor: pointer;
- font-family: "GB-PINYINOK-B";
- overflow: hidden;
- &.exercise-model:hover {
- background: rgba(0, 0, 0, 0.05)
- url("../../../assets/NPC/selectYinjie-hover.png") right bottom
- no-repeat;
- background-size: 11px;
- border: 1px solid rgba(0, 0, 0, 0.1);
- }
- &.active {
- background: rgba(0, 188, 75, 0.05)
- url("../../../assets/NPC/selectYinjie-active.png") right bottom
- no-repeat !important;
- background-size: 11px !important;
- border: 1px solid #00bc4b !important;
- }
- &.userRight {
- background: rgba(44, 167, 103, 0.1);
- border-color: #2ca767;
- }
- &.userError {
- background: rgba(237, 52, 45, 0.1);
- border-color: #ed342d;
- }
- &.userNoAnswer {
- background: #fff;
- border-color: #000;
- }
- }
- }
- .clear-btn {
- width: 16px;
- height: 16px;
- background: url("../../../assets/icon/Undofill-16-disable-Black.png")
- center no-repeat;
- background-size: 100%;
- &.active {
- background: url("../../../assets/icon/Undofill-16-normal-Black.png")
- center no-repeat;
- background-size: 100%;
- }
- &.notAllow {
- cursor: not-allowed;
- }
- }
- }
- }
- .NPC-Big-Book-preview-green {
- .SelectYinjie {
- .item-box {
- 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 {
- .SelectYinjie {
- .item-box {
- 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;
- }
- }
- }
- }
- }
- .SelectYinjie-phone {
- .SelectYinjie-inner {
- padding: 10px;
- }
- }
- </style>
|