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 './manage-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-banner.png' import { checkPhone } from '@/helpers/validate' export default defineComponent({ name: 'companion-teacher-register', setup() { const route = useRoute() const state = reactive({ showPicker: false, showSubject: false, submitStatus: 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, // 下拉类型 forms: { realName: '', phone: null, gender: 1, idCardNo: null, smsValidCode: '' }, 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/schoolStaff/registerTeacher', { data: { ...forms, schoolId: state.id } }) state.submitStatus = true } catch { // } state.btnLoading = 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/subject/page', { data: { page: 1, rows: 50 } }) const rows = data.rows || [] const tempSubjects: any = [] rows.forEach((item) => { tempSubjects.push({ text: item.name, value: item.id }) }) state.columnSubject = tempSubjects } catch { showDialog({ message: '信息获取失败,请联系老师', theme: 'round-button', confirmButtonColor: '#64A9FF' }) } }) return () => (

{state.name}

{{ button: () => state.countDownStatus ? ( ) : ( ) }}
提示:手机号码将成为您管乐团管理端登录账号
{{ input: () => ( ) }}
{ state.checked = !state.checked }} > 请认真阅读并勾选 《乐团伴学老师注册协议》
(state.submitStatus = false)} />

恭喜您已成功登记为

{state.name} 【管理老师】

请下载管乐团管理端APP进行授课

{state.imgCodeStatus ? ( { state.imgCodeStatus = false }} onSendCode={onCodeSend} /> ) : null}
) } })