闫增涛
2024-03-28 0b523220931d70aa752c3beaca5ed32ca85511c5
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,21 @@
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    //获取职称
    this.getpositionalTitle();
    this.getAgreement();
    if (wx.getStorageSync(app.config.tokenKey)) {
      this.getUserRole()
    }
    // 检查登录状态
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.getUserRole()
        }
      })
    } else {
      this.getUserRole()
    }
  },
@@ -91,7 +107,6 @@
        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) {
@@ -103,9 +118,6 @@
            role: 'Teacher',
            roleId: teacherRole.role.id,
          }
          this.setData({
            currAuthStep: 2,
          });
        } else if (WeChatInfo) {
          defaultUser = {
@@ -114,20 +126,13 @@
            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 : "",
            userId: res.userId,
          }
        }
        wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser));
      }
    })
  },
  //获取字段
  getType() {
    app.MG.resource.getCmsTypeByRefCode({
      refCodes: ['jsek_teacherCertification']
@@ -139,6 +144,7 @@
      this.newGetTeacherInfo()
    })
  },
  //获取教师状态
  newGetTeacherInfo() {
    const data = {
      start: 0,
@@ -209,8 +215,7 @@
                md5: this.data.teacherInfo.relevantCertificates,
                linkType: 'LinkFile',
                linkProtectType: 'Public',
                url:
                  app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates,
                url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates,
                imgUrl: app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates,
              }
              arr.push(imgObj);
@@ -221,11 +226,10 @@
          }
        }
      } catch (error) {
      }
      } catch (error) {}
    })
  },
  //获取职称
  getpositionalTitle() {
    const data = {
      refCodes: ['positionalTitle']
@@ -293,10 +297,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 +319,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 +332,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 +344,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 +359,7 @@
  chooseImg(e) {
    var that = this;
    wx.chooseMedia({
      // count: 1, // 默认9
      count: 1,
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
      success: function (res) {
@@ -383,14 +397,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 +577,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 +613,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 +655,7 @@
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  onReachBottom() {},
  /**
   * 用户点击右上角分享