From e6a156a6a8bb6f1d3a17e9310269f53c56e10b42 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期一, 08 四月 2024 22:29:26 +0800
Subject: [PATCH] 问题修改

---
 packageDomain/pages/sampleBookList/applicationForm/index.js |  109 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/applicationForm/index.js b/packageDomain/pages/sampleBookList/applicationForm/index.js
index e884a0f..b1831f9 100644
--- a/packageDomain/pages/sampleBookList/applicationForm/index.js
+++ b/packageDomain/pages/sampleBookList/applicationForm/index.js
@@ -1,4 +1,6 @@
-import { worksDataBytool } from "../../../../assets/js/toolClass.js";
+import {
+  worksDataBytool
+} from "../../../../assets/js/toolClass.js";
 const app = getApp();
 Page({
   data: {
@@ -16,6 +18,7 @@
       phone: "",
       detailedAddress: ""
     },
+    phoneError: false,
     paperBookList: [], //鏍蜂功鍗曠焊璐ㄤ功
     electronicBookList: [], //鏍蜂功鍗曠數瀛愪功
     ebookCount: 0,
@@ -26,10 +29,10 @@
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
-  onLoad() { },
+  onLoad() {},
   /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
- */
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+   */
   onShow() {
     if (wx.getStorageSync(app.config.userInfoKey)) {
       this.setData({
@@ -42,6 +45,18 @@
           'contactInfo.fullName': JSON.parse(this.data.userInfo.data).fullName,
           'contactInfo.phone': JSON.parse(this.data.userInfo.data).phone,
           'contactInfo.detailedAddress': JSON.parse(this.data.userInfo.data).detailedAddress,
+        })
+      } else {
+        wx.showModal({
+          title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', //鎻愮ず鐨勬爣棰�
+          content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', //鎻愮ず鐨勫唴瀹�
+          success: function (res) {
+            if (res.confirm) {
+              wx.navigateTo({
+                url: "/packageDomain/pages/teacherCertification/index",
+              });
+            }
+          }
         })
       }
       if (wx.getStorageSync("paperBookList")) {
@@ -58,16 +73,14 @@
       this.getSelectBookCount();
       this.getSelectPaperBookCount();
       this.getPaperType();
-    } else {
-      wx.navigateTo({
-        url: "/pages/testLogin/index",
-      });
     }
-
   },
 
   tabClick(item) {
     let that = this;
+    that.setData({
+      bookList: []
+    })
     if (item.detail.value == '1') {
       that.setData({
         active: item.detail.value,
@@ -84,7 +97,9 @@
   },
 
   getElectronType() {
-    app.MG.resource.getCmsTypeByRefCode({ refCodes: ['jsek_electronicSampleBook'] }).then((res) => {
+    app.MG.resource.getCmsTypeByRefCode({
+      refCodes: ['jsek_electronicSampleBook']
+    }).then((res) => {
       this.setData({
         description: res[0].description,
         'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
@@ -95,23 +110,22 @@
     app.MG.resource.getCmsTypeByRefCode({
       refCodes: ['jsek_paperVersionSampleBook']
     }).
-      then((res) => {
-        if (res && res.length > 0) {
-          this.setData({
-            description: res[0].description,
-            'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
-          })
-        }
-        console.log(this.data.teacherInfo.workInfo, 333)
-      })
+    then((res) => {
+      if (res && res.length > 0) {
+        this.setData({
+          description: res[0].description,
+          'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
+        })
+      }
+    })
   },
   //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙鐢靛瓙锛�
   getSelectBookCount() {
     let that = this;
     app.MG.app.getTicketResult({
-      ticketRefCodeOrGuid: 'electronicSampleBookapplyNum',
-      roleId: that.data.userInfo.roleId
-    })
+        ticketRefCodeOrGuid: 'electronicSampleBookapplyNum',
+        roleId: that.data.userInfo.roleId
+      })
       .then((res) => {
         let num = res.totalCount - res.usedCount;
         that.setData({
@@ -123,9 +137,9 @@
   getSelectPaperBookCount() {
     let that = this;
     app.MG.app.getTicketResult({
-      ticketRefCodeOrGuid: 'paperSampleBookapplyNum',
-      roleId: that.data.userInfo.roleId
-    })
+        ticketRefCodeOrGuid: 'paperSampleBookapplyNum',
+        roleId: that.data.userInfo.roleId
+      })
       .then((res) => {
         let count = res.totalCount - res.usedCount;
         that.setData({
@@ -133,6 +147,37 @@
         })
       })
   },
+  //濮撳悕
+  onFullNameInput(e) {
+    this.setData({
+      "contactInfo.fullName": e.detail.value,
+    });
+  },
+  //杈撳叆鎵嬫満鍙�
+  onPhoneInput(e) {
+    const {
+      phoneError
+    } = this.data;
+    if (e.detail.value) {
+      const isPhoneNumber = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e.detail.value);
+      if (phoneError === isPhoneNumber) {
+        this.setData({
+          phoneError: !isPhoneNumber,
+          "contactInfo.phone": e.detail.value,
+        });
+      }
+    } else {
+      this.setData({
+        phoneError: false,
+      });
+    }
+  },
+  onAddressInput() {
+    this.setData({
+      "contactInfo.detailedAddress": e.detail.value,
+    });
+  },
+
 
   submit() {
     let that = this;
@@ -179,12 +224,10 @@
           })
           return
         }
-
         const mailAddress = JSON.stringify(that.data.contactInfo)
         that.setData({
           'teacherInfo.detailedAddress': mailAddress
         })
-        console.log(that.data.teacherInfo.workInfo, 345)
 
         data = {
           topicIdOrRefCode: 'applyEntityBook',
@@ -209,13 +252,13 @@
                 electronicBookList: [],
                 bookList: [],
               })
-              wx.setStorageSync("electronicBookList", that.data.electronicBookList);
+              wx.removeStorageSync("electronicBookList")
             } else {
               that.setData({
                 paperBookList: [],
                 bookList: [],
               })
-              wx.setStorageSync("paperBookList", that.data.paperBookList);
+              wx.removeStorageSync("paperBookList")
             }
             wx.showModal({
               title: '鎻愮ず锛�', //鎻愮ず鐨勬爣棰�
@@ -223,10 +266,9 @@
               success: function (res) {
                 if (res.confirm) {
                   wx.navigateTo({
-                    url: "/packagePersonal/pages/sampleBooks/index",
+                    url: "/packagePersonal/pages/sampleBooks/index?stateTab=1&tabActive=" + that.data.active,
                   });
-                } else if (res.cancel) {
-                }
+                } else if (res.cancel) {}
               }
             })
           })
@@ -273,8 +315,7 @@
             })
             wx.setStorageSync("paperBookList", pList);
           }
-        } else if (res.cancel) {
-        }
+        } else if (res.cancel) {}
       }
     })
   },

--
Gitblit v1.9.1