From aff8d054df4a638f399dc8f15d98c19b9c9aa785 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 29 四月 2025 10:11:25 +0800
Subject: [PATCH] 扫码视频播放

---
 packageDomain/pages/teacherCertification/index.js |  173 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 145 insertions(+), 28 deletions(-)

diff --git a/packageDomain/pages/teacherCertification/index.js b/packageDomain/pages/teacherCertification/index.js
index 9ed9576..df343fc 100644
--- a/packageDomain/pages/teacherCertification/index.js
+++ b/packageDomain/pages/teacherCertification/index.js
@@ -45,6 +45,9 @@
     editState: true,
     reasonTxt: "",
     reasonTxtShow: false,
+    skeletonLoding: true,
+    isIos: wx.getSystemInfoSync().platform === 'ios',
+    keyboardHeight: 0
   },
 
   /**
@@ -54,17 +57,7 @@
     //鑾峰彇鑱岀О
     this.getpositionalTitle();
     this.getAgreement();
-    // 妫�鏌ョ櫥褰曠姸鎬�
-    const token = wx.getStorageSync(app.config.tokenKey)
-    if (!token) {
-      loginInfo(app, (data) => {
-        if (data) {
-          this.getUserRole()
-        }
-      })
-    } else {
-      this.getUserRole()
-    }
+
   },
 
   /**
@@ -78,6 +71,21 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
+    // 妫�鏌ョ櫥褰曠姸鎬�
+    const token = wx.getStorageSync(app.config.tokenKey)
+    if (!token) {
+      loginInfo(app, (data) => {
+        if (data) {
+          this.getUserRole()
+        } else {
+          wx.switchTab({
+            url: '/pages/home/home',
+          })
+        }
+      })
+    } else {
+      this.getUserRole()
+    }
 
   },
 
@@ -99,7 +107,8 @@
       if (res) {
         this.getType()
         this.setData({
-          userId: res.userId
+          userId: res.userId,
+          skeletonLoding: true,
         })
         let nickNameData = res.infoList.find((item) => item.type == 'nickName')
         let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
@@ -109,8 +118,8 @@
         if (teacherRole && teacherInfos) {
           defaultUser = {
             ...teacherInfos,
-            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
-            icon: nickNameData && JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
+            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : WeChatInfo ? WeChatInfo.name : '',
+            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
             userId: res.userId,
             role: 'Teacher',
             roleId: teacherRole.role.id,
@@ -120,7 +129,7 @@
           defaultUser = {
             ...WeChatInfo,
             nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
-            icon: nickNameData && JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
+            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
             userId: res.userId,
           }
         }
@@ -138,8 +147,9 @@
       })
       this.newGetTeacherInfo()
     })
-
   },
+
+
   //鑾峰彇鏁欏笀鐘舵��
   newGetTeacherInfo() {
     let that = this;
@@ -185,6 +195,7 @@
             topicId: resData.id,
             topicMessageList: resData.cmsItemDataList,
             teachText: info.positionalTitle,
+            skeletonLoding: false,
           })
           if (resData.feedBack != null) {
             that.setData({
@@ -222,6 +233,10 @@
             }
           }
 
+        } else {
+          that.setData({
+            skeletonLoding: false,
+          });
         }
       } catch (error) {}
     })
@@ -319,11 +334,17 @@
     const {
       phoneError
     } = this.data;
-    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) {
+    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,
+          "teacherInfo.phone": e.detail.value,
+        });
+      }
+    } else {
       this.setData({
-        phoneError: !isPhoneNumber,
-        "teacherInfo.phone": e.detail.value,
+        phoneError: false,
       });
     }
   },
@@ -332,11 +353,17 @@
     const {
       telphoneError
     } = this.data;
-    const isPhoneNumber = /^0\d{2}-\d{8}$|^0\d{3}-\d{7}$/.test(e.detail.value);
-    if (telphoneError === isPhoneNumber) {
+    if (e.detail.value) {
+      const isPhoneNumber = /^0\d{2}-\d{8}$|^0\d{3}-\d{7}$/.test(e.detail.value);
+      if (telphoneError === isPhoneNumber) {
+        this.setData({
+          telphoneError: !isPhoneNumber,
+          "teacherInfo.telphone": e.detail.value,
+        });
+      }
+    } else {
       this.setData({
-        telphoneError: !isPhoneNumber,
-        "teacherInfo.telphone": e.detail.value,
+        telphoneError: false,
       });
     }
   },
@@ -344,17 +371,31 @@
     const {
       emailError
     } = this.data;
-    const isPhoneNumber = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(e.detail.value);
-    if (emailError === isPhoneNumber) {
+    if (e.detail.value) {
+      const isPhoneNumber = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(e.detail.value);
+      if (emailError === isPhoneNumber) {
+        this.setData({
+          emailError: !isPhoneNumber,
+          "teacherInfo.email": e.detail.value,
+        });
+      }
+    } else {
       this.setData({
-        emailError: !isPhoneNumber,
-        "teacherInfo.email": e.detail.value,
+        emailError: false,
       });
     }
   },
   // 涓婁紶鍥剧墖浜嬩欢
   chooseImg(e) {
     var that = this;
+    if (that.data.imgPics.length == 4) {
+      wx.showToast({
+        title: "宸ヤ綔璇佹枃浠朵笉瓒呰繃5涓紒",
+        icon: 'none',
+        duration: 1000,
+      })
+      return
+    }
     wx.chooseMedia({
       count: 1,
       sizeType: ['original', 'compressed'], // 鍙互鎸囧畾鏄師鍥捐繕鏄帇缂╁浘锛岄粯璁や簩鑰呴兘鏈�
@@ -539,6 +580,14 @@
       })
       return
     }
+    if (!that.data.teacherInfo.detailedAddress) {
+      wx.showToast({
+        title: "璇峰~鍐欒缁嗗湴鍧�锛�",
+        icon: 'none',
+        duration: 1000,
+      })
+      return
+    }
     if (that.data.imgPics.length == 0) {
       wx.showToast({
         title: "璇蜂笂浼犲伐浣滆瘉锛�",
@@ -648,7 +697,75 @@
       this.getUserRole()
     }
   },
+  // 鐩戝惉椤甸潰杞敭鐩樺脊璧锋墜鍔ㄦ帹鍔ㄩ〉闈�
+  bindkeyboardheightchange(e) {
+    // 鍙ios 澶勭悊
+    if (!this.data.isIos === 'ios') {
+      return
+    }
+    // 閿洏楂樺害
+    const height = e.detail.height;
+    const className = e.target.dataset.class;
+    if (height === 0) {
+      this.scrollToInput(0);
+      return;
+    }
+    try {
+      this.createSelectorQuery()
+        .select(`.${className}`)
+        .boundingClientRect((res) => {
+          // 鍙娇鐢ㄧ獥鍙i珮搴�
+          const windowHeight = wx.getSystemInfoSync().windowHeight;
+          // 闄ゅ幓閿洏鐨勫墿浣欓珮搴�
+          let restHeight = windowHeight - height;
+          // 鍏冪礌宸︿笅瑙掑潗鏍�
+          let bottom = res.bottom;
+          // 鍙湁褰撳厓绱犺杞敭鐩樿鐩栫殑鏃跺�欐墠涓婃帹椤甸潰
+          if (bottom <= restHeight) return;
+          // 鐜伴樁娈甸渶瑕佹粴鍔ㄧ殑澶у皬
+          let scrollTop = bottom - restHeight;
+          this.scrollToInput(height, scrollTop);
+        })
+        .exec();
+    } catch (error) {}
+  },
 
+  // 鑾峰彇椤甸潰婊氬姩鏉′綅缃�
+  getScrollOffset() {
+    return new Promise((resolve) => {
+      try {
+        wx.createSelectorQuery()
+          .selectViewport()
+          .scrollOffset((res) => {
+            resolve(res.scrollTop);
+          })
+          .exec();
+      } catch (error) {
+        resolve(0);
+      }
+    });
+  },
+
+  // 鐩戝惉椤甸潰杞敭鐩樺脊璧锋墜鍔ㄦ帹鍔ㄩ〉闈�
+  scrollToInput(keyboardHeight, scrollTop) {
+    this.setData({
+      keyboardHeight,
+    });
+    if (scrollTop) {
+      try {
+        this.getScrollOffset().then((lastScrollTop) => {
+          wx.pageScrollTo({
+            // 濡傛灉宸茬粡瀛樺湪婊氬姩锛屽湪姝ゅ熀纭�涓婄户缁粴
+            scrollTop: lastScrollTop ? lastScrollTop + scrollTop : scrollTop,
+            duration: 300,
+          });
+        });
+      } catch (error) {}
+    }
+  },
+  changeParam(e) {
+    this.scrollToInput(0);
+  },
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */

--
Gitblit v1.9.1