From cf1fcff430fa1331c1d9b2b844fa9ad710fb7a26 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 16 四月 2024 11:30:34 +0800
Subject: [PATCH] 详情页,答题器bug修改

---
 packageBookService/pages/bookServices/examination/examination.js |  402 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 233 insertions(+), 169 deletions(-)

diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index 108f1e6..ceac28b 100644
--- a/packageBookService/pages/bookServices/examination/examination.js
+++ b/packageBookService/pages/bookServices/examination/examination.js
@@ -1,4 +1,6 @@
-import { getPublicImage } from "../../../../assets/js/middleGround/tool";
+import {
+  getPublicImage
+} from "../../../../assets/js/middleGround/tool";
 const app = getApp();
 Page({
   /**
@@ -28,6 +30,7 @@
     total: 0, // 棰樼洰鎬绘暟
     cardList: [], // 鎻愪氦椤�,
     questionDataList: [], // 鏄剧ず棰樼洰鍒楄〃
+    noData: false,
     mockid: 0,
     uuid: 0,
     mockData: {
@@ -44,6 +47,7 @@
     sliderValue: 0, // 瀛椾綋婊戝潡
     startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿
     pauseTime: 0, //鏆傚仠鏃堕棿
+    showDialog: false // 鏈彁浜ら��鍑烘嫤鎴脊绐�
   },
 
   /**
@@ -64,6 +68,9 @@
       idPathList: options.idPathList ? JSON.parse(options.idPathList) : [],
       answerType: options.answerType,
     });
+    // wx.setNavigationBarTitle({
+    //   title: options.answerTitle,
+    // })
     if (this.data.answerType == "mock") {
       this.setData({
         uuid: options.uuid,
@@ -71,7 +78,6 @@
       });
     }
     this.init();
-    console.log("浼犲弬", options);
   },
 
   /**
@@ -178,7 +184,6 @@
   // 鐩戝惉watch
   watch(context, variableName, callback) {
     let value = context.data[variableName]; // 鑾峰彇琚洃鍚睘鎬х殑褰撳墠鍊�
-
     // 浣跨敤 Object.defineProperty 鏂规硶鍦ㄦ暟鎹璞′笂瀹氫箟灞炴�х殑 getter 鍜� setter
     Object.defineProperty(context.data, variableName, {
       configurable: true, // 鍙厤缃�
@@ -193,6 +198,41 @@
       },
     });
   },
+
+  // 姝e垯鎵惧嚭鍚姏src
+  extractSourceSrc(htmlString) {
+    // 姝e垯琛ㄨ揪寮忓尮閰�<source>鏍囩涓殑src灞炴�у��  
+    var srcRegex = /<source\s+src="([^"]+)"/i;
+    var srcTwo = /<audio\s+src="([^"]+)"/i;
+
+    // 鎵ц姝e垯鍖归厤  
+    var match = srcRegex.exec(htmlString);
+    const local = srcTwo.exec(htmlString)
+    // 濡傛灉鍖归厤鎴愬姛锛岃繑鍥炵涓�涓崟鑾风粍鐨勫唴瀹癸紙src灞炴�х殑鍊硷級  
+    if (match && match[1]) {
+      return match[1].replace('../file', app.config.requestCtx + '/file');
+    } else if (local && local[1]) {
+      return local[1].replace('../file', app.config.requestCtx + '/file')
+    } else {
+      // 濡傛灉娌℃湁鍖归厤鍒帮紝杩斿洖null  
+      return null;
+    }
+  },
+
+  // 鎷垮埌鍚姏棰橀櫎audio鏍囩澶栧叾浠栧唴瀹�
+  removeVideoAndAudioTags(htmlString) {
+    // 浣跨敤姝e垯琛ㄨ揪寮忓尮閰嶅苟绉婚櫎鎵�鏈夌殑 <video> 鍜� <audio> 鏍囩
+    var cleanedHtml = htmlString.replace(/<video[^>]*>[\s\S]*?<\/video>|<audio[^>]*>[\s\S]*?<\/audio>/gi, '');
+
+    return cleanedHtml;
+  },
+
+  // 鏀瑰彉loading鐘舵��
+  changeLoadingState() {
+    this.setData({
+      loading: true
+    })
+  },
   // 杩斿洖鎷︽埅
   beforeleave() {
     wx.showModal({
@@ -202,10 +242,14 @@
       cancelColor: "#949494",
       complete: (res) => {
         if (res.cancel) {
+          this.setData({
+            showDialog: true
+          })
         }
         if (res.confirm) {
           this.setData({
             submitStatus: true,
+            showDialog: false
           });
           wx.navigateBack();
         }
@@ -452,6 +496,7 @@
   // 鎻愪氦閫昏緫
   submitPaper() {
     this.setData({
+      showDialog: false,
       submitStatus: true,
       loading: true,
     });
@@ -505,16 +550,14 @@
         });
       }
       app.MG.identity.setUserKey({
-        setKeyRequests: [
-          {
-            domain: "mockAnswerData",
-            key: this.data.uuid,
-            value: JSON.stringify({
-              time: this.data.countdownTime,
-              answerData: saveData,
-            }),
-          },
-        ],
+        setKeyRequests: [{
+          domain: "mockAnswerData",
+          key: this.data.uuid,
+          value: JSON.stringify({
+            time: this.data.countdownTime,
+            answerData: saveData,
+          }),
+        }, ],
       });
       child.openTestReportDialog();
     }
@@ -532,7 +575,6 @@
     });
     if (this.data.answerType == "option") {
       if (this.data)
-        // this.startCountdown()
         this.setData({
           countdownTime: 2 * 60 * 60 * 1000,
         });
@@ -596,6 +638,9 @@
             oldMockData.state == "2"
           ) {
             this.startCountdown();
+            this.setData({
+              showDialog: true
+            })
           }
           if (oldMockData.state == "3") {
             this.setData({
@@ -633,16 +678,14 @@
       // 缁勫嵎妯″紡
       // 娓呯┖绛旈璁板綍
       await app.MG.identity.setUserKey({
-        setKeyRequests: [
-          {
-            domain: "mockAnswerData",
-            key: this.data.uuid,
-            value: JSON.stringify({
-              time: this.data.countdownTime,
-              answerData: [],
-            }),
-          },
-        ],
+        setKeyRequests: [{
+          domain: "mockAnswerData",
+          key: this.data.uuid,
+          value: JSON.stringify({
+            time: this.data.countdownTime,
+            answerData: [],
+          }),
+        }, ],
       });
       this.init();
     } else {
@@ -693,11 +736,13 @@
               this.setData({
                 currentIndex: value.currentIndex,
               });
-              console.log(this.data.submitStatus);
               // 鎼哄甫绛旈璁板綍 鑾峰彇棰樼洰
               await this.getQuestionList(value.dataList);
             } else {
               await this.getQuestionList(); // 鑾峰彇棰樺簱棰樼洰
+              this.setData({
+                showDialog: true
+              })
             }
           });
         }
@@ -722,6 +767,7 @@
   async getQuestionList(oldData) {
     // 娓呯┖姝g‘棰樻暟璁板綍
     this.setData({
+      noData: false,
       cardList: [],
       correctNum: 0,
     });
@@ -783,34 +829,26 @@
             // num: index, // 棰樺彿
             id: item.id,
             type: pathitem.name,
-            stem:
-              item.Embedded_QuestionBank_QuestionType == "completion"
-                ? JSON.parse(item.Embedded_QuestionBank_Stem)
-                    .stemTxt.replaceAll("<vacancy>", ",input,")
-                    .split(",")
-                : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
+            stem: item.Embedded_QuestionBank_QuestionType == "completion" ?
+              JSON.parse(item.Embedded_QuestionBank_Stem)
+              .stemTxt.replaceAll("<vacancy>", ",input,")
+              .split(",") : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
             answer: item.Embedded_QuestionBank_Answer, // 绛旀
-            option: item.Embedded_QuestionBank_Option
-              ? JSON.parse(item.Embedded_QuestionBank_Option)
-              : "", // 閫夋嫨棰橀�夐」
+            option: item.Embedded_QuestionBank_Option ?
+              JSON.parse(item.Embedded_QuestionBank_Option) : "", // 閫夋嫨棰橀�夐」
             analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽
             questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷
             optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷
             stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷
-            difficulty: item.Embedded_QuestionBank_Difficulty
-              ? 4 - item.Embedded_QuestionBank_Difficulty
-              : 0, // 闅惧害绛夌骇
-            userAnswer: oldObj
-              ? oldObj.userAnswer
-              : item.Embedded_QuestionBank_QuestionType == "completion" ||
-                item.Embedded_QuestionBank_QuestionType == "multipleChoice"
-              ? []
-              : "",
+            difficulty: item.Embedded_QuestionBank_Difficulty ?
+              4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇
+            userAnswer: oldObj ?
+              oldObj.userAnswer : item.Embedded_QuestionBank_QuestionType == "completion" ||
+              item.Embedded_QuestionBank_QuestionType == "multipleChoice" ? [] : "",
             isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false,
             isRight: oldObj ? oldObj.isRight : null,
             isComplete: oldObj ? oldObj.isComplete : false,
-            isCollect:
-              this.data.collectList.indexOf(item.id) > -1 ? true : false,
+            isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false,
             isUnfold: "", // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮�
           };
           // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡
@@ -847,7 +885,7 @@
                 /\<img/gi,
                 '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
               )
-              .replace(/\<p/gi, '<p class="stem-rich-p"');
+              .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
           }
           // 閫夐」瀵屾枃鏈鐞�
           if (
@@ -859,8 +897,8 @@
             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"');
+                .replace(/\<img/gi, '<img class="option-rich-img"')
+                .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
             });
           }
           // 瑙f瀽瀵屾枃鏈鐞�
@@ -872,6 +910,14 @@
               /\<img/gi,
               '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
             );
+          }
+          // 鍚姏棰樹慨鏀�
+          if (questionObj.questionType == 'singleChoice') {
+            const src = this.extractSourceSrc(questionObj.stem.stemTxt)
+            if (src) {
+              questionObj.src = src
+              questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
+            }
           }
           // 鑾峰彇鍥剧墖
           if (
@@ -951,7 +997,14 @@
       });
     }
     // 鏈夐鐩啀寮�濮嬪�掕鏃�
-    if (this.data.questionDataList.length) this.startCountdown();
+    if (this.data.questionDataList.length) {
+      console.log(this.data.questionDataList);
+      this.startCountdown();
+    } else {
+      this.setData({
+        noData: true
+      })
+    }
     this.setData({
       loading: false,
     });
@@ -1047,13 +1100,11 @@
       // 璁板綍閿欓
       app.MG.identity
         .setUserKey({
-          setKeyRequests: [
-            {
-              domain: "errorData",
-              key: this.data.rootCmsItemId,
-              value: JSON.stringify(this.data.errorList),
-            },
-          ],
+          setKeyRequests: [{
+            domain: "errorData",
+            key: this.data.rootCmsItemId,
+            value: JSON.stringify(this.data.errorList),
+          }, ],
         })
         .then((res) => {
           console.log(res);
@@ -1111,13 +1162,11 @@
     }
     app.MG.identity
       .setUserKey({
-        setKeyRequests: [
-          {
-            domain: "collectData",
-            key: this.data.rootCmsItemId,
-            value: JSON.stringify(this.data.collectList),
-          },
-        ],
+        setKeyRequests: [{
+          domain: "collectData",
+          key: this.data.rootCmsItemId,
+          value: JSON.stringify(this.data.collectList),
+        }, ],
       })
       .then((res) => {});
   },
@@ -1156,17 +1205,15 @@
   setAnswerInfo(data) {
     app.MG.identity
       .setUserKey({
-        setKeyRequests: [
-          {
-            domain: "answerData",
-            key: this.data.productLinkPath,
-            value: JSON.stringify(data),
-          },
-        ],
+        setKeyRequests: [{
+          domain: "answerData",
+          key: this.data.productLinkPath,
+          value: JSON.stringify(data),
+        }, ],
       })
       .then((res) => {});
   },
-  // 鑾峰彇绛旈鏁版嵁
+  // 鑾峰彇鏃х瓟棰樻暟鎹�
   getAnswerInfo(callback) {
     app.MG.identity
       .getUserKey({
@@ -1177,7 +1224,7 @@
         if (callback) callback(res);
       });
   },
-  // 鍒犻櫎绛旈鏁版嵁
+  // 鍒犻櫎鏃х瓟棰樻暟鎹�
   delAnswerInfo(callback) {
     app.MG.identity
       .delUserKey({
@@ -1206,6 +1253,7 @@
         } else {
           this.setData({
             loading: false,
+            noData: true
           });
           wx.showModal({
             title: "鎻愮ず",
@@ -1230,8 +1278,7 @@
   async getCollectDataList() {
     let questionArr = [];
     this.setData({
-      cardList: [
-        {
+      cardList: [{
           catalogName: "鍗曢�夐",
           infoList: [],
         },
@@ -1285,28 +1332,21 @@
           const questionObj = {
             number: index + 1, // 棰樺彿
             id: item.id,
-            stem:
-              item.Embedded_QuestionBank_QuestionType == "completion"
-                ? JSON.parse(item.Embedded_QuestionBank_Stem)
-                    .stemTxt.replaceAll("<vacancy>", ",input,")
-                    .split(",")
-                : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
+            stem: item.Embedded_QuestionBank_QuestionType == "completion" ?
+              JSON.parse(item.Embedded_QuestionBank_Stem)
+              .stemTxt.replaceAll("<vacancy>", ",input,")
+              .split(",") : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
             answer: item.Embedded_QuestionBank_Answer, // 绛旀
-            option: item.Embedded_QuestionBank_Option
-              ? JSON.parse(item.Embedded_QuestionBank_Option)
-              : "", // 閫夋嫨棰橀�夐」
+            option: item.Embedded_QuestionBank_Option ?
+              JSON.parse(item.Embedded_QuestionBank_Option) : "", // 閫夋嫨棰橀�夐」
             analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽
             questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷
             optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷
             stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷
-            difficulty: item.Embedded_QuestionBank_Difficulty
-              ? 4 - item.Embedded_QuestionBank_Difficulty
-              : 0, // 闅惧害绛夌骇
-            userAnswer:
-              item.Embedded_QuestionBank_QuestionType == "completion" ||
-              item.Embedded_QuestionBank_QuestionType == "multipleChoice"
-                ? []
-                : "",
+            difficulty: item.Embedded_QuestionBank_Difficulty ?
+              4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇
+            userAnswer: item.Embedded_QuestionBank_QuestionType == "completion" ||
+              item.Embedded_QuestionBank_QuestionType == "multipleChoice" ? [] : "",
             isSubmit: false, // 鏌ョ湅瑙f瀽
             isRight: null, // 鏄惁姝g‘
             isComplete: false,
@@ -1365,7 +1405,7 @@
                 /\<img/gi,
                 '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
               )
-              .replace(/\<p/gi, '<p class="stem-rich-p"');
+              .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
           }
           // 閫夐」瀵屾枃鏈鐞�
           if (
@@ -1377,9 +1417,27 @@
             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"');
+                .replace(/\<img/gi, '<img class="option-rich-img"')
+                .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
             });
+          }
+          // 瑙f瀽瀵屾枃鏈鐞�
+          if (
+            questionObj.analysisCon &&
+            typeof questionObj.analysisCon == "string"
+          ) {
+            questionObj.analysisCon = questionObj.analysisCon.replace(
+              /\<img/gi,
+              '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
+            );
+          }
+          // 鍚姏棰樹慨鏀�
+          if (questionObj.questionType == 'singleChoice') {
+            const src = this.extractSourceSrc(questionObj.stem.stemTxt)
+            if (src) {
+              questionObj.src = src
+              questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
+            }
           }
           if (item.Embedded_QuestionBank_QuestionType == "judge") {
             questionObj.type = "鍒ゆ柇棰�";
@@ -1443,7 +1501,8 @@
           this.getErrorDataList();
         } else {
           this.setData({
-            loading: true,
+            loading: false,
+            noData: true
           });
           wx.showModal({
             title: "鎻愮ず",
@@ -1467,8 +1526,7 @@
   // 鑾峰彇閿欓闆�
   async getErrorDataList() {
     this.setData({
-      cardList: [
-        {
+      cardList: [{
           catalogName: "鍗曢�夐",
           infoList: [],
         },
@@ -1520,28 +1578,21 @@
         const questionObj = {
           number: index + 1, // 棰樺彿
           id: item.id,
-          stem:
-            item.Embedded_QuestionBank_QuestionType == "completion"
-              ? JSON.parse(item.Embedded_QuestionBank_Stem)
-                  .stemTxt.replaceAll("<vacancy>", ",input,")
-                  .split(",")
-              : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
+          stem: item.Embedded_QuestionBank_QuestionType == "completion" ?
+            JSON.parse(item.Embedded_QuestionBank_Stem)
+            .stemTxt.replaceAll("<vacancy>", ",input,")
+            .split(",") : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
           answer: item.Embedded_QuestionBank_Answer, // 绛旀
-          option: item.Embedded_QuestionBank_Option
-            ? JSON.parse(item.Embedded_QuestionBank_Option)
-            : "", // 閫夋嫨棰橀�夐」
+          option: item.Embedded_QuestionBank_Option ?
+            JSON.parse(item.Embedded_QuestionBank_Option) : "", // 閫夋嫨棰橀�夐」
           analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽
           questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷
           optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷
           stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷
-          difficulty: item.Embedded_QuestionBank_Difficulty
-            ? 4 - item.Embedded_QuestionBank_Difficulty
-            : 0, // 闅惧害绛夌骇
-          userAnswer:
-            item.Embedded_QuestionBank_QuestionType == "completion" ||
-            item.Embedded_QuestionBank_QuestionType == "multipleChoice"
-              ? []
-              : "",
+          difficulty: item.Embedded_QuestionBank_Difficulty ?
+            4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇
+          userAnswer: item.Embedded_QuestionBank_QuestionType == "completion" ||
+            item.Embedded_QuestionBank_QuestionType == "multipleChoice" ? [] : "",
           isSubmit: false, // 鏌ョ湅瑙f瀽
           isRight: null, // 鏄惁姝g‘
           isComplete: false,
@@ -1602,7 +1653,7 @@
               /\<img/gi,
               '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
             )
-            .replace(/\<p/gi, '<p class="stem-rich-p"');
+            .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
         }
         // 閫夐」瀵屾枃鏈鐞�
         if (
@@ -1614,9 +1665,28 @@
           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"');
+              .replace(/\<img/gi, '<img class="option-rich-img"')
+              .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
           });
+        }
+        // 瑙f瀽瀵屾枃鏈鐞�
+        if (
+          questionObj.analysisCon &&
+          typeof questionObj.analysisCon == "string"
+        ) {
+          questionObj.analysisCon = questionObj.analysisCon.replace(
+            /\<img/gi,
+            '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
+          );
+        }
+        // 鍚姏棰樹慨鏀�
+        if (questionObj.questionType == 'singleChoice') {
+          const src = this.extractSourceSrc(questionObj.stem.stemTxt)
+          if (src) {
+            questionObj.src = src
+            questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
+            console.log('棰樺共', questionObj.stem.stemTxt);
+          }
         }
         if (item.Embedded_QuestionBank_QuestionType == "judge") {
           questionObj.type = "鍒ゆ柇棰�";
@@ -1798,35 +1868,27 @@
             id: item.id,
             score: pathitem.infoList.find((infoItem) => infoItem.id == item.id)
               .score,
-            stem:
-              item.Embedded_QuestionBank_QuestionType == "completion"
-                ? JSON.parse(item.Embedded_QuestionBank_Stem)
-                    .stemTxt.replaceAll("<vacancy>", ",input,")
-                    .split(",")
-                : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
+            stem: item.Embedded_QuestionBank_QuestionType == "completion" ?
+              JSON.parse(item.Embedded_QuestionBank_Stem)
+              .stemTxt.replaceAll("<vacancy>", ",input,")
+              .split(",") : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共
             answer: item.Embedded_QuestionBank_Answer, // 绛旀
-            option: item.Embedded_QuestionBank_Option
-              ? JSON.parse(item.Embedded_QuestionBank_Option)
-              : "", // 閫夋嫨棰橀�夐」
+            option: item.Embedded_QuestionBank_Option ?
+              JSON.parse(item.Embedded_QuestionBank_Option) : "", // 閫夋嫨棰橀�夐」
             analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽
             questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷
             optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷
             stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷
-            difficulty: item.Embedded_QuestionBank_Difficulty
-              ? 4 - item.Embedded_QuestionBank_Difficulty
-              : 0, // 闅惧害绛夌骇
-            userAnswer: oldObj
-              ? oldObj.answer
-              : item.Embedded_QuestionBank_QuestionType == "completion" ||
-                item.Embedded_QuestionBank_QuestionType == "multipleChoice"
-              ? []
-              : "",
-            isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false,
+            difficulty: item.Embedded_QuestionBank_Difficulty ?
+              4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇
+            userAnswer: oldObj ?
+              oldObj.answer : item.Embedded_QuestionBank_QuestionType == "completion" ||
+              item.Embedded_QuestionBank_QuestionType == "multipleChoice" ? [] : "",
+            isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.answer) : false,
             isRight: oldObj ? oldObj.isRight : null,
             // isComplete: oldObj ? oldObj.isComplete : false,
             isComplete: this.data.mockData.state == "3" ? true : false,
-            isCollect:
-              this.data.collectList.indexOf(item.id) > -1 ? true : false,
+            isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false,
             isUnfold: "", // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮�
           };
           // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡
@@ -1861,7 +1923,7 @@
             questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(
               /\<img/gi,
               '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img"'
-            );
+            ).replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
           }
           // 閫夐」瀵屾枃鏈鐞�
           if (
@@ -1875,8 +1937,16 @@
                 item.txt = item.txt.replace(
                   /\<img/gi,
                   '<img class="option-rich-img"'
-                );
+                ).replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
             });
+          }
+          // 鍚姏棰樹慨鏀�
+          if (questionObj.questionType == 'singleChoice') {
+            const src = this.extractSourceSrc(questionObj.stem.stemTxt)
+            if (src) {
+              questionObj.src = src
+              questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
+            }
           }
           // 鑾峰彇鍥剧墖
           if (
@@ -1957,26 +2027,22 @@
   // 璁板綍璐拱缁勫嵎鏃堕棿
   setMockInfo(data) {
     app.MG.identity.setUserKey({
-      setKeyRequests: [
-        {
-          domain: "mockData",
-          key: this.data.bookId + "",
-          value: JSON.stringify(data),
-        },
-      ],
+      setKeyRequests: [{
+        domain: "mockData",
+        key: this.data.bookId + "",
+        value: JSON.stringify(data),
+      }, ],
     });
   },
   // 璁板綍缁勫嵎棰樼洰鍒楄〃
   saveMockQuestionList(data) {
     app.MG.identity
       .setUserKey({
-        setKeyRequests: [
-          {
-            domain: "mockQuestionData",
-            key: this.data.uuid,
-            value: JSON.stringify(data),
-          },
-        ],
+        setKeyRequests: [{
+          domain: "mockQuestionData",
+          key: this.data.uuid,
+          value: JSON.stringify(data),
+        }, ],
       })
       .then((res) => {
         console.log("妯¤�冮鐩垪琛ㄥ凡璁板綍");
@@ -2005,12 +2071,12 @@
       })
       .then((res) => {
         if (res[0]) {
+          // 杩欓噷鐨� countdownTime 璧嬪�硷細濡傛灉鏄椂闂村埌浜嗘彁浜わ紝璁板綍鐨勫墿浣欐椂闂村氨鏄�0锛屾墍浠ワ細濡傛灉鏄�0鐨勮瘽璧嬪��1绉掞紝闃叉鐩戝惉鍒版椂闂翠负0鍐嶆鎻愪氦
           this.setData({
             currentIndex: JSON.parse(res[0].value).currentIndex,
             "mockData.time": JSON.parse(res[0].value).time,
-            countdownTime: JSON.parse(res[0].value).time
-              ? JSON.parse(res[0].value).time
-              : this.data.mockData.sumTime,
+            countdownTime: JSON.parse(res[0].value).time > 0 ?
+              JSON.parse(res[0].value).time : 1000,
             "mockData.answer": JSON.parse(res[0].value).answerData,
           });
           console.log(JSON.parse(res[0].value));
@@ -2054,17 +2120,15 @@
     //
     app.MG.identity
       .setUserKey({
-        setKeyRequests: [
-          {
-            domain: "mockAnswerData",
-            key: this.data.uuid,
-            value: JSON.stringify({
-              currentIndex: this.data.currentIndex,
-              time: this.data.countdownTime,
-              answerData: saveData,
-            }),
-          },
-        ],
+        setKeyRequests: [{
+          domain: "mockAnswerData",
+          key: this.data.uuid,
+          value: JSON.stringify({
+            currentIndex: this.data.currentIndex,
+            time: this.data.countdownTime,
+            answerData: saveData,
+          }),
+        }, ],
       })
       .then((res) => {
         this.setData({
@@ -2110,4 +2174,4 @@
     );
     return newContent;
   },
-});
+});
\ No newline at end of file

--
Gitblit v1.9.1