From 4b5f1f7ed3460df9465e5071a59b8105cbc9146e Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期五, 29 三月 2024 14:35:30 +0800
Subject: [PATCH] 修改

---
 packageDomain/pages/teacherCertification/index.js |  136 +++++++++++++++++++++++---------------------
 1 files changed, 71 insertions(+), 65 deletions(-)

diff --git a/packageDomain/pages/teacherCertification/index.js b/packageDomain/pages/teacherCertification/index.js
index 82493b7..9ed9576 100644
--- a/packageDomain/pages/teacherCertification/index.js
+++ b/packageDomain/pages/teacherCertification/index.js
@@ -1,8 +1,13 @@
 const app = getApp();
 import SparkMD5 from 'spark-md5'
 import tool from "../../../assets/js/toolClass.js";
-import { getTopicMsgCmsItemFile } from '../../../assets/js/middleGround/tool.js';
+import {
+  getTopicMsgCmsItemFile
+} from '../../../assets/js/middleGround/tool.js';
 import FormData from '../../../utils/formdata/index.js';
+import {
+  loginInfo
+} from '../../../assets/js/login';
 Page({
 
   /**
@@ -46,10 +51,18 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad() {
+    //鑾峰彇鑱岀О
     this.getpositionalTitle();
     this.getAgreement();
-
-    if (wx.getStorageSync(app.config.tokenKey)) {
+    // 妫�鏌ョ櫥褰曠姸鎬�
+    const token = wx.getStorageSync(app.config.tokenKey)
+    if (!token) {
+      loginInfo(app, (data) => {
+        if (data) {
+          this.getUserRole()
+        }
+      })
+    } else {
       this.getUserRole()
     }
   },
@@ -91,36 +104,23 @@
         let nickNameData = res.infoList.find((item) => item.type == 'nickName')
         let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
         let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
-        let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword')
         let WeChatInfo = res.infoList.find((item) => item.type === "WeChat");
         let defaultUser = {};
         if (teacherRole && teacherInfos) {
           defaultUser = {
             ...teacherInfos,
-            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : teacherInfos.name,
-            icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
+            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,
             userId: res.userId,
             role: 'Teacher',
             roleId: teacherRole.role.id,
           }
-          this.setData({
-            currAuthStep: 2,
-          });
 
         } else if (WeChatInfo) {
           defaultUser = {
             ...WeChatInfo,
-            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
-            icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
-            userId: res.userId,
-          }
-          this.setData({
-            currAuthStep: 3,
-          });
-        } else if (secretData) {
-          defaultUser = {
-            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : secretData.credential,
-            icon: nickNameData ? JSON.parse(nickNameData.data).icon : "",
+            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,
             userId: res.userId,
           }
         }
@@ -128,18 +128,21 @@
       }
     })
   },
+  //鑾峰彇瀛楁
   getType() {
     app.MG.resource.getCmsTypeByRefCode({
       refCodes: ['jsek_teacherCertification']
     }).then((res) => {
-      console.log(res)
       this.setData({
         worksInfo: res[0].cmsTypeLinks[0].children,
       })
       this.newGetTeacherInfo()
     })
+
   },
+  //鑾峰彇鏁欏笀鐘舵��
   newGetTeacherInfo() {
+    let that = this;
     const data = {
       start: 0,
       size: 10,
@@ -152,22 +155,22 @@
     }
     app.MG.ugc.getTopicMessageList(data).then((res) => {
       try {
-        this.setData({
+        that.setData({
           imgPics: [],
         })
-        const resData = res.datas.find((i) => i.appUserCreator.userId === this.data.userId)
+        const resData = res.datas.find((i) => i.appUserCreator.userId === that.data.userId)
         if (resData) {
           if (resData.state == 'WaitAudit') {
-            this.setData({
+            that.setData({
               editState: false,
             })
           } else {
-            this.setData({
+            that.setData({
               editState: true,
             })
           }
-          let info = getTopicMsgCmsItemFile(this.data.worksInfo, resData.cmsItemDataList)
-          this.setData({
+          let info = getTopicMsgCmsItemFile(that.data.worksInfo, resData.cmsItemDataList)
+          that.setData({
             'teacherInfo.fullName': info.fullName,
             'teacherInfo.schoolName': info.schoolName,
             'teacherInfo.positionalTitle': info.positionalTitle,
@@ -184,14 +187,14 @@
             teachText: info.positionalTitle,
           })
           if (resData.feedBack != null) {
-            this.setData({
+            that.setData({
               reasonTxt: JSON.parse(resData.feedBack).reason,
             })
           }
-          if (this.data.teacherInfo.relevantCertificates.length > 0) {
+          if (that.data.teacherInfo.relevantCertificates.length > 0) {
             let arr = [];
-            if (typeof this.data.teacherInfo.relevantCertificates == 'object') {
-              this.data.teacherInfo.relevantCertificates.forEach((ele) => {
+            if (typeof that.data.teacherInfo.relevantCertificates == 'object') {
+              that.data.teacherInfo.relevantCertificates.forEach((ele) => {
                 let imgObj = {
                   md5: ele.file.md5,
                   linkType: 'LinkFile',
@@ -200,32 +203,30 @@
                   imgUrl: ele.file.imgUrl
                 }
                 arr.push(imgObj);
-                this.setData({
+                that.setData({
                   imgPics: arr,
                 });
               })
             } else {
               let imgObj = {
-                md5: this.data.teacherInfo.relevantCertificates,
+                md5: that.data.teacherInfo.relevantCertificates,
                 linkType: 'LinkFile',
                 linkProtectType: 'Public',
-                url:
-                  app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates,
-                imgUrl: app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates,
+                url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + that.data.teacherInfo.relevantCertificates,
+                imgUrl: app.config.requestCtx + `/file/GetPreViewImage?md5=` + that.data.teacherInfo.relevantCertificates,
               }
               arr.push(imgObj);
-              this.setData({
+              that.setData({
                 imgPics: arr,
               });
             }
           }
 
         }
-      } catch (error) {
-      }
+      } catch (error) {}
     })
   },
-
+  //鑾峰彇鑱岀О
   getpositionalTitle() {
     const data = {
       refCodes: ['positionalTitle']
@@ -293,10 +294,14 @@
 
   //閫夋嫨鑱岀О
   onTeachPicker() {
-    this.setData({ teachVisible: true });
+    this.setData({
+      teachVisible: true
+    });
   },
   onPickerChange(e) {
-    const { label } = e.detail;
+    const {
+      label
+    } = e.detail;
     this.setData({
       teachVisible: false,
       teachText: label[0],
@@ -311,7 +316,9 @@
   },
   //杈撳叆鎵嬫満鍙�
   onPhoneInput(e) {
-    const { phoneError } = this.data;
+    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) {
       this.setData({
@@ -322,7 +329,9 @@
   },
   //杈撳叆搴ф満
   onTelphoneInput(e) {
-    const { telphoneError } = this.data;
+    const {
+      telphoneError
+    } = this.data;
     const isPhoneNumber = /^0\d{2}-\d{8}$|^0\d{3}-\d{7}$/.test(e.detail.value);
     if (telphoneError === isPhoneNumber) {
       this.setData({
@@ -332,7 +341,9 @@
     }
   },
   onEmailInput(e) {
-    const { emailError } = this.data;
+    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) {
       this.setData({
@@ -345,7 +356,7 @@
   chooseImg(e) {
     var that = this;
     wx.chooseMedia({
-      // count: 1, // 榛樿9
+      count: 1,
       sizeType: ['original', 'compressed'], // 鍙互鎸囧畾鏄師鍥捐繕鏄帇缂╁浘锛岄粯璁や簩鑰呴兘鏈�
       sourceType: ['album', 'camera'], // 鍙互鎸囧畾鏉ユ簮鏄浉鍐岃繕鏄浉鏈猴紝榛樿浜岃�呴兘鏈�
       success: function (res) {
@@ -383,14 +394,14 @@
                   data: data.buffer,
                   success(res1) {
                     if (res1.statusCode == 200) {
-                      resolve(res1.data); if (res1.data) {
+                      resolve(res1.data);
+                      if (res1.data) {
                         let arr = [];
                         let imgObj = {
                           md5: md5,
                           linkType: 'LinkFile',
                           linkProtectType: 'Public',
-                          url:
-                            app.config.requestCtx + `/file/GetPreViewImage?md5=` + md5,
+                          url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + md5,
                           imgUrl: res.tempFiles[0].tempFilePath
                         }
                         arr = [...that.data.imgPics, ...[imgObj]];
@@ -563,13 +574,11 @@
         delete basicInfo.worksInfo
         delete basicInfo.state
         const userInfo = {
-          requests: [
-            {
-              data: JSON.stringify(basicInfo),
-              name: that.data.teacherInfo.fullName + '',
-              type: 'newTeacherInfo'
-            }
-          ]
+          requests: [{
+            data: JSON.stringify(basicInfo),
+            name: that.data.teacherInfo.fullName + '',
+            type: 'newTeacherInfo'
+          }]
         }
         app.MG.identity.setAppUserInfo(userInfo).then((res) => {
           if (res) {
@@ -601,13 +610,11 @@
         delete basicInfo.worksInfo
         delete basicInfo.state
         const userInfo = {
-          requests: [
-            {
-              data: JSON.stringify(basicInfo),
-              name: that.data.teacherInfo.fullName + '',
-              type: 'teacherInfo'
-            }
-          ]
+          requests: [{
+            data: JSON.stringify(basicInfo),
+            name: that.data.teacherInfo.fullName + '',
+            type: 'teacherInfo'
+          }]
         }
         app.MG.identity.setAppUserInfo(userInfo).then((res) => {
           app.MG.ugc.newTopicMessage(data).then(() => {
@@ -645,8 +652,7 @@
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
-  onReachBottom() {
-  },
+  onReachBottom() {},
 
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�

--
Gitblit v1.9.1