// pages/teachAuthentication/teachAuthentication.js Page({ /** * 页面的初始数据 */ data: { phoneNum: '', //电话号码 weChatNum: '', //微信号码 englishName: '', //英文名称 nameFirst: '', //老师的姓 nameLast: '', //老师的名字 idNum: '', //身份证号 sex: '', //性别,根据输入的身份证号自动判断 idImgFontPath: '', //身份证正面照片的地址 idImgBackPath: '', //身份证背面照片的地址 diplomaPath:'', //毕业证书照片的地址 stuCardPath:'', //学生证照片的地址 headImgPath:'', //头像照片的地址 chosedTeachAttr: '', //老师的身份 showIdAttr: false, //老师的身份选项是否展示 shcool: '', //毕业后就读的学校 major: '', //所学专业 chosedEducation: '', //学历 showEdu: false, //学历的选项是否展示 province: '', //籍贯的省份 city: '', //籍贯的城市 county: '', //籍贯的区县 // 老师身份列表 attributeList: [{ 'attr': '专职老师', chosed: false }, { 'attr': '在校大学生', chosed: false } ], // 学历列表 educationList: [{ 'edu': '博士毕业', chosed: false }, { 'edu': '博士在读', chosed: false }, { 'edu': '硕士毕业', chosed: false }, { 'edu': '硕士在读', chosed: false }, { 'edu': '本科毕业', chosed: false }, { 'edu': '本科在读', chosed: false }, { 'edu': '专科毕业', chosed: false }, { 'edu': '专科在读', chosed: false } ] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, // 获取输入的电话号码 getPhoneNum(e) { this.setData({ phoneNum: e.detail.value }) }, //获取微信号 getWeChatNum(e) { this.setData({ weChatNum: e.detail.value }) }, // 获取英文名称 getEnglishName(e) { this.setData({ englishName: e.detail.value }) }, //获取用户输入的姓 getNameFirst(e) { this.setData({ nameFirst: e.detail.value }) }, //获取用户输入的名字 getNameLast(e) { this.setData({ nameLast: e.detail.value }) }, // 获取输入的身份证号 getIdInput(e) { // console.log(e.detail.value) this.setData({ idNum: e.detail.value }) let idNumber = this.data.idNum let idLength = this.data.idNum.length // console.log('idLength:' + idLength) // console.log(idNumber.charAt(16)) // 判断性别 if (idLength < 18) { this.setData({ sex: '' }) return } if (idNumber.charAt(16) % 2 == 0) { this.setData({ sex: '女' }) } else { this.setData({ sex: '男' }) } // console.log(this.data.sex) }, // 选择身份证的正面照片 chooseIdFront() { let that = this wx.chooseMedia({ count: 1, mediaType: ['image'], sourceType: ['album', 'camera'], sizeType:['compressed'], success(res) { // console.log(res.tempFiles[0].tempFilePath) console.log(res.tempFiles[0].size) that.setData({ idImgFontPath: res.tempFiles[0].tempFilePath }) } }) }, // 选择身份证的背面照片 chooseIdBack() { let that = this wx.chooseMedia({ count: 1, mediaType: ['image'], sourceType: ['album', 'camera'], // sizeType:['compressed'], success(res) { // console.log(res.tempFiles[0].tempFilePath) console.log(res.tempFiles[0].size) that.setData({ idImgBackPath: res.tempFiles[0].tempFilePath }) } }) }, // 选择毕业证 chooseDiploma(){ let that = this wx.chooseMedia({ count: 1, mediaType: ['image'], sourceType: ['album', 'camera'], // sizeType:['compressed'], success(res) { // console.log(res.tempFiles[0].tempFilePath) console.log(res.tempFiles[0].size) that.setData({ diplomaPath: res.tempFiles[0].tempFilePath }) } }) }, // 选择学生证 chooseStuCard(){ let that = this wx.chooseMedia({ count: 1, mediaType: ['image'], sourceType: ['album', 'camera'], // sizeType:['compressed'], success(res) { // console.log(res.tempFiles[0].tempFilePath) console.log(res.tempFiles[0].size) that.setData({ stuCardPath: res.tempFiles[0].tempFilePath }) } }) }, // 选择头像 chooseHeadImg(){ let that = this wx.chooseMedia({ count: 1, mediaType: ['image'], sourceType: ['album', 'camera'], // sizeType:['compressed'], success(res) { // console.log(res.tempFiles[0].tempFilePath) console.log(res.tempFiles[0].size) that.setData({ headImgPath: res.tempFiles[0].tempFilePath }) } }) }, // 选择老师身份属性 chooseTeachAttr() { this.setData({ showIdAttr: true }) }, //老师身份选择 onidAttrSelect(e) { // console.log(e) let index = e.currentTarget.dataset.index let attributeList = this.data.attributeList for (let i = 0; i < attributeList.length; i++) { if (i == index) { attributeList[i].chosed = !attributeList[i].chosed; } else { attributeList[i].chosed = false } } this.setData({ attributeList }) }, // 定义一个退出选项的方法 // 退出老师身份选项的方法 hiddenTeachId() { this.setData({ showIdAttr: false }) }, // 退出学历选项的方法 hiddenEdu() { this.setData({ showEdu: false }) }, // 老师身份选择确定 confirmTeachId() { let attributeList = this.data.attributeList // let index // for(let i = 0;i < attributeList.length;i++){ // if(attributeList.chosed){ // index = i // } // } // let chosedTeachAttr = attributeList[index].attr let chosedTeachAttr = attributeList[attributeList.findIndex(item => item.chosed)]?.attr || '' this.setData({ chosedTeachAttr }) this.hiddenTeachId() }, // 学历选择区 chooseEducation() { this.setData({ showEdu: true }) }, // 学历选择 onEduSelect(e) { // console.log(e) let index = e.currentTarget.dataset.index let educationList = this.data.educationList for (let i = 0; i < educationList.length; i++) { if (i == index) { educationList[i].chosed = !educationList[i].chosed; } else { educationList[i].chosed = false } } this.setData({ educationList }) }, // 学历选择确定 confirmEdu() { let educationList = this.data.educationList let chosedEducation = educationList[educationList.findIndex(item => item.chosed)]?.edu || '' this.setData({ chosedEducation }) this.hiddenEdu() }, // 获取输入的学校名称 getSchool(e) { this.setData({ school: e.detail.value }) }, // 获取输入的专业 getMajor(e) { this.setData({ major: e.detail.value }) }, // 获取输入的省份 getProvince(e) { this.setData({ province: e.detail.value }) }, // 获取输入的地市信息 getCity(e) { this.setData({ city: e.detail.value }) }, // 获取输入的区县信息 getCounty(e) { this.setData({ county: e.detail.value }) }, //提交审核 toSubmit() { // 判断手机号是否正确 let phone = this.data.phoneNum // 判断手机号是否为空 if (!phone) { wx.showToast({ title: '手机号不能为空', icon: 'none' }) return } // 判断手机号是否正确 let phoneReg = /^1(3|4|5|6|7|8|9)\d{9}$/; if (!phoneReg.test(phone)) { wx.showToast({ title: '手机号格式错误', icon: 'none' }) return; } // 判断微信号是否输入 let weChatNum = this.data.weChatNum if (!weChatNum) { wx.showToast({ title: '微信号不能为空', icon: 'none' }) return } // 判断用户的姓是否输入 let nameFirst = this.data.nameFirst if (!nameFirst) { wx.showToast({ title: '姓不能为空', icon: 'none' }) return } // 判断用户的名字是否输入 let nameLast = this.data.nameLast if (!nameLast) { wx.showToast({ title: '名字不能为空', icon: 'none' }) return } // 判断用户输入的身份证号码是否正确 let idNum = this.data.idNum // 判断身份证号是否为空 if (!idNum) { wx.showToast({ title: '身份证号码未填', icon: 'none' }) return } // 判断身份证号码是否正确 if (idNum.length != 18) { wx.showToast({ title: '身份证号码错误', icon: 'none' }) return } // 判断身份是否为空 let chosedTeachAttr = this.data.chosedTeachAttr if (!chosedTeachAttr) { wx.showToast({ title: '您还未选择身份', icon: 'none' }) return } // 判断学校是否为空 let school = this.data.school if (!school) { wx.showToast({ title: '学校不能为空', icon: 'none' }) return } // 判断专业是否为空 let major = this.data.major if (!major) { wx.showToast({ title: '专业不能为空', icon: 'none' }) return } // 判断学历 let chosedEducation = this.data.chosedEducation // 学历不能为空 if (!chosedEducation) { wx.showToast({ title: '您还未选择学历', icon: 'none' }) return } if (chosedTeachAttr == '专职老师') { if (chosedEducation == '博士在读' || chosedEducation == '硕士在读' || chosedEducation == '本科在读' || chosedEducation == '专科在读') { wx.showToast({ title: '学历与身份不符', icon: 'none' }) return } } if (chosedTeachAttr == '在校大学生') { if (chosedEducation == '博士毕业' || chosedEducation == '硕士毕业' || chosedEducation == '本科毕业' || chosedEducation == '专科毕业') { wx.showToast({ title: '学历与身份不符', icon: 'none' }) return } } // 判断籍贯是否为空 // 判断省份是否为空 let province = this.data.province if (!province) { wx.showToast({ title: '省份不能为空', icon: 'none' }) return } // 判断地市是否为空 let city = this.data.city if (!city) { wx.showToast({ title: '地市不能为空', icon: 'none' }) return } // 判断区县是否为空 let county = this.data.county if (!county) { wx.showToast({ title: '区县不能为空', icon: 'none' }) return } // 存入本地缓存 wx.setStorageSync('teach', { phoneNum: this.data.phoneNum, weChatNum: this.data.weChatNum, englishName: this.data.englishName, nameFirst: this.data.nameFirst, nameLast: this.data.nameLast, idNum: this.data.idNum, sex: this.data.sex, chosedTeachAttr: this.data.chosedTeachAttr, shcool: this.data.school, major: this.data.major, chosedEducation: this.data.chosedEducation, province: this.data.province, city: this.data.city, county: this.data.county, }) wx.showToast({ title: '提交成功', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })