From 9f916f98c6cc6827c84da18fbc9a5e2cacbefc0a Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 02 四月 2024 16:20:08 +0800
Subject: [PATCH] Merge refs/remotes/origin/master into refs/heads/master

---
 packageDomain/pages/sampleBookList/applicationForm/index.js |  147 ++++++++++++++++++++++++++++--------------------
 1 files changed, 86 insertions(+), 61 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/applicationForm/index.js b/packageDomain/pages/sampleBookList/applicationForm/index.js
index 19715ff..6b599f9 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: {
@@ -9,12 +11,14 @@
       workInfo: null,
       schoolName: "",
       courseName: "",
+      detailedAddress: ""
     },
     contactInfo: {
       fullName: "",
       phone: "",
       detailedAddress: ""
     },
+    phoneError: false,
     paperBookList: [], //鏍蜂功鍗曠焊璐ㄤ功
     electronicBookList: [], //鏍蜂功鍗曠數瀛愪功
     ebookCount: 0,
@@ -25,10 +29,10 @@
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
-  onLoad() { },
+  onLoad() {},
   /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
- */
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+   */
   onShow() {
     if (wx.getStorageSync(app.config.userInfoKey)) {
       this.setData({
@@ -36,41 +40,35 @@
       })
       if (this.data.userInfo.role == 'Teacher') {
         this.setData({
-          teacherInfo: {
-            schoolName: JSON.parse(this.data.userInfo.data).schoolName,
-            courseName: JSON.parse(this.data.userInfo.data).courseName,
-          },
-          contactInfo: {
-            fullName: JSON.parse(this.data.userInfo.data).fullName,
-            phone: JSON.parse(this.data.userInfo.data).phone,
-            detailedAddress: JSON.parse(this.data.userInfo.data).detailedAddress
-          }
+          'teacherInfo.schoolName': JSON.parse(this.data.userInfo.data).schoolName,
+          'teacherInfo.courseName': JSON.parse(this.data.userInfo.data).courseName,
+          '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,
         })
       }
       if (wx.getStorageSync("paperBookList")) {
         this.setData({
-          paperBookList: JSON.parse(wx.getStorageSync("paperBookList")),
-          bookList: JSON.parse(wx.getStorageSync("paperBookList"))
+          paperBookList: wx.getStorageSync("paperBookList"),
+          bookList: wx.getStorageSync("paperBookList")
         })
       }
       if (wx.getStorageSync("electronicBookList")) {
         this.setData({
-          electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList"))
+          electronicBookList: wx.getStorageSync("electronicBookList")
         })
       }
       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,
@@ -87,12 +85,12 @@
   },
 
   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
-        },
+        'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
       })
     })
   },
@@ -100,24 +98,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
-            },
-          })
-        }
-      })
+    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({
@@ -129,9 +125,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({
@@ -139,6 +135,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;
@@ -173,7 +200,7 @@
         }
         applyInfo = {
           ticketRefCodeOrGuid: 'electronicSampleBookapplyNum',
-          roleId: userStore.userInfo.roleId,
+          roleId: that.data.userInfo.roleId,
           refType: 'applyBook'
         }
       } else {
@@ -187,10 +214,9 @@
         }
         const mailAddress = JSON.stringify(that.data.contactInfo)
         that.setData({
-          teacherInfo: {
-            detailedAddress: mailAddress,
-          }
+          'teacherInfo.detailedAddress': mailAddress
         })
+
         data = {
           topicIdOrRefCode: 'applyEntityBook',
           name: that.data.userInfo.name || '',
@@ -214,25 +240,23 @@
                 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: '鎻愮ず锛�', //鎻愮ず鐨勬爣棰�
               content: '鎮ㄧ殑鏍蜂功鐢宠宸叉彁浜わ紝绠$悊鍛樺鏍镐腑锛佺敵璇风姸鎬佸湪銆愪釜浜轰腑蹇冣�旀牱涔︾敵璇枫�戜腑鏌ヨ銆�', //鎻愮ず鐨勫唴瀹�
               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) {}
               }
             })
           })
@@ -257,28 +281,29 @@
       success: function (res) {
         if (res.confirm) {
           if (that.data.active == '1') {
-            that.data.electronicBookList.forEach((obj, index) => {
+            let eList = that.data.electronicBookList;
+            eList.forEach((obj, index) => {
               if (obj.id == item.id) {
-                that.data.electronicBookList.splice(index, 1);
+                eList.splice(index, 1);
               }
             })
             that.setData({
-              bookList: that.data.electronicBookList
+              bookList: eList
             })
-            wx.setStorageSync("electronicBookList", that.data.electronicBookList);
+            wx.setStorageSync("electronicBookList", eList);
           } else {
-            that.data.paperBookList.forEach((obj, index) => {
+            let pList = that.data.paperBookList;
+            pList.forEach((obj, index) => {
               if (obj.id == item.id) {
-                that.data.paperBookList.splice(index, 1);
+                pList.splice(index, 1);
               }
             })
             that.setData({
-              bookList: this.data.paperBookList
+              bookList: pList
             })
-            wx.setStorageSync("paperBookList", that.data.paperBookList);
+            wx.setStorageSync("paperBookList", pList);
           }
-        } else if (res.cancel) {
-        }
+        } else if (res.cancel) {}
       }
     })
   },

--
Gitblit v1.9.1