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 |   60 +++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index 070b53f..ceac28b 100644
--- a/packageBookService/pages/bookServices/examination/examination.js
+++ b/packageBookService/pages/bookServices/examination/examination.js
@@ -47,7 +47,7 @@
     sliderValue: 0, // 瀛椾綋婊戝潡
     startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿
     pauseTime: 0, //鏆傚仠鏃堕棿
-
+    showDialog: false // 鏈彁浜ら��鍑烘嫤鎴脊绐�
   },
 
   /**
@@ -68,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,
@@ -75,7 +78,6 @@
       });
     }
     this.init();
-    console.log("浼犲弬", options);
   },
 
   /**
@@ -202,15 +204,15 @@
     // 姝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');
+      return match[1].replace('../file', app.config.requestCtx + '/file');
     } else if (local && local[1]) {
-      return local[1].replace( '../file', app.config.requestCtx + '/file')
+      return local[1].replace('../file', app.config.requestCtx + '/file')
     } else {
       // 濡傛灉娌℃湁鍖归厤鍒帮紝杩斿洖null  
       return null;
@@ -239,10 +241,15 @@
       confirmColor: "#ff6c00",
       cancelColor: "#949494",
       complete: (res) => {
-        if (res.cancel) {}
+        if (res.cancel) {
+          this.setData({
+            showDialog: true
+          })
+        }
         if (res.confirm) {
           this.setData({
             submitStatus: true,
+            showDialog: false
           });
           wx.navigateBack();
         }
@@ -489,6 +496,7 @@
   // 鎻愪氦閫昏緫
   submitPaper() {
     this.setData({
+      showDialog: false,
       submitStatus: true,
       loading: true,
     });
@@ -567,7 +575,6 @@
     });
     if (this.data.answerType == "option") {
       if (this.data)
-        // this.startCountdown()
         this.setData({
           countdownTime: 2 * 60 * 60 * 1000,
         });
@@ -631,6 +638,9 @@
             oldMockData.state == "2"
           ) {
             this.startCountdown();
+            this.setData({
+              showDialog: true
+            })
           }
           if (oldMockData.state == "3") {
             this.setData({
@@ -730,6 +740,9 @@
               await this.getQuestionList(value.dataList);
             } else {
               await this.getQuestionList(); // 鑾峰彇棰樺簱棰樼洰
+              this.setData({
+                showDialog: true
+              })
             }
           });
         }
@@ -794,9 +807,6 @@
         },
       };
       await app.MG.store.getProductDetail(query).then((res) => {
-        if (!res.datas.cmsDatas[0].datas.length) return this.setData({
-          noData: true
-        })
         this.setData({
           total: res.datas.cmsDatas[0].datas.length,
         });
@@ -875,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 (
@@ -888,7 +898,7 @@
               if (item.txt)
                 item.txt = item.txt
                 .replace(/\<img/gi, '<img class="option-rich-img"')
-                .replace(/\<p/gi, '<p class="stem-rich-p"');
+                .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
             });
           }
           // 瑙f瀽瀵屾枃鏈鐞�
@@ -987,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,
     });
@@ -1388,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 (
@@ -1401,7 +1418,7 @@
               if (item.txt)
                 item.txt = item.txt
                 .replace(/\<img/gi, '<img class="option-rich-img"')
-                .replace(/\<p/gi, '<p class="stem-rich-p"');
+                .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
             });
           }
           // 瑙f瀽瀵屾枃鏈鐞�
@@ -1636,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 (
@@ -1649,7 +1666,7 @@
             if (item.txt)
               item.txt = item.txt
               .replace(/\<img/gi, '<img class="option-rich-img"')
-              .replace(/\<p/gi, '<p class="stem-rich-p"');
+              .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
           });
         }
         // 瑙f瀽瀵屾枃鏈鐞�
@@ -1906,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 (
@@ -1920,7 +1937,7 @@
                 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');
             });
           }
           // 鍚姏棰樹慨鏀�
@@ -2054,11 +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));

--
Gitblit v1.9.1