import { areas } from '@/helpers/area' import request from '@/helpers/request' import { CellGroup, Form, Field, RadioGroup, Tag, Icon, Checkbox, Radio, Button, showToast, showDialog, showLoadingToast, closeToast, Picker, Popup, CountDown } from 'vant' import { defineComponent, onMounted, reactive } from 'vue' import { useRoute } from 'vue-router' import styles from './companion-teacher-register.module.less' import ImgCode from '@/components/o-img-code' import schoolLogo from './images/school-logo.png' import iconClose from './images/icon-close.png' import topBanner1 from './images/top-banner1.png' import { checkPhone } from '@/helpers/validate' import OUpload from '@/components/o-upload' import router from '@/router' export default defineComponent({ name: 'companion-teacher-register', setup() { const route = useRoute() const state = reactive({ showPicker: false, showSubject: false, submitStatus: false, showEducation: false, id: route.query.id, name: route.query.name, pattern: /^1(3|4|5|6|7|8|9)\d{9}$/, columns: [] as any, pickerType: null, // 下拉类型 selectSubjects: [] as any, // 选中的声部 forms: { realName: '', phone: null, gender: 1, idCardNo: null, cityCode: null, cityCodeName: '', provinceCode: null, showSubjectIds: '', subjectIds: [], smsValidCode: '', educationBackground: '', // 学历 graduateSchool: null, // 毕业学校 idcardFrontImg: '', idcardBackImg: '' // 身份证反面照 }, btnLoading: false, checkPhone: false, checked: true, columnSubject: [] as any, countDownStatus: true, // 是否发送验证码 countDownTime: 120, // 倒计时时间 countDownRef: null as any, // 倒计时实例 imgCodeStatus: false }) const onSubmit = async () => { if (!state.checked) { showToast('请阅读并同意协议') return } state.btnLoading = true try { const forms = state.forms await request.post('/api-school/open/schoolTeacherStudent/registerTeacher', { data: { ...forms, subjectIds: forms.subjectIds.join(','), schoolId: state.id } }) state.submitStatus = true } catch { // showToast('保存失败,请重试') } state.btnLoading = false } const onConfirm = (val: any) => { const selectedOptions = val.selectedOptions[1] state.forms.cityCode = selectedOptions.code state.forms.cityCodeName = selectedOptions.name const selectedFirst = val.selectedOptions[0] state.forms.provinceCode = selectedFirst.code state.showPicker = false } const onSubjectRemove = (item: any, index: any) => { showDialog({ title: '提示', message: '您是否删除选中的声部', confirmButtonColor: '#ff8057', showCancelButton: true }).then(() => { state.selectSubjects.splice(index, 1) const tempSubjectIds: any = [] state.selectSubjects.forEach((subject: any) => { tempSubjectIds.push(subject.value) }) state.forms.subjectIds = tempSubjectIds state.forms.showSubjectIds = tempSubjectIds.join(',') }) } // 选择声部 const onConfirmSubject = (val: any) => { const selected = val.selectedOptions[0] let isCheck = false state.selectSubjects.forEach((subject: any) => { if (subject.value === selected.value) { isCheck = true } }) // 判断是否有选择一样的数据 if (isCheck) { state.showSubject = false return } state.selectSubjects.push(val.selectedOptions[0]) const tempSubjectIds: any = [] state.selectSubjects.forEach((subject: any) => { tempSubjectIds.push(subject.value) }) state.forms.subjectIds = tempSubjectIds state.forms.showSubjectIds = tempSubjectIds.join(',') state.showSubject = false } // 选择学历 const onConfirmEduction = (val: any) => { const selectedOptions = val.selectedOptions[0] state.forms.educationBackground = selectedOptions.value state.showEducation = false } const onSendCode = () => { // 发送验证码 if (!checkPhone(state.forms.phone as any)) { return showToast('请输入正确的手机号码') } state.imgCodeStatus = true } const onCodeSend = () => { state.countDownStatus = false const clearTimer = setInterval(() => { state.countDownTime = state.countDownTime - 1 if (state.countDownTime <= 0) { state.countDownTime = 120 state.countDownStatus = true clearInterval(clearTimer) } }, 1000) } const onFinished = () => { state.countDownStatus = true // ;(this.$refs.countDownRef as any).reset() } onMounted(async () => { if (!state.id) { showToast('信息获取失败,请联系老师') } try { const tempareas: any = [] areas.forEach((item) => { const temp = { name: item.name, code: item.code, areas: [] as any } if (item.areas && item.areas.length > 0) { item.areas.forEach((child) => { temp.areas.push({ name: child.name, code: child.code }) }) } tempareas.push(temp) }) state.columns = tempareas || [] const { data } = await request.post( '/api-school/open/orchestraSubjectConfig/pageByOrchestraId', { data: { page: 1, rows: 50 } } ) const rows = data.rows || [] const tempSubjects: any = [] rows.forEach((item: any) => { tempSubjects.push({ text: item.name, value: item.subjectId }) }) state.columnSubject = tempSubjects } catch { showDialog({ message: '信息获取失败,请联系老师', theme: 'round-button', confirmButtonColor: '#64A9FF' }) } }) const onPreview = () => { window.open(window.location.origin + '/#/preview-protocol', '_blank') } return () => (
{state.name}
恭喜您已成功登记为
{state.name}
【伴学老师】
请下载管乐团老师端APP进行授课