From 8ff9b0d45ac250607afa258cf095c9ac7624f96b Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期一, 09 九月 2024 20:14:59 +0800
Subject: [PATCH] bg

---
 packageDomain/pages/sampleBookList/applicationForm/index.js |   69 +++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/applicationForm/index.js b/packageDomain/pages/sampleBookList/applicationForm/index.js
index 9c00d50..451f903 100644
--- a/packageDomain/pages/sampleBookList/applicationForm/index.js
+++ b/packageDomain/pages/sampleBookList/applicationForm/index.js
@@ -5,18 +5,18 @@
 Page({
   data: {
     userInfo: null,
-    active: 0,
+    active: '0',
     description: "", //鐢宠瑙勫垯
     teacherInfo: {
       workInfo: null,
       schoolName: "",
       courseName: "",
-      detailedAddress: ""
+      address: ""
     },
     contactInfo: {
-      fullName: "",
+      user: "",
       phone: "",
-      detailedAddress: ""
+      address: ""
     },
     phoneError: false,
     paperBookList: [], //鏍蜂功鍗曠焊璐ㄤ功
@@ -48,9 +48,9 @@
         that.setData({
           'teacherInfo.schoolName': JSON.parse(that.data.userInfo.data).schoolName,
           'teacherInfo.courseName': JSON.parse(that.data.userInfo.data).courseName,
-          'contactInfo.fullName': JSON.parse(that.data.userInfo.data).fullName,
+          'contactInfo.user': JSON.parse(that.data.userInfo.data).fullName,
           'contactInfo.phone': JSON.parse(that.data.userInfo.data).phone,
-          'contactInfo.detailedAddress': JSON.parse(that.data.userInfo.data).detailedAddress,
+          'contactInfo.address': JSON.parse(that.data.userInfo.data).detailedAddress,
         })
       } else {
         wx.showModal({
@@ -61,24 +61,55 @@
               wx.navigateTo({
                 url: "/packageDomain/pages/teacherCertification/index",
               });
+            } else {
+              wx.navigateBack();
             }
           }
         })
       }
       if (wx.getStorageSync("paperBookList")) {
+        const paperBookList = JSON.parse(wx.getStorageSync("paperBookList"))
+        for (let index = 0; index < paperBookList.length; index++) {
+          const item = paperBookList[index];
+          if (item.publicationDate)
+            item.publicationDate = this.formatDate(item.publicationDate)
+        }
         that.setData({
-          paperBookList: JSON.parse(wx.getStorageSync("paperBookList")),
-          bookList: JSON.parse(wx.getStorageSync("paperBookList"))
+          paperBookList: paperBookList,
+          bookList: paperBookList
         })
       }
       if (wx.getStorageSync("electronicBookList")) {
+        const electronicBookList = JSON.parse(wx.getStorageSync("electronicBookList"))
+        for (let index = 0; index < electronicBookList.length; index++) {
+          const item = electronicBookList[index];
+          if (item.publicationDate)
+            item.publicationDate = this.formatDate(item.publicationDate)
+        }
         that.setData({
-          electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList"))
+          electronicBookList: electronicBookList
         })
       }
       that.getSelectBookCount();
       that.getSelectPaperBookCount();
       that.getPaperType();
+    }
+  },
+
+  formatDate(inputDate) {
+    // 浣跨敤姝e垯琛ㄨ揪寮忓尮閰嶆棩鏈熼儴鍒�  
+    const dateMatch = inputDate.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2})/);
+    if (dateMatch) {
+      // 鎻愬彇骞淬�佹湀銆佹棩  
+      const year = dateMatch[1];
+      const month = dateMatch[2].padStart(2, '0'); // 纭繚鏈堜唤涓轰袱浣嶆暟  
+      const day = dateMatch[3].padStart(2, '0'); // 纭繚鏃ユ湡涓轰袱浣嶆暟  
+
+      // 鎷兼帴骞惰繑鍥炴牸寮忓寲鍚庣殑鏃ユ湡  
+      return `${year}-${month}-${day}`;
+    } else {
+      // 濡傛灉娌℃湁鍖归厤鍒版棩鏈熼儴鍒嗭紝鍒欒繑鍥炲師濮嬭緭鍏ユ垨鎶涘嚭閿欒  
+      return inputDate; // 鎴栬�� throw new Error('Invalid date format');  
     }
   },
 
@@ -123,6 +154,7 @@
           'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
         })
       }
+
     })
   },
   //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙鐢靛瓙锛�
@@ -156,7 +188,7 @@
   //濮撳悕
   onFullNameInput(e) {
     this.setData({
-      "contactInfo.fullName": e.detail.value,
+      "contactInfo.user": e.detail.value,
     });
   },
   //杈撳叆鎵嬫満鍙�
@@ -178,13 +210,11 @@
       });
     }
   },
-  onAddressInput() {
+  onAddressInput(e) {
     this.setData({
-      "contactInfo.detailedAddress": e.detail.value,
+      "contactInfo.address": e.detail.value,
     });
   },
-
-
   submit() {
     let that = this;
     if (that.data.bookList.length > 0) {
@@ -222,7 +252,7 @@
           refType: 'applyBook'
         }
       } else {
-        if (!(that.data.contactInfo.fullName && that.data.contactInfo.phone && that.data.contactInfo.detailedAddress)) {
+        if (!(that.data.contactInfo.user && that.data.contactInfo.phone && that.data.contactInfo.address)) {
           wx.showToast({
             title: "璇峰皢鏀惰揣浜轰俊鎭~鍐欏畬鏁达紒",
             icon: 'none',
@@ -232,7 +262,7 @@
         }
         const mailAddress = JSON.stringify(that.data.contactInfo)
         that.setData({
-          'teacherInfo.detailedAddress': mailAddress
+          'teacherInfo.address': mailAddress
         })
 
         data = {
@@ -308,7 +338,7 @@
             that.setData({
               bookList: eList
             })
-            wx.setStorageSync("electronicBookList", eList);
+            wx.setStorageSync("electronicBookList", JSON.stringify(eList));
           } else {
             let pList = that.data.paperBookList;
             pList.forEach((obj, index) => {
@@ -319,7 +349,7 @@
             that.setData({
               bookList: pList
             })
-            wx.setStorageSync("paperBookList", pList);
+            wx.setStorageSync("paperBookList", JSON.stringify(pList));
           }
         } else if (res.cancel) {}
       }
@@ -394,6 +424,9 @@
       } catch (error) {}
     }
   },
+  changeParam(e) {
+    this.scrollToInput(0);
+  },
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */

--
Gitblit v1.9.1