| | |
| | | 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({ |
| | | |
| | | /** |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | 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() |
| | | } |
| | | }, |
| | |
| | | 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, |
| | | } |
| | | } |
| | |
| | | } |
| | | }) |
| | | }, |
| | | //获取字段 |
| | | 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, |
| | |
| | | } |
| | | 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, |
| | |
| | | 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', |
| | |
| | | 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'] |
| | |
| | | |
| | | //选择职称 |
| | | 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], |
| | |
| | | }, |
| | | //输入手机号 |
| | | 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({ |
| | |
| | | }, |
| | | //输入座机 |
| | | 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({ |
| | |
| | | } |
| | | }, |
| | | 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({ |
| | |
| | | chooseImg(e) { |
| | | var that = this; |
| | | wx.chooseMedia({ |
| | | // count: 1, // 默认9 |
| | | count: 1, |
| | | sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 |
| | | sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 |
| | | success: function (res) { |
| | |
| | | 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]]; |
| | |
| | | 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) { |
| | |
| | | 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(() => { |
| | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | }, |
| | | onReachBottom() {}, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |