123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564 |
- // 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() {
- }
- })
|