| | |
| | | const app = getApp(); |
| | | import SparkMD5 from 'spark-md5' |
| | | import tool from "../../../assets/js/toolClass.js"; |
| | | import { getTopicMsgCmsItemFile } from '../../../assets/js/middleGround/tool.js'; |
| | | import FormData from '../../../utils/formdata/index.js'; |
| | |
| | | this.setData({ |
| | | userId: res.userId |
| | | }) |
| | | 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 wechatInfo = res.infoList.find((item) => item.type == 'WeChat') |
| | | let studentInfo = res.infoList.find((item) => item.type == 'Default') |
| | | let phoneInfo = res.secretList.find((item) => item.type == 'MobilePhone') |
| | | let emailInfo = res.secretList.find((item) => item.type == 'EMail') |
| | | 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: teacherInfos.fullName, |
| | | avatarUrl: teacherInfos.icon, |
| | | nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : teacherInfos.name, |
| | | icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '', |
| | | userId: res.userId, |
| | | phoneNumber: phoneInfo?.credential, |
| | | Email: emailInfo ? emailInfo.credential : JSON.parse(teacherInfos.data).email, |
| | | role: 'Teacher', |
| | | roleId: teacherRole.role.id |
| | | roleId: teacherRole.role.id, |
| | | } |
| | | this.setData({ |
| | | currAuthStep: 2, |
| | | }); |
| | | |
| | | } else if (wechatInfo) { |
| | | } else if (WeChatInfo) { |
| | | defaultUser = { |
| | | ...wechatInfo, |
| | | nickName: wechatInfo.name, |
| | | avatarUrl: wechatInfo.icon, |
| | | ...WeChatInfo, |
| | | nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name, |
| | | icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon, |
| | | userId: res.userId, |
| | | phoneNumber: phoneInfo?.credential, |
| | | Email: emailInfo?.credential, |
| | | role: 'Student' |
| | | } |
| | | } else if (studentInfo) { |
| | | this.setData({ |
| | | currAuthStep: 3, |
| | | }); |
| | | } else if (secretData) { |
| | | defaultUser = { |
| | | ...studentInfo, |
| | | nickName: wechatInfo.name, |
| | | avatarUrl: wechatInfo.icon, |
| | | nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : secretData.credential, |
| | | icon: nickNameData ? JSON.parse(nickNameData.data).icon : "", |
| | | userId: res.userId, |
| | | phoneNumber: phoneInfo?.credential, |
| | | Email: emailInfo?.credential, |
| | | role: 'Student' |
| | | } |
| | | } |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); |
| | |
| | | }) |
| | | } |
| | | let info = getTopicMsgCmsItemFile(this.data.worksInfo, resData.cmsItemDataList) |
| | | console.log(info) |
| | | this.setData({ |
| | | 'teacherInfo.fullName': info.fullName, |
| | | 'teacherInfo.schoolName': info.schoolName, |
| | |
| | | md5: ele.file.md5, |
| | | linkType: 'LinkFile', |
| | | linkProtectType: 'Public', |
| | | url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + ele.md5 |
| | | url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + ele.md5, |
| | | imgUrl: ele.file.imgUrl |
| | | } |
| | | arr.push(imgObj); |
| | | this.setData({ |
| | |
| | | linkType: 'LinkFile', |
| | | linkProtectType: 'Public', |
| | | url: |
| | | app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates |
| | | app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates, |
| | | imgUrl: app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates, |
| | | } |
| | | arr.push(imgObj); |
| | | this.setData({ |
| | |
| | | this.setData({ teachVisible: true }); |
| | | }, |
| | | onPickerChange(e) { |
| | | const { value, label } = e.detail; |
| | | const { label } = e.detail; |
| | | this.setData({ |
| | | teachVisible: false, |
| | | teachText: label[0], |
| | | 'teacherInfo.positionalTitle': value.join[0], |
| | | 'teacherInfo.positionalTitle': label[0], |
| | | }); |
| | | }, |
| | | onPickerCancel(e) { |
| | |
| | | sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 |
| | | success: function (res) { |
| | | // 返回选定照片的本地文件路径列表,tempFilePath也可以作为img标签的src属性显示图片 |
| | | console.log(res.tempFiles[0]) |
| | | tool.getFileMd5(res.tempFiles[0]).then((e) => { |
| | | console.log(e, 4) |
| | | if (!that.data.imgPics.find((item) => item.md5 == e)) { |
| | | let formData = new FormData(); |
| | | formData.append('Md5', e); |
| | | formData.append('FileName', e); |
| | | formData.append('FileType', res.tempFiles[0].fileType); |
| | | formData.appendFile("file", res.tempFiles[0].tempFilePath); |
| | | const data = formData.getData(); |
| | | let _token = wx.getStorageSync(app.config.tokenKey); |
| | | let header = {}; |
| | | if (_token == null) { |
| | | header["Authorization"] = `Basic ${Base64.encode(website.clientId + ":" + website.clientSecret)}`; |
| | | } else { |
| | | header["Authorization"] = `Bearer ` + _token; |
| | | } |
| | | new Promise((resolve, reject) => { |
| | | wx.request({ |
| | | url: app.config.requestCtx + '/file/api/ApiUpload', |
| | | method: 'POST', |
| | | header: { |
| | | 'content-type': data.contentType, |
| | | ...header |
| | | }, |
| | | data: data.buffer, |
| | | success(res) { |
| | | if (res.statusCode == 200) { |
| | | resolve(res.data); if (res.data) { |
| | | let arr = []; |
| | | let imgObj = { |
| | | md5: e, |
| | | linkType: 'LinkFile', |
| | | linkProtectType: 'Public', |
| | | url: |
| | | app.config.requestCtx + `/file/GetPreViewImage?md5=` + e |
| | | } |
| | | arr = [...that.data.imgPics, ...[imgObj]]; |
| | | wx.getFileSystemManager().readFile({ |
| | | filePath: res.tempFiles[0].tempFilePath, //选择图片返回的相对路径 |
| | | // encoding: 'binary', //编码格式 |
| | | success: ress => { |
| | | //成功的回调 |
| | | let spark = new SparkMD5.ArrayBuffer(); |
| | | spark.append(ress.data); |
| | | let md5 = spark.end(false); |
| | | if (!that.data.imgPics.find((item) => item.md5 == md5)) { |
| | | let formData = new FormData(); |
| | | formData.append('Md5', md5); |
| | | formData.append('FileName', md5); |
| | | formData.append('FileType', res.tempFiles[0].fileType); |
| | | formData.appendFile("file", res.tempFiles[0].tempFilePath); |
| | | const data = formData.getData(); |
| | | let _token = wx.getStorageSync(app.config.tokenKey); |
| | | let header = {}; |
| | | if (_token == null) { |
| | | header["Authorization"] = `Basic ${Base64.encode(website.clientId + ":" + website.clientSecret)}`; |
| | | } else { |
| | | header["Authorization"] = `Bearer ` + _token; |
| | | } |
| | | new Promise((resolve, reject) => { |
| | | wx.request({ |
| | | url: app.config.requestCtx + '/file/api/ApiUpload', |
| | | method: 'POST', |
| | | header: { |
| | | 'content-type': data.contentType, |
| | | ...header |
| | | }, |
| | | data: data.buffer, |
| | | success(res1) { |
| | | if (res1.statusCode == 200) { |
| | | resolve(res1.data); if (res1.data) { |
| | | let arr = []; |
| | | let imgObj = { |
| | | md5: md5, |
| | | linkType: 'LinkFile', |
| | | linkProtectType: 'Public', |
| | | url: |
| | | app.config.requestCtx + `/file/GetPreViewImage?md5=` + md5, |
| | | imgUrl: res.tempFiles[0].tempFilePath |
| | | } |
| | | arr = [...that.data.imgPics, ...[imgObj]]; |
| | | |
| | | that.setData({ |
| | | imgPics: arr, |
| | | }); |
| | | that.setData({ |
| | | imgPics: arr, |
| | | }); |
| | | } |
| | | } else { |
| | | reject('运行时错误,请稍后再试'); |
| | | } |
| | | } else { |
| | | reject('运行时错误,请稍后再试'); |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: "当前文件已上传,请勿重复操作!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: "当前文件已上传,请勿重复操作!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | } |
| | | }); |
| | | }, |
| | |
| | | }) |
| | | }, |
| | | onChange() { |
| | | console.log(this.data.teacherInfo.agree, 12) |
| | | if (this.data.teacherInfo.agree) { |
| | | this.setData({ |
| | | 'teacherInfo.agree': false, |
| | |
| | | reasonTxtShow: e.detail.visible |
| | | }); |
| | | }, |
| | | onCloseProtocol() { |
| | | this.setData({ |
| | | protocolShow: false, |
| | | }); |
| | | }, |
| | | |
| | | //查看为通过原因 |
| | | previewReason() { |
| | | this.setData({ |
| | | reasonTxtShow: true, |
| | | }); |
| | | }, |
| | | |
| | | onCloseReasonTxt() { |
| | | this.setData({ |
| | | reasonTxtShow: false, |
| | | }); |
| | | }, |
| | | |
| | |
| | | }) |
| | | return |
| | | } |
| | | if (that.data.teacherInfo.relevantCertificates.length == 0) { |
| | | if (that.data.imgPics.length == 0) { |
| | | wx.showToast({ |
| | | title: "请上传工作证!", |
| | | icon: 'none', |
| | |
| | | }) |
| | | return |
| | | } |
| | | console.log(that.data.teacherInfo.fullName) |
| | | if (that.data.teacherInfo.agree) { |
| | | if (that.data.topicMessageList.length > 0) { |
| | | let dataRequests = tool.UpdateworksDataBytool( |
| | |
| | | that.data.teacherInfo, |
| | | that.data.imgPics |
| | | ); |
| | | console.log(dataRequests, 4) |
| | | const data = { |
| | | description: '', |
| | | icon: '', |
| | |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | that.newGetTeacherInfo() |
| | | that.getUserRole() |
| | | // that.newGetTeacherInfo() |
| | | } |
| | | }) |
| | | } |
| | |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | that.newGetTeacherInfo() |
| | | // that.newGetTeacherInfo() |
| | | that.getUserRole() |
| | | } |
| | | }) |
| | | }) |
| | |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | if (wx.getStorageSync(app.config.tokenKey)) { |
| | | this.getUserRole() |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |