From 00993a660c1c79c37b59a811b9c940dbe604a7bb Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期五, 15 三月 2024 18:53:46 +0800 Subject: [PATCH] 教师认证 --- pages/teacherCertification/index.wxss | 59 +++++++ pages/teacherCertification/index.wxml | 33 ++- pages/teacherCertification/index.json | 10 .vscode/settings.json | 2 pages/teacherCertification/index.js | 322 ++++++++++++++++++++++++++++++++++++++++ project.config.json | 2 6 files changed, 409 insertions(+), 19 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 22d6d96..8096c21 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,7 +32,7 @@ }, "editor.tabSize": 2, "[wxml]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "wechat.miniprogram.wxml-language-features" }, "[css]": { "editor.defaultFormatter": "HookyQR.beautify" diff --git a/pages/teacherCertification/index.js b/pages/teacherCertification/index.js index 358d636..af25488 100644 --- a/pages/teacherCertification/index.js +++ b/pages/teacherCertification/index.js @@ -1,17 +1,51 @@ +const app = getApp(); +import tool from "../../assets/js/toolClass.js"; +import { getTopicMsgCmsItemFile } from '../../assets/js/middleGround/tool.js' Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - + teacherInfo: { + schoolName: '', //瀛︽牎鍚嶇О + fullName: '', //濮撳悕 + positionalTitle: '', //鑱岀О + courseName: '', //浠昏鏁欑▼ + phone: '', //鑱旂郴鐢佃瘽 + telphone: '', //搴ф満 + email: '', //鑱旂郴閭 + detailedAddress: '', //閫氳鍦板潃 + relevantCertificates: [], //鐩稿叧璇佷欢 + state: '', //瀹℃牳鐘舵�侀粯璁ゅ緟瀹℃牳 + agree: false + }, + teachPosts: [], + teachText: '', + teachVisible: false, + phoneError: false, + telphoneError: false, + emailError: false, + topicMessageList: [], + topicId: "", + worksInfo: [], + userId: '', + fileList: [], + protocolTxt: '', //鏁欏笀鍗忚 + editState: true, + reasonTxt: "" }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { - console.log(options); + console.log(options, 111); + this.getpositionalTitle(); + this.getAgreement(); + if (wx.getStorageSync(app.config.tokenKey)) { + this.getUserRole() + } }, /** @@ -41,6 +75,290 @@ onUnload() { }, + getUserRole() { + app.MG.identity.getCurrentAppUser().then((res) => { + if (res) { + + this.getType() + this.setData({ + userId: res.userId + }) + 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 defaultUser = {}; + if (teacherRole && teacherInfos) { + defaultUser = { + ...teacherInfos, + nickName: teacherInfos.fullName, + avatarUrl: teacherInfos.icon, + userId: res.userId, + phoneNumber: phoneInfo?.credential, + Email: emailInfo ? emailInfo.credential : JSON.parse(teacherInfos.data).email, + role: 'Teacher', + roleId: teacherRole.role.id + } + + } else if (wechatInfo) { + defaultUser = { + ...wechatInfo, + nickName: wechatInfo.name, + avatarUrl: wechatInfo.icon, + userId: res.userId, + phoneNumber: phoneInfo?.credential, + Email: emailInfo?.credential, + role: 'Student' + } + } else if (studentInfo) { + defaultUser = { + ...studentInfo, + nickName: wechatInfo.name, + avatarUrl: wechatInfo.icon, + userId: res.userId, + phoneNumber: phoneInfo?.credential, + Email: emailInfo?.credential, + role: 'Student' + } + } + wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo)); + } + }) + }, + getType() { + const data = { + refCodes: ['jsek_teacherCertification'] + } + app.MG.resource.getCmsTypeByRefCode(data).then((res) => { + this.setData({ + worksInfo: res[0].cmsTypeLinks[0].children, + }) + this.newGetTeacherInfo() + }) + }, + newGetTeacherInfo() { + const data = { + start: 0, + size: 10, + topicIdOrRefCode: 'teacherRoleApproval', + appRefCode: app.config.appRefCode, + sort: { + type: 'Desc', + field: 'CreateDate' + } + } + app.MG.ugc.getTopicMessageList(data).then((res) => { + try { + this.setData({ + fileList: [], + }) + const resData = res.datas.find((i) => i.appUserCreator.userId === this.data.userId) + if (resData) { + if (resData.state == 'WaitAudit') { + this.setData({ + editState: false, + }) + } else { + this.setData({ + editState: true, + }) + } + let info = getTopicMsgCmsItemFile(this.data.worksInfo, resData.cmsItemDataList) + this.setData({ + 'teacherInfo.fullName': info.fullName, + 'teacherInfo.schoolName ': info.schoolName, + 'teacherInfo.positionalTitle': info.positionalTitle, + 'teacherInfo.courseName': info.courseName, + 'teacherInfo.phone': info.phone, + 'teacherInfo.telphone': info.telphone ? info.telphone : '', + 'teacherInfo.email': info.email, + 'teacherInfo.detailedAddress': info.detailedAddress ? info.detailedAddress : '', + 'teacherInfo.relevantCertificates': info.relevantCertificates, + 'teacherInfo.agree': true, + 'teacherInfo.state': resData.state, + topicId: resData.id, + topicMessageList: resData.cmsItemDataList + }) + if (resData.feedBack != null) { + this.setData({ + reasonTxt: JSON.parse(resData.feedBack).reason, + }) + } + if (this.data.teacherInfo.relevantCertificates.length > 0) { + if (typeof this.data.teacherInfo.relevantCertificates == 'object') { + this.data.teacherInfo.relevantCertificates.forEach((ele) => { + let imgObj = { + md5: ele.file.md5, + linkType: 'LinkFile', + linkProtectType: 'Public', + url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + ele.file.md5 + } + this.data.fileList.push(imgObj) + }) + } else { + let imgObj = { + md5: this.data.teacherInfo.relevantCertificates, + linkType: 'LinkFile', + linkProtectType: 'Public', + url: + app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates + } + this.data.fileList.push(imgObj) + } + } + } + } catch (error) { + } + }) + }, + + getpositionalTitle() { + const data = { + refCodes: ['positionalTitle'] + } + app.MG.store.getProductTypeField(data).then((res) => { + try { + let list = res[0] + let options = JSON.parse(list.config).option + options.forEach((item) => { + item.label = item.name; + }) + this.setData({ + teachPosts: options, + }) + } catch (error) { + + } + }) + }, + getAgreement() { + let query = { + path: 'jsek_protocol', + fields: { + content: [] + } + } + app.MG.resource.getItem(query).then((res) => { + try { + const data = res.datas.find((e) => e.refCode == 'jsek_teacherCertificationAgreement') + this.setData({ + protocolTxt: data ? data.content : '鏆傛棤鍗忚', + }) + } catch (error) { + this.setData({ + protocolTxt: '鏆傛棤鍗忚', + }) + } + }) + }, + //閫夋嫨鑱岀О + onTeachPicker() { + this.setData({ teachVisible: true }); + }, + onPickerChange(e) { + const { value, label } = e.detail; + this.setData({ + teachVisible: false, + teachText: label[0], + 'teacherInfo.positionalTitle': value.join[0], + }); + }, + onPickerCancel(e) { + this.setData({ + 'teacherInfo.positionalTitle': '', + teachVisible: false, + }); + }, + //杈撳叆鎵嬫満鍙� + onPhoneInput(e) { + 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({ + phoneError: !isPhoneNumber, + }); + } + }, + //杈撳叆搴ф満 + onTelphoneInput(e) { + 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({ + telphoneError: !isPhoneNumber, + }); + } + }, + onEmailInput(e) { + 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({ + emailError: !isPhoneNumber, + }); + } + }, + handleAdd(e) { + const { fileList } = this.data; + console.log(e) + const { files } = e.detail; + // 鏂规硶2锛氭瘡娆¢�夋嫨鍥剧墖閮戒笂浼狅紝灞曠ず姣忔涓婁紶鍥剧墖鐨勮繘搴� + files.forEach(file => { + this.onUpload(file) + }) + }, + onUpload(file) { + console.log(file, '123') + const isLt2M = (0.5 * file.size) / 1024 / 1024 < 0.5 + if (!isLt2M) { + wx.showToast({ + title: "涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 500KB!", + icon: 'none', + duration: 1000, + }) + return reject() + } + const FileName = file.name.split('.')[0] + const Extension = file.name.split('.')[1] + const FileType = file.type + let size = 1024 + tool.getFileMd5(file, size * 1024).then((e) => { + if (!this.data.fileList.find((item) => item.md5 == e)) { + const imgData = new FormData() + imgData.append('Md5', e) + imgData.append('FileName', FileName) + imgData.append('Extension', Extension) + imgData.append('FileType', FileType) + imgData.append('MetaData', null) + imgData.append('file', file) + app.MG.file.upload(imgData).then(() => { + this.data.fileList.push({ + md5: e, + linkType: 'LinkFile', + linkProtectType: 'Public', + name: FileName, + type: FileType, + url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + e + }) + }) + } else { + ElMessage.error('褰撳墠鏂囦欢宸蹭笂浼狅紝璇峰嬁閲嶅鎿嶄綔锛�') + } + }) + .catch((e) => { + console.error(e) + }) + }, + handleRemove(e) { + const { index } = e.detail; + const { fileList } = this.data; + fileList.splice(index, 1); + this.setData({ + fileList, + }); + }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 diff --git a/pages/teacherCertification/index.json b/pages/teacherCertification/index.json index 8aecc2b..a0d3693 100644 --- a/pages/teacherCertification/index.json +++ b/pages/teacherCertification/index.json @@ -1,6 +1,10 @@ { "navigationBarTitleText": "鏁欏笀璁よ瘉", - "enablePullDownRefresh": true, - "backgroundTextStyle": "light", - "usingComponents": {} + "usingComponents": { + "t-cell": "tdesign-miniprogram/cell/cell", + "t-picker": "tdesign-miniprogram/picker/picker", + "t-picker-item": "tdesign-miniprogram/picker-item/picker-item", + "t-input": "tdesign-miniprogram/input/input", + "t-upload": "tdesign-miniprogram/upload/upload" + } } \ No newline at end of file diff --git a/pages/teacherCertification/index.wxml b/pages/teacherCertification/index.wxml index 5feb603..fe2cbb5 100644 --- a/pages/teacherCertification/index.wxml +++ b/pages/teacherCertification/index.wxml @@ -4,65 +4,74 @@ <form catchsubmit="formSubmit" catchreset="formReset" class="formBox"> <view class="from-item"> <view class="label"> 褰撳墠鐘舵�侊細 </view> - <view class="item-content"> - <input class="weui-input" name="input" placeholder="" /> + <view class="stateBox"> + <text class="wait" wx:if="{{teacherInfo.state == 'WaitAudit'}}">绛夊緟瀹℃牳</text> + <text class="yes" wx:if="{{teacherInfo.state == 'Normal'}}">宸茶璇�</text> + <text class="no" wx:if="{{teacherInfo.state == 'Reject'}}">宸查┏鍥�</text> + <text class="wait" wx:if="{{teacherInfo.state == ''}}">寰呰璇�</text> </view> </view> <view class="from-item"> <view class="label"> 瀛︽牎锛� </view> <view class="item-content"> - <input class="weui-input" name="input" placeholder="璇疯緭鍏ュ鏍�" /> + <t-input placeholder="璇疯緭鍏ュ鏍�" borderless value="{{teacherInfo.schoolName}}" /> </view> </view> <view class="from-item"> <view class="label"> 鐪熷疄濮撳悕锛� </view> <view class="item-content"> - <input class="weui-input" name="input" placeholder="璇疯緭鍏ョ湡瀹炲鍚�" /> + <t-input placeholder="璇疯緭鍏ョ湡瀹炲鍚�" borderless value="{{teacherInfo.fullName}}" /> </view> </view> <view class="from-item"> <view class="label"> 鑱岀О锛� </view> <view class="item-content"> - <!-- <input class="weui-input" name="input" placeholder="璇烽�夋嫨鑱岀О" /> --> + <t-cell arrow note="{{teachText}}" bind:click="onTeachPicker" /> + <t-picker visible="{{teachVisible}}" default-value="{{teacherInfo.positionalTitle}}" title="閫夋嫨鑱岀О" cancelBtn="鍙栨秷" confirmBtn="纭" bindchange="onPickerChange" bindcancel="onPickerCancel"> + <t-picker-item options="{{teachPosts}}" /> + </t-picker> </view> </view> <view class="from-item"> <view class="label"> 浠绘暀璇剧▼锛� </view> <view class="item-content"> - <input class="weui-input" name="input" placeholder="璇疯緭鍏ヤ换鏁欒绋�" /> + <t-input placeholder="璇疯緭鍏ヤ换鏁欒绋�" borderless value="{{teacherInfo.courseName}}" /> </view> </view> <view class="from-item"> <view class="label"> 鎵嬫満鍙凤細 </view> <view class="item-content"> - <input class="weui-input" name="input" placeholder="璇疯緭鍏ユ墜鏈哄彿" /> + <t-input placeholder="杈撳叆鎵嬫満鍙风爜" borderless value="{{teacherInfo.phone}}" type="number" tips="{{phoneError ? '鎵嬫満鍙疯緭鍏ヤ笉姝g‘' : ''}}" bindchange="onPhoneInput" /> </view> </view> <view class="from-item"> <view class="label"> 搴ф満锛� </view> <view class="item-content"> - <input class="weui-input" name="input" placeholder="璇疯緭鍏ュ骇鏈�" /> + <t-input placeholder="杈撳叆搴ф満鍙�" borderless value="{{teacherInfo.telphone}}" type="number" tips="{{telphoneError ? '搴ф満鍙疯緭鍏ヤ笉姝g‘' : ''}}" bindchange="onTelphoneInput" /> </view> </view> <view class="from-item"> <view class="label"> 閭锛� </view> <view class="item-content"> - <input class="weui-input" name="input" placeholder="璇疯緭鍏ラ偖绠�" /> + <t-input placeholder="杈撳叆閭" borderless value="{{teacherInfo.email}}" type="number" tips="{{emailError ? '閭杈撳叆涓嶆纭�' : ''}}" bindchange="onEmailInput" /> </view> </view> <view class="from-item"> <view class="label"> 璇︾粏鍦板潃锛� </view> <view class="item-content"> - <input class="weui-input" name="input" placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" /> + <t-input placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" borderless value="{{teacherInfo.detailedAddress}}" /> </view> </view> <view class="from-item"> <view class="label"> 鍦ㄨ亴鏁欏笀宸ヤ綔璇侊細 </view> - <view class="item-content"> </view> + <view class="wrapper"> + <t-upload mediaType="{{['image']}}" files="{{fileList}}" bind:add="handleAdd" bind:remove="handleRemove"> + </t-upload> + </view> </view> <view class="btn-area"> <button class="submit" formType="submit">鎻愪氦</button> </view> </form> </view> -</view> +</view> \ No newline at end of file diff --git a/pages/teacherCertification/index.wxss b/pages/teacherCertification/index.wxss index aa4e93c..7be42c9 100644 --- a/pages/teacherCertification/index.wxss +++ b/pages/teacherCertification/index.wxss @@ -30,7 +30,66 @@ padding: 10rpx; } +.from-item .stateBox { + padding: 10rpx; +} + +.from-item .t-input { + padding: 0 !important; +} + .submit { background: #ff6c00; color: #fff; +} + +.t-cell { + padding: 0 !important; +} + +.t-cell::after { + border-bottom: 0 !important; +} + +.t-cell__title { + flex: 0 !important; +} + +.t-cell__note { + justify-content: flex-start !important; + display: block !important; + /* width: 300rpx; */ +} + +.t-input__wrap .t-input__content, +.t-input__control { + font-size: 28rpx !important; +} + +.t-picker-item__wrapper { + padding: 80rpx 0 !important; +} + +.t-picker__indicator { + top: 80rpx !important; +} + +.wait { + color: #ff6d00; +} + +.no { + color: #EE1818 +} + +.yes { + color: #1FBC1F +} + +.wrapper { + width: 56%; +} + +.t-grid-item { + width: 50% !important; } \ No newline at end of file diff --git a/project.config.json b/project.config.json index d702033..7f717ad 100644 --- a/project.config.json +++ b/project.config.json @@ -48,7 +48,7 @@ }, "compileType": "miniprogram", "libVersion": "2.23.1", - "appid": "wx5461028c83fea0b3", + "appid": "wx7f362fe7cb6e0d1f", "projectname": "tdesign-miniprogram-starter-retail", "simulatorType": "wechat", "simulatorPluginLibVersion": {}, -- Gitblit v1.9.1