From c4e651ac030ef5fe8870f6974fcc4658d42986c6 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期四, 21 三月 2024 14:35:01 +0800
Subject: [PATCH] 图书列表,详情页、答题器样式修改,代码合并上传测试服

---
 packageBookService/pages/bookServices/examination/examination.js |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index 6b82781..3bec06c 100644
--- a/packageBookService/pages/bookServices/examination/examination.js
+++ b/packageBookService/pages/bookServices/examination/examination.js
@@ -48,6 +48,15 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+    // wx.enableAlertBeforeUnload({
+    //   message: "鏈彁浜わ紝鏄惁閫�鍑虹瓟棰橈紵",
+    //   success: function (res) {
+    //     console.log('纭畾', res);
+    //   },
+    //   fail: function (err) {
+    //     console.log("澶辫触锛�", err);
+    //   },
+    // });
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
@@ -75,7 +84,6 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
   onReady() {
-
   },
 
   /**
@@ -101,13 +109,12 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
   onHide() {
-
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
    */
-  onUnload() {
+  onUnload(e) {
     if (this.data.countdownInterval !== null) {
       clearInterval(this.data.countdownInterval)
     }
@@ -132,8 +139,29 @@
    */
   onShareAppMessage() {
   },
+
+  // 鐩戝惉watch
+  watch(context, variableName, callback) {
+    let value = context.data[variableName]; // 鑾峰彇琚洃鍚睘鎬х殑褰撳墠鍊�
+
+    // 浣跨敤 Object.defineProperty 鏂规硶鍦ㄦ暟鎹璞′笂瀹氫箟灞炴�х殑 getter 鍜� setter
+    Object.defineProperty(context.data, variableName, {
+      configurable: true, // 鍙厤缃�
+      enumerable: true, // 鍙灇涓�
+      get: function () {
+        return value; // 杩斿洖灞炴�х殑褰撳墠鍊�
+      },
+      set: function (newVal) {
+        const oldVal = value; // 璁板綍灞炴�х殑鏃у��
+        value = newVal; // 鏇存柊灞炴�х殑鍊�
+        callback.call(context, newVal, oldVal); // 璋冪敤鍥炶皟鍑芥暟锛屼紶閫掓柊鍊煎拰鏃у��
+      }
+    });
+  },
+
   // 杩斿洖
   goBack() {
+    console.log(this.data.submitStatus);
     wx.navigateBack();
   },
   //璁剧疆鑳屾櫙鑹�
@@ -201,10 +229,11 @@
     this.setData({
       currentIndex: e.detail.index
     })
-    let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
-    let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer)
-    if (flag) this.handleQuestion(e.detail.index)
-
+    if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') {
+      let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
+      let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer)
+      if (flag) this.handleQuestion(e.detail.index)
+    }
   },
   // 鐐瑰嚮绛旈鍗¤烦杞鐩�
   goQuestion(e) {
@@ -295,6 +324,8 @@
   },
   // 鎻愪氦閫昏緫
   submitPaper() {
+    // 鍏抽棴閫�鍑洪〉闈㈢洃鍚�
+    wx.disableAlertBeforeUnload()
     this.setData({
       submitStatus: true
     })
@@ -495,6 +526,7 @@
               let value = JSON.parse(res[0].value)
               // 鏈夌瓟棰樿褰曪紝寰楀垎璧嬪��
               if (value) {
+                wx.disableAlertBeforeUnload()
                 this.setData({
                   submitStatus: true
                 })
@@ -508,6 +540,7 @@
               this.setData({
                 currentIndex: value.currentIndex
               })
+              console.log(this.data.submitStatus);
               // 鎼哄甫绛旈璁板綍 鑾峰彇棰樼洰
               await this.getQuestionList(value.dataList)
             } else {

--
Gitblit v1.9.1