From 3d73fb33c46aada16a6060adcd4ea14bb33b6b2a Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 09 四月 2024 10:39:11 +0800
Subject: [PATCH] 详情页tabs样式优化,答题添加页面退出拦截,合并代码

---
 packageBookService/pages/bookServices/examination/examination.js |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index d864f29..108f1e6 100644
--- a/packageBookService/pages/bookServices/examination/examination.js
+++ b/packageBookService/pages/bookServices/examination/examination.js
@@ -50,15 +50,6 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   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 =
@@ -199,6 +190,25 @@
         const oldVal = value; // 璁板綍灞炴�х殑鏃у��
         value = newVal; // 鏇存柊灞炴�х殑鍊�
         callback.call(context, newVal, oldVal); // 璋冪敤鍥炶皟鍑芥暟锛屼紶閫掓柊鍊煎拰鏃у��
+      },
+    });
+  },
+  // 杩斿洖鎷︽埅
+  beforeleave() {
+    wx.showModal({
+      title: "鎻愮ず",
+      content: "鏈彁浜わ紝鏄惁閫�鍑虹瓟棰�",
+      confirmColor: "#ff6c00",
+      cancelColor: "#949494",
+      complete: (res) => {
+        if (res.cancel) {
+        }
+        if (res.confirm) {
+          this.setData({
+            submitStatus: true,
+          });
+          wx.navigateBack();
+        }
       },
     });
   },
@@ -441,8 +451,6 @@
   },
   // 鎻愪氦閫昏緫
   submitPaper() {
-    // 鍏抽棴閫�鍑洪〉闈㈢洃鍚�
-    wx.disableAlertBeforeUnload();
     this.setData({
       submitStatus: true,
       loading: true,
@@ -669,7 +677,6 @@
               let value = JSON.parse(res[0].value);
               // 鏈夌瓟棰樿褰曪紝寰楀垎璧嬪��
               if (value) {
-                wx.disableAlertBeforeUnload();
                 this.setData({
                   submitStatus: true,
                 });
@@ -1203,6 +1210,8 @@
           wx.showModal({
             title: "鎻愮ず",
             content: "鏀惰棌澶规殏鏃犳暟鎹�", //editable濡傛灉涓簍rue锛岃繖灏辨槸杈撳叆妗嗙殑鍐呭
+            confirmColor: "#ff6c00",
+            cancelColor: "#949494",
             editable: false, //鏄惁鏄剧ず杈撳叆妗�
             showCancel: false,
             success: (res) => {
@@ -1439,6 +1448,8 @@
           wx.showModal({
             title: "鎻愮ず",
             content: "閿欓闆嗘殏鏃犳暟鎹�", //editable濡傛灉涓簍rue锛岃繖灏辨槸杈撳叆妗嗙殑鍐呭
+            confirmColor: "#ff6c00",
+            cancelColor: "#949494",
             editable: false, //鏄惁鏄剧ず杈撳叆妗�
             showCancel: false,
             success: (res) => {

--
Gitblit v1.9.1