From c0ff00c32bca4077b140d0d69b2863851ae31273 Mon Sep 17 00:00:00 2001
From: zhongshujie <2862698242@qq.com>
Date: 星期二, 08 七月 2025 16:29:17 +0800
Subject: [PATCH] 优化

---
 packageBookService/pages/psychologyAnswer/psychologyAnswer.js |   77 ++++++++++++++++++++++++++++++--------
 1 files changed, 61 insertions(+), 16 deletions(-)

diff --git a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
index 02f47f5..f4bbd95 100644
--- a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
+++ b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
@@ -9,6 +9,7 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    isBuy: false, // 鏄惁闇�瑕佽喘涔�
     questuionName: "", //璇曞嵎鍚嶇О
     dataList: "",
     barHeight: "",
@@ -37,28 +38,72 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
-    const questuionName = options.listName
-    this.setData({
-      questuionName: questuionName
-    })
-    const systInfo = wx.getSystemInfoSync();
-    const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
-    const navBarHeight =
-      (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
-    const token = wx.getStorageSync(app.config.tokenKey)
-    if (!token) {
-      loginInfo(app, (data) => {
-        if (data) {
-          this.init();
+    // 鍦ㄦ杩涜鏄惁璐拱鐨勬煡璇�
+    const questionId = options.listId;
+    const bookId = options.bookId
+    const bookName = options.bookName
+    const formPath = options.formPath
+    const query = {
+      "cmsItemId": Number(questionId)
+    };
+    app.MG.file.checkCmsItem(query)
+      .then((res) => {
+        const isBuys = res;
+        this.setData({
+          isBuy: isBuys
+        });
+        if (!isBuys) {
+          wx.showModal({
+            icon: 'error',
+            title: '娓╅Θ鎻愮ず',
+            content: '璇疯喘涔伴搴擄紝鍗冲皢杩斿洖璐拱椤�',
+            confirmText: '纭畾',
+            showCancel: false, // 鍏抽棴鍙栨秷鎸夐挳
+            success: function (res) {
+              if (res.confirm) {
+                wx.navigateTo({
+                  url: '/packageBookService/pages/bookServices/detail/index?id=' + bookId + '&name=' + bookName + '&tabValue=' + formPath,
+                })
+              }
+            }
+          });
+          return; // 鐩存帴杩斿洖锛岄伩鍏嶆墽琛屽悗缁唬鐮�
+        }
+
+        // 鍏朵粬閫昏緫
+        const questuionName = options.listName;
+        this.setData({
+          questionName: questuionName
+        });
+
+        const systInfo = wx.getSystemInfoSync();
+        const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
+        const navBarHeight =
+          (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
+
+        const token = wx.getStorageSync(app.config.tokenKey);
+        if (!token) {
+          loginInfo(app, (data) => {
+            if (data) {
+              this.init();
+            } else {
+              this.init();
+            }
+          });
         } else {
           this.init();
         }
       })
-    } else {
-      this.init()
-    }
+      .catch((err) => {
+        console.error('妫�鏌ラ搴撳け璐�:', err);
+        wx.showToast({
+          icon: 'error',
+          title: '鍔犺浇澶辫触锛岃閲嶈瘯'
+        });
+      });
   },
 
+
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */

--
Gitblit v1.9.1