From 5ca38e4ef60e35f08e87d6569b72c25433c311ca Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 26 三月 2024 17:05:14 +0800
Subject: [PATCH] 答题器bug修改,添加请求地址

---
 packageBookService/pages/bookServices/detail/index.js |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js
index b538001..8e525fa 100644
--- a/packageBookService/pages/bookServices/detail/index.js
+++ b/packageBookService/pages/bookServices/detail/index.js
@@ -34,6 +34,7 @@
     openTeachids: [],
     openLearnids: [],
     openTestids: [],
+    applyResourceState: false,  // 鐢宠鏁欏璧勬簮鎸夐挳闃叉姈
     resourceClassList: [], // 璧勬簮鎵�灞炲垎绫�
     applyState: "",  // 鏁欏璧勬簮鐢宠鐘舵��
     deadline: "",  // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡
@@ -53,7 +54,6 @@
       mockList: [] // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅
     },
     flag: true,
-    applyResourceLoading: false,
     noResources: false,
     selectedIds: "",//鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮�
     bookBuy: false, //鍟嗗搧鎴栧瓙鍟嗗搧鏄惁璐拱
@@ -180,7 +180,7 @@
   // 鏍煎紡鍖栨棩鏈�
   formatDate(dateString) {
     if (!dateString) {
-      return 'Invalid date';
+      return '';
     }
     const match = dateString.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
     if (!match) {
@@ -281,9 +281,12 @@
       });
       this.getSubTtem();
       // 鑾峰彇鍥句功鍒嗙被
-      const iconType = JSON.parse(res.datas.bookClassification)[0][0];
-      const classType = JSON.parse(res.datas.bookClassification)[0][1];
-      const className = await this.getBookClass(iconType, classType)
+      let className = ''
+      if (Array.isArray(res.datas.bookClassification) && res.datas.bookClassification.length) {
+        const iconType = JSON.parse(res.datas.bookClassification)[0][0];
+        const classType = JSON.parse(res.datas.bookClassification)[0][1];
+        className = await this.getBookClass(iconType, classType)
+      }
       // 鑾峰彇缁勫嵎閿�鍞甶d
       if (res.datas.saleMethod && res.datas.saleMethod.length) {
         res.datas.saleMethod.forEach((item) => {
@@ -799,8 +802,6 @@
     });
   },
 
-
-
   async buyBook() {
     if (!this.data.expire) {
       let bookOrdersId = ''
@@ -837,7 +838,7 @@
   },
 
   // 鑾峰彇鏁欏璧勬簮涓嬭浇鏄惁鐢宠閫氳繃
-  getApplyInfo(id) {
+  async getApplyInfo(id) {
     // 鑾峰彇褰撳墠鏃堕棿
     const currentDate = new Date()
     let query = {
@@ -850,7 +851,7 @@
       appRefCode: app.config.appRefCode,
       topicIdOrRefCode: 'productDownLoad'
     }
-    app.MG.ugc.getTopicMessageList(query).then((res) => {
+    await app.MG.ugc.getTopicMessageList(query).then((res) => {
       const applyResource = res.datas.find((item) => {
         let content = []
         try {
@@ -906,13 +907,23 @@
       }
     })
     this.setData({
-      applyResourceLoading: false
+      applyResourceState: false,
     })
+    wx.hideLoading()
   },
   // 鐢宠鏁欏璧勬簮
   applyResource() {
+    if (this.data.applyResourceState) {
+      return wx.showToast({
+        icon: 'error',
+        title: '璇峰嬁閲嶅鐐瑰嚮',
+      })
+    }
     this.setData({
-      applyResourceLoading: true
+      applyResourceState: true
+    })
+    wx.showLoading({
+      title: '鍔犺浇涓�',
     })
     // let role = userStore.userInfo ? userStore.userInfo.role : null
     // if (role) {
@@ -934,13 +945,13 @@
         }
       ])
     }
-    app.MG.ugc.newTopicMessage(query).then((res) => {
+    app.MG.ugc.newTopicMessage(query).then(async (res) => {
       if (res) {
         wx.showToast({
           title: '鐢宠宸叉彁浜わ紝璇峰緟瀹℃牳閫氳繃鍚庝笅杞�',
         })
       }
-      this.getApplyInfo(this.data.bookDetail.id)
+      await this.getApplyInfo(this.data.bookDetail.id)
     })
     //   } else {
     //     ElMessageBox.confirm('璇峰厛杩涜鏁欏笀璁よ瘉锛�', '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', {
@@ -1306,7 +1317,6 @@
         keys: [this.data.bookId]
       })
       .then((res) => {
-        console.log(JSON.parse(res[0].value));
         if (res && res.length) {
           const mock = JSON.parse(res[0].value)
           mock.forEach(item => {

--
Gitblit v1.9.1