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 |  112 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 98 insertions(+), 14 deletions(-)

diff --git a/packageDomain/pages/teacherCertification/index.js b/packageDomain/pages/teacherCertification/index.js
index 28fa09f..df343fc 100644
--- a/packageDomain/pages/teacherCertification/index.js
+++ b/packageDomain/pages/teacherCertification/index.js
@@ -46,6 +46,8 @@
     reasonTxt: "",
     reasonTxtShow: false,
     skeletonLoding: true,
+    isIos: wx.getSystemInfoSync().platform === 'ios',
+    keyboardHeight: 0
   },
 
   /**
@@ -55,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()
-    }
+
   },
 
   /**
@@ -79,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()
+    }
 
   },
 
@@ -111,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,
@@ -140,8 +147,9 @@
       })
       this.newGetTeacherInfo()
     })
-
   },
+
+
   //鑾峰彇鏁欏笀鐘舵��
   newGetTeacherInfo() {
     let that = this;
@@ -572,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: "璇蜂笂浼犲伐浣滆瘉锛�",
@@ -681,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