From 8f1835f66ef83bbd752e080178afb98632a6970d Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期四, 28 三月 2024 14:09:44 +0800 Subject: [PATCH] 云学习购买 --- packageBookService/pages/bookServices/examination/examination.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 9d544ed..0762452 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -277,7 +277,6 @@ item.userAnswer = radioChecked item.isUserAnswer = this.isHaveAnswer(radioChecked) if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { - debugger let index = this.data.currentIndex - 1 >= 0 ? this.data.currentIndex - 1 : 0 this.handleQuestion(index) } @@ -760,6 +759,18 @@ index++ } } + } + // 棰樺共瀵屾枃鏈鐞� + if (questionObj.stemStyle == 'RichText') { + // questionObj.option.txt = '' + questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img class="stem-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"') + + } + // 閫夐」瀵屾枃鏈鐞� + if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { + questionObj.option.forEach(item => { + if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"') + }) } // 鑾峰彇鍥剧墖 if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { @@ -1536,6 +1547,17 @@ } } } + // 棰樺共瀵屾枃鏈鐞� + if (questionObj.stemStyle == 'RichText') { + // questionObj.option.txt = '' + questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img class="stem-rich-img"') + } + // 閫夐」瀵屾枃鏈鐞� + if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { + questionObj.option.forEach(item => { + if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"') + }) + } // 鑾峰彇鍥剧墖 if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) @@ -1706,5 +1728,30 @@ }) console.log('妯¤�冪瓟棰樻暟鎹凡璁板綍') }) + }, + + // 瀵屾枃鏈鐞� + formatRichText(html) { + console.log(html); + let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) { + match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, ''); + match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, ''); + match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, ''); + return match; + }); + newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) { + match = match + .replace(/<p>/gi, '<p class="p_class">') + .replace(/width:[^;]+;/gi, 'max-width:100%;') + .replace(/width:[^;]+;/gi, 'max-width:100%;'); + return match; + }); + newContent = newContent.replace(/<br[^>]*\/>/gi, ""); + newContent = newContent.replace(/<a>/gi, '<a class="p_class "'); + newContent = newContent.replace(/<li>/gi, '<li class="p_class "'); + newContent = newContent.replace(/\<p/gi, '<p class="p_class "'); + newContent = newContent.replace(/\<span/gi, '<span class="p_class "'); + newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"'); + return newContent; } }) \ No newline at end of file -- Gitblit v1.9.1