123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908 |
- <template>
- <!-- 根据图片完成对话 -->
- <div class="SelectCorrect writeDialogueD">
- <div class="SelectCorrect-top">
- <img alt src="../../assets/qp/Ellipse 27.png">
- <img alt src="../../assets/qp/Ellipse 28.png">
- <img alt src="../../assets/qp/Ellipse 29.png">
- </div>
- <div class="SelectCorrect-main">
- <div class="dialog-maxHeight">
- <div class="left">
- <img alt src="../../assets/dialogue/Ellipse 41.png">
- <img alt class="wx-arrow" src="../../assets/dialogue/Rectangle 540.png">
- <div class="dialogue_content_box">
- <div class="bubble" v-if="cur.stem[0].mp3_url">
- <div class="bubble_dv">
- <VoicePlay
- :mp3="cur.stem[0].mp3_url"
- :seconds="cur.stem[0].duration+'’’'"
- v-if="cur.stem[0].mp3_url && cur.stem[0].mp3_url.indexOf('http') > -1"
- />
- </div>
- </div>
- <div
- :class="['translate_box',cur.stem[0].mp3_url?'':'novoice']"
- v-if="cur.stem[0].english||cur.stem[0].con"
- >
- <div class="translate">
- <div :key="index" v-for="(item,index) in stemCn">
- <p
- :class="bd.indexOf(stemPy[index]) != -1 ? 'pinyin_hidden' : 'spell'"
- v-if="lanactiveArr.indexOf('简单')>-1"
- >{{stemPy[index]}}</p>
- <p class="chinese">{{item}}</p>
- </div>
- </div>
- <p
- class="english"
- v-if="lanactiveArr.indexOf('简单')>-1"
- >{{cur.stem[0].english}}</p>
- </div>
- </div>
- </div>
- <div :key="index" class="micro-box" v-for="(item,index) in wavList">
- <div class="right">
- <div class="bubble">
- <div class="r_bubble_dv">
- <VoicePlay :seconds="item.seconds+'’’'" :wav="item.wav"/>
- </div>
- </div>
- <img alt class="wx-arrow" src="../../assets/dialogue/Rectangle 556.png">
- <img alt src="../../assets/dialogue/Ellipse 46.png">
- </div>
- </div>
- </div>
- <div class="bottom">
- <div class="bottom_top">
- <div class="switch">
- <!-- <img
- @click="lanShow =!lanShow"
- alt
- class="switchBtn"
- src="../../assets/dialogue/Group 1991.png"
- >-->
- <ul>
- <li
- :class="lanactiveArr.indexOf(item)>-1?'active':''"
- :key="index"
- @click="changeLan(item,index)"
- v-for="(item,index) in languageArr"
- >{{item}}</li>
- </ul>
- </div>
- </div>
- <div class="bottom_main">
- <div :class="['bottom-right']" @click="microphone()">
- <div class="bottom-right_record">
- <img alt src="../../assets/dialogue/maikefeng-red.png">
- {{rightBtn}}
- </div>
- <img alt src="../../assets/dialogue/Ellipse 46.png">
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Recorder from "js-audio-recorder"; //录音插件
- import VoicePlay from "../../components/common/VoicePlay";
- export default {
- props: [
- "cur",
- "getAnswer",
- "queIndex",
- "answer",
- "uiType",
- "watchIndex"
- ],
- components: {
- VoicePlay
- },
- data () {
- return {
- anwser: "",
- languageArr: [
- '简单',
- '困难'
- ],
- lanactiveArr: [
- '简单'
- ],
- lanShow: false, // 语言分类按钮是否显示
- stemCn: [], // 题干 中文
- stemPy: [], // 题干 拼音
- optionCn: [], // 回复 中文
- optionPy: [],// 回复 英文
- wavList: [], // 录音数组
- recorder: new Recorder({
- sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
- sampleRate: 16000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
- numChannels: 1, // 声道,支持 1 或 2, 默认是1
- }),
- microphoneStatus: false,
- rightBtn: "点击录音",
- wavblob: null,
- microphoneBtn: null, // 当前正在录音的按钮
- bd: [
- ",",
- ",",
- "。",
- ".",
- "!",
- "?",
- ":",
- ";",
- "(",
- ")",
- "【",
- "】",
- "{",
- "}",
- "‘",
- "“",
- "’",
- "”",
- "、",
- "、",
- "《",
- "》",
- "…",
- "·",
- "—",
- "~"
- ],
- };
- },
- watch: {
- watchIndex: {
- handler: function (val, oldVal) {
- let _this = this;
- if (val) {
- _this.handleData()
- }
- },
- // 深度观察监听
- deep: true,
- },
- },
- methods: {
- handleBookAnswer (e) {
- let value = e.trim()
- this.userAnswer = []
- this.userAnswer.push(value)
- this.getAnswer(this.userAnswer, this.queIndex)
- this.cur.Bookanswer = this.userAnswer
- },
- handleData () {
- this.stemCn = this.cur.stem[0].con.split("")
- this.stemPy = this.cur.stem[0].pinyin.split(" ")
- this.optionCn = this.cur.stem[1].con.replace(/_/g, "^").split("")
- this.optionPy = this.cur.stem[1].pinyin.replace(/_/g, "^").split(" ")
- this.optionCn.forEach((item, index) => {
- if (this.optionCn[index - 1] && this.optionCn[index - 1] == item && item == '^') {
- this.optionCn.splice(index, 1)
- }
- })
- if (this.cur.Bookanswer) {
- this.wavList = this.cur.Bookanswer
- } else {
- this.wavList = []
- }
- },
- // 切换语言
- changeLan (item, index) {
- this.lanactiveArr = item
- },
- // 开始录音
- microphone () {
- if (!this.microphoneStatus) {
- //开始录音
- this.recorder.start();
- this.microphoneStatus = true;
- this.rightBtn = '录音中...'
- } else {
- this.recorder.stop();
- let toltime = this.recorder.duration; //录音总时长
- let fileSize = this.recorder.fileSize; //录音总大小
- //录音结束,获取取录音数据
- let PCMBlob = this.recorder.getPCMBlob(); //获取 PCM 数据
- let wav = this.recorder.getWAVBlob(); //获取 WAV 数据
- this.wavblob = wav;
- this.microphoneStatus = false;
- this.microphoneBtn = null
- let wavResult = null
- var reader = new window.FileReader();
- reader.readAsDataURL(wav);
- let _this = this
- reader.onloadend = function() {
- wavResult = reader.result
- let obj = {
- wav: wavResult,
- seconds: Math.ceil(toltime)
- }
- _this.wavList.push(obj)
- _this.cur.Bookanswer = _this.wavList
- }
- this.rightBtn = '点击录音'
- }
- },
- // 判断对错
- practiceJudge () {
- if(this.cur.Bookanswer){
- return true
- }else{
- return false
- }
- }
- },
- created () {
- this.handleData()
- },
- };
- </script>
- <style lang="scss" scoped>
- * {
- margin: 0;
- padding: 0;
- }
- .SelectCorrect {
- width: 1200px;
- height: 708px;
- margin: 76px auto 0 auto;
- background: #fff;
- border-radius: 24px;
- box-shadow: 0px 6px 0px rgba(239, 167, 28, 0.4);
- .SelectCorrect-top {
- width: 100%;
- height: 60px;
- background: rgba(255, 214, 107, 0.3);
- border-top-left-radius: 24px;
- border-top-right-radius: 24px;
- display: flex;
- align-items: center;
- > img {
- margin-left: 20px;
- width: 24px;
- }
- }
- .SelectCorrect-main {
- background: #fff;
- padding: 48px 0px 0px 0;
- border-bottom-left-radius: 24px;
- border-bottom-right-radius: 24px;
- .img1 {
- text-align: center;
- border-bottom: 1px solid #e5e5e5;
- /* height: 120px;
- background: url("../../assets/dialogue/Group 1970.png") no-repeat */
- }
- &::after {
- content: '';
- display: block;
- height: 0;
- clear: both;
- visibility: hidden;
- }
- }
- .left {
- display: flex;
- align-items: flex-start;
- position: relative;
- margin-left: 60px;
- > img {
- width: 84px;
- }
- .wx-arrow {
- width: 12px;
- margin-top: 34px;
- margin-left: 24px;
- }
- .dialogue_content_box {
- padding-top: 10px;
- }
- .translate_box {
- background: #f6f6f6;
- border-radius: 14px;
- padding: 9px 20px;
- max-width: 600px;
- &.novoice {
- background: #e1f2fa;
- min-height: 68px;
- }
- }
- .translate {
- display: inline-block;
- align-items: center;
- color: #2c2c2c;
- > div {
- margin-left: 3px;
- text-align: center;
- float: left;
- }
- .spell {
- font-family: 'GB-PINYINOK-B';
- font-style: normal;
- font-weight: normal;
- font-size: 18px;
- height: 24px;
- }
- .chinese {
- font-family: 'FZJCGFKTK';
- font-style: normal;
- font-weight: normal;
- font-size: 36px;
- }
- }
- .english {
- color: #2c2c2c;
- font-size: 16px;
- line-height: 20px;
- // font-family: sourceR;
- display: block;
- margin-left: 5px;
- }
- }
- .wx-arrow {
- margin-bottom: 8px;
- }
- .right {
- display: flex;
- align-items: flex-start;
- justify-content: flex-end;
- margin-top: 44px;
- margin-right: 60px;
- > img {
- width: 84px;
- }
- .wx-arrow {
- width: 12px;
- margin-top: 34px;
- margin-right: 24px;
- }
- .dialogue_content_box {
- padding-top: 10px;
- }
- .translate_box {
- background: #f6f6f6;
- &.novoice {
- background: #f6f6f6;
- }
- }
- .bubble {
- justify-content: flex-end;
- .bubble_dv {
- background: #f6f6f6;
- }
- }
- }
- .bubble {
- display: flex;
- align-items: center;
- // padding: 0 24px;
- .bubble_dv {
- width: 200px;
- height: 72px;
- background: #e1f2fa;
- border-radius: 14px;
- font-size: 24px;
- display: flex;
- align-items: center;
- cursor: pointer;
- margin-bottom: 8px;
- > img {
- margin-left: 20px;
- }
- > span {
- margin-left: 10px;
- }
- }
- .r_bubble_dv {
- min-height: 72px;
- background: #eeeeee;
- border-radius: 14px;
- font-size: 24px;
- display: flex;
- align-items: center;
- max-width: 600px;
- margin-top: 8px;
- > img {
- margin-left: 20px;
- }
- > span {
- margin-left: 10px;
- }
- .translate {
- display: flex;
- align-items: center;
- padding: 0px 20px;
- color: #2c2c2c;
- > div {
- margin-left: 5px;
- text-align: center;
- }
- }
- }
- }
- .pinyin_hidden {
- visibility: hidden;
- }
- }
- .micro-box {
- display: flex;
- justify-content: flex-end;
- }
- .bottom {
- margin-top: 10px;
- img {
- margin-left: 10px;
- width:84px;
- }
- .switch {
- display: flex;
- align-items: center;
- padding-bottom: 16px;
- padding-left: 52px;
- }
- ul {
- display: inline-block;
- width: 900px;
- li {
- display: inline-block;
- min-width: 48px;
- padding: 4px 8px;
- font-size: 18px;
- line-height: 1.5;
- background: #ffedbf;
- border-radius: 8px;
- margin: 0 4px;
- text-align: center;
- cursor: pointer;
- // font-family: sourceR;
- }
- .active {
- background: #7663ec;
- color: #ffffff;
- font-weight: 700;
- }
- }
- .switchBtn {
- width: 40px;
- margin-left: 24px;
- margin-right: 8px;
- cursor: pointer;
- }
- .bottom_top {
- border-bottom: 1px solid #e5e5e5;
- }
- .bottom_main {
- height: 156px;
- display: flex;
- align-items: top;
- justify-content: flex-end;
- // font-family: Source Han Sans SC;
- font-style: normal;
- font-weight: normal;
- font-size: 24px;
- padding-right: 60px;
- .bottom-right {
- margin-top: 24px;
- display: flex;
- cursor: pointer;
- align-items: center;
- > div {
- width: 176px;
- margin-right: 12px;
- border: 2px solid #fb5b5b;
- border-radius: 14px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 24px;
- line-height: 35px;
- color: #e24747;
- height: 72px;
- img {
- width:22px;
- height: 22px;
- margin-right: 10px;
- }
- }
- .bottom-right_record:active {
- background: #ffe3e3;
- border-color: #ffe3e3;
- }
- }
- }
- }
- .questionMiddle {
- .SelectCorrect {
- width: 800px;
- height: 472px;
- margin: 44px auto 0 auto;
- background: #fff;
- border-radius: 16px;
- box-shadow: 0px 4px 0px rgba(239, 167, 28, 0.4);
- .SelectCorrect-top {
- width: 100%;
- height: 40px;
- background: rgba(255, 214, 107, 0.3);
- border-top-left-radius: 16px;
- border-top-right-radius: 16px;
- > img {
- margin-left: 13px;
- width: 16px;
- }
- }
- .SelectCorrect-main {
- background: #fff;
- padding: 32px 0px 0px 0;
- border-bottom-left-radius: 16px;
- border-bottom-right-radius: 16px;
- }
- .left {
- margin-left: 40px;
- > img {
- width: 56px;
- }
- .wx-arrow {
- width: 8px;
- margin-top: 22px;
- margin-left: 16px;
- }
- .dialogue_content_box {
- padding-top: 6px;
- }
- .translate_box {
- border-radius: 10px;
- padding: 6px 13px;
- max-width: 400px;
- &.novoice {
- min-height: 46px;
- }
- }
- .translate {
- > div {
- margin-left: 2px;
- }
- .spell {
- font-size: 12px;
- height: 16px;
- }
- .chinese {
- font-size: 24px;
- }
- }
- .english {
- font-size: 12px;
- line-height: 20px;
- margin-left: 4px;
- }
- }
- .wx-arrow {
- margin-bottom: 6px;
- }
- .right {
- margin-top: 30px;
- margin-right: 40px;
- > img {
- width: 56px;
- }
- .wx-arrow {
- width: 8px;
- margin-top: 22px;
- margin-right: 16px;
- }
- .dialogue_content_box {
- padding-top: 6px;
- }
- .translate_box {
- background: #f6f6f6;
- &.novoice {
- background: #f6f6f6;
- }
- }
- .bubble {
- justify-content: flex-end;
- .bubble_dv {
- background: #f6f6f6;
- }
- }
- }
- .bubble {
- .bubble_dv {
- width: 133px;
- height: 48px;
- border-radius: 10px;
- font-size: 16px;
- margin-bottom: 6px;
- > img {
- margin-left: 13px;
- }
- > span {
- margin-left: 6px;
- }
- }
- .r_bubble_dv {
- min-height: 48px;
- border-radius: 10px;
- font-size: 16px;
- max-width: 400px;
- margin-top: 6px;
- > img {
- margin-left: 13px;
- }
- > span {
- margin-left: 6px;
- }
- .translate {
- padding: 0px 13px;
- > div {
- margin-left: 4px;
- }
- }
- }
- }
- .pinyin_hidden {
- visibility: hidden;
- }
- }
- .bottom {
- margin-top: 6px;
- img {
- margin-left: 6px;
- width:56px;
- }
- .switch {
- padding-bottom: 10px;
- padding-left: 34px;
- }
- ul {
- display: inline-block;
- width: 600px;
- li {
- display: inline-block;
- min-width: 32px;
- padding: 3px 6px;
- font-size: 12px;
- border-radius: 6px;
- margin: 0 3px;
- }
- .active {
- background: #7663ec;
- color: #ffffff;
- font-weight: 700;
- }
- }
- .switchBtn {
- width: 26px;
- margin-left: 16px;
- margin-right: 6px;
- }
- .bottom_main {
- height: 104px;
- font-size: 16px;
- padding-right: 40px;
- .bottom-right {
- margin-top: 16px;
- > div {
- width: 117px;
- margin-right: 8px;
- border: 2px solid #fb5b5b;
- border-radius: 10px;
- font-size: 16px;
- line-height: 24px;
- height: 48px;
- img {
- width:14px;
- height: 14px;
- margin-right: 6px;
- }
- }
- .bottom-right_record:active {
- background: #ffe3e3;
- border-color: #ffe3e3;
- }
- }
- }
- }
- }
- .questionSmall {
- .SelectCorrect {
- width: 600px;
- height: 354px;
- margin: 28px auto 0 auto;
- border-radius: 12px;
- box-shadow: 0px 3px 0px rgba(239, 167, 28, 0.4);
- .SelectCorrect-top {
- height: 30px;
- border-top-left-radius: 12px;
- border-top-right-radius: 12px;
- > img {
- margin-left: 10px;
- width: 12px;
- }
- }
- .SelectCorrect-main {
- padding: 24px 0px 0px 0;
- border-bottom-left-radius: 12px;
- border-bottom-right-radius: 12px;
- }
- .left {
- margin-left: 30px;
- > img {
- width: 42px;
- }
- .wx-arrow {
- width: 6px;
- margin-top: 17px;
- margin-left: 12px;
- }
- .dialogue_content_box {
- padding-top: 5px;
- }
- .translate_box {
- border-radius: 7px;
- padding: 5px 10px;
- max-width: 300px;
- &.novoice {
- background: #e1f2fa;
- min-height: 34px;
- }
- }
- .translate {
- > div {
- margin-left: 2px;
- }
- .spell {
- font-size: 12px;
- height: 18px;
- }
- .chinese {
- font-size: 18px;
- }
- }
- .english {
- font-size: 12px;
- line-height: 18px;
- margin-left: 2px;
- }
- }
- .wx-arrow {
- margin-bottom: 4px;
- }
- .right {
- margin-top: 22px;
- margin-right: 30px;
- > img {
- width: 42px;
- }
- .wx-arrow {
- width: 6px;
- margin-top: 17px;
- margin-right: 12px;
- }
- .dialogue_content_box {
- padding-top: 5px;
- }
- .translate_box {
- background: #f6f6f6;
- &.novoice {
- background: #f6f6f6;
- }
- }
- .bubble {
- justify-content: flex-end;
- .bubble_dv {
- background: #f6f6f6;
- }
- }
- }
- .bubble {
- .bubble_dv {
- width: 100px;
- height: 36px;
- border-radius: 7px;
- font-size: 12px;
- margin-bottom: 4px;
- > img {
- margin-left: 10px;
- }
- > span {
- margin-left: 5px;
- }
- }
- .r_bubble_dv {
- min-height: 36px;
- border-radius: 7px;
- font-size: 12px;
- max-width: 300px;
- margin-top: 4px;
- > img {
- margin-left: 10px;
- }
- > span {
- margin-left: 5px;
- }
- .translate {
- padding: 0px 10px;
- > div {
- margin-left: 2px;
- }
- }
- }
- }
- .pinyin_hidden {
- visibility: hidden;
- height:12px;
- }
- }
- .bottom {
- margin-top: 5px;
- img {
- margin-left: 5px;
- width:42px;
- }
- .switch {
- padding-bottom: 8px;
- padding-left: 26px;
- }
- ul {
- width: 450px;
- li {
- min-width: 24px;
- padding: 2px 4px;
- font-size: 12px;
- border-radius: 4px;
- margin: 0 2px;
- }
- .active {
- background: #7663ec;
- color: #ffffff;
- font-weight: 700;
- }
- }
- .switchBtn {
- width: 20px;
- margin-left: 12px;
- margin-right: 4px;
- }
- .bottom_main {
- height: 78px;
- font-size: 12px;
- padding-right: 30px;
- .bottom-right {
- margin-top: 12px;
- > div {
- width: 88px;
- margin-right: 6px;
- border: 1px solid #fb5b5b;
- border-radius: 7px;
- font-size: 12px;
- line-height: 18px;
- height: 36px;
- img {
- width:11px;
- height: 11px;
- margin-right: 5px;
- }
- }
- .bottom-right_record:active {
- background: #ffe3e3;
- border-color: #ffe3e3;
- }
- }
- }
- }
- }
- </style>
|