From aff8d054df4a638f399dc8f15d98c19b9c9aa785 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 29 四月 2025 10:11:25 +0800 Subject: [PATCH] 扫码视频播放 --- packageDomain/pages/teacherCertification/index.js | 285 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 202 insertions(+), 83 deletions(-) diff --git a/packageDomain/pages/teacherCertification/index.js b/packageDomain/pages/teacherCertification/index.js index 0979b20..df343fc 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({ /** @@ -40,18 +45,19 @@ editState: true, reasonTxt: "", reasonTxtShow: false, + skeletonLoding: true, + isIos: wx.getSystemInfoSync().platform === 'ios', + keyboardHeight: 0 }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad() { + //鑾峰彇鑱岀О this.getpositionalTitle(); this.getAgreement(); - if (wx.getStorageSync(app.config.tokenKey)) { - this.getUserRole() - } }, /** @@ -65,6 +71,21 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { + // 妫�鏌ョ櫥褰曠姸鎬� + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) { + this.getUserRole() + } else { + wx.switchTab({ + url: '/pages/home/home', + }) + } + }) + } else { + this.getUserRole() + } }, @@ -86,41 +107,29 @@ if (res) { this.getType() this.setData({ - userId: res.userId + userId: res.userId, + skeletonLoding: true, }) 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 ? WeChatInfo.name : '', + icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : WeChatInfo ? 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 +137,22 @@ } }) }, + //鑾峰彇瀛楁 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,23 +165,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) - console.log(info) - this.setData({ + let info = getTopicMsgCmsItemFile(that.data.worksInfo, resData.cmsItemDataList) + that.setData({ 'teacherInfo.fullName': info.fullName, 'teacherInfo.schoolName': info.schoolName, 'teacherInfo.positionalTitle': info.positionalTitle, @@ -183,16 +195,17 @@ topicId: resData.id, topicMessageList: resData.cmsItemDataList, teachText: info.positionalTitle, + skeletonLoding: false, }) 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', @@ -201,32 +214,34 @@ 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, }); } } + } else { + that.setData({ + skeletonLoding: false, + }); } - } catch (error) { - } + } catch (error) {} }) }, - + //鑾峰彇鑱岀О getpositionalTitle() { const data = { refCodes: ['positionalTitle'] @@ -294,10 +309,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], @@ -312,46 +331,77 @@ }, //杈撳叆鎵嬫満鍙� 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) { + const { + phoneError + } = this.data; + if (e.detail.value) { + 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, + "teacherInfo.phone": e.detail.value, + }); + } + } else { this.setData({ - phoneError: !isPhoneNumber, - "teacherInfo.phone": e.detail.value, + phoneError: false, }); } }, //杈撳叆搴ф満 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) { + const { + telphoneError + } = this.data; + if (e.detail.value) { + const isPhoneNumber = /^0\d{2}-\d{8}$|^0\d{3}-\d{7}$/.test(e.detail.value); + if (telphoneError === isPhoneNumber) { + this.setData({ + telphoneError: !isPhoneNumber, + "teacherInfo.telphone": e.detail.value, + }); + } + } else { this.setData({ - telphoneError: !isPhoneNumber, - "teacherInfo.telphone": e.detail.value, + telphoneError: false, }); } }, 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) { + const { + emailError + } = this.data; + if (e.detail.value) { + 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, + "teacherInfo.email": e.detail.value, + }); + } + } else { this.setData({ - emailError: !isPhoneNumber, - "teacherInfo.email": e.detail.value, + emailError: false, }); } }, // 涓婁紶鍥剧墖浜嬩欢 chooseImg(e) { var that = this; + if (that.data.imgPics.length == 4) { + wx.showToast({ + title: "宸ヤ綔璇佹枃浠朵笉瓒呰繃5涓紒", + icon: 'none', + duration: 1000, + }) + return + } wx.chooseMedia({ - // count: 1, // 榛樿9 + count: 1, sizeType: ['original', 'compressed'], // 鍙互鎸囧畾鏄師鍥捐繕鏄帇缂╁浘锛岄粯璁や簩鑰呴兘鏈� sourceType: ['album', 'camera'], // 鍙互鎸囧畾鏉ユ簮鏄浉鍐岃繕鏄浉鏈猴紝榛樿浜岃�呴兘鏈� success: function (res) { // 杩斿洖閫夊畾鐓х墖鐨勬湰鍦版枃浠惰矾寰勫垪琛紝tempFilePath涔熷彲浠ヤ綔涓篿mg鏍囩鐨剆rc灞炴�ф樉绀哄浘鐗� - console.log(res.tempFiles[0], 12); wx.getFileSystemManager().readFile({ filePath: res.tempFiles[0].tempFilePath, //閫夋嫨鍥剧墖杩斿洖鐨勭浉瀵硅矾寰� // encoding: 'binary', //缂栫爜鏍煎紡 @@ -385,14 +435,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]]; @@ -446,7 +496,6 @@ }) }, onChange() { - console.log(this.data.teacherInfo.agree, 12) if (this.data.teacherInfo.agree) { this.setData({ 'teacherInfo.agree': false, @@ -531,6 +580,14 @@ }) return } + if (!that.data.teacherInfo.detailedAddress) { + wx.showToast({ + title: "璇峰~鍐欒缁嗗湴鍧�锛�", + icon: 'none', + duration: 1000, + }) + return + } if (that.data.imgPics.length == 0) { wx.showToast({ title: "璇蜂笂浼犲伐浣滆瘉锛�", @@ -547,7 +604,6 @@ that.data.teacherInfo, that.data.imgPics ); - console.log(dataRequests, 4) const data = { description: '', icon: '', @@ -567,13 +623,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) { @@ -605,13 +659,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,12 +697,79 @@ this.getUserRole() } }, + // 鐩戝惉椤甸潰杞敭鐩樺脊璧锋墜鍔ㄦ帹鍔ㄩ〉闈� + bindkeyboardheightchange(e) { + // 鍙ios 澶勭悊 + if (!this.data.isIos === 'ios') { + return + } + // 閿洏楂樺害 + const height = e.detail.height; + const className = e.target.dataset.class; + if (height === 0) { + this.scrollToInput(0); + return; + } + try { + this.createSelectorQuery() + .select(`.${className}`) + .boundingClientRect((res) => { + // 鍙娇鐢ㄧ獥鍙i珮搴� + const windowHeight = wx.getSystemInfoSync().windowHeight; + // 闄ゅ幓閿洏鐨勫墿浣欓珮搴� + let restHeight = windowHeight - height; + // 鍏冪礌宸︿笅瑙掑潗鏍� + let bottom = res.bottom; + // 鍙湁褰撳厓绱犺杞敭鐩樿鐩栫殑鏃跺�欐墠涓婃帹椤甸潰 + if (bottom <= restHeight) return; + // 鐜伴樁娈甸渶瑕佹粴鍔ㄧ殑澶у皬 + let scrollTop = bottom - restHeight; + this.scrollToInput(height, scrollTop); + }) + .exec(); + } catch (error) {} + }, + // 鑾峰彇椤甸潰婊氬姩鏉′綅缃� + getScrollOffset() { + return new Promise((resolve) => { + try { + wx.createSelectorQuery() + .selectViewport() + .scrollOffset((res) => { + resolve(res.scrollTop); + }) + .exec(); + } catch (error) { + resolve(0); + } + }); + }, + + // 鐩戝惉椤甸潰杞敭鐩樺脊璧锋墜鍔ㄦ帹鍔ㄩ〉闈� + scrollToInput(keyboardHeight, scrollTop) { + this.setData({ + keyboardHeight, + }); + if (scrollTop) { + try { + this.getScrollOffset().then((lastScrollTop) => { + wx.pageScrollTo({ + // 濡傛灉宸茬粡瀛樺湪婊氬姩锛屽湪姝ゅ熀纭�涓婄户缁粴 + scrollTop: lastScrollTop ? lastScrollTop + scrollTop : scrollTop, + duration: 300, + }); + }); + } catch (error) {} + } + }, + changeParam(e) { + this.scrollToInput(0); + }, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ - onReachBottom() { - }, + onReachBottom() {}, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� -- Gitblit v1.9.1