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' import dayjs from 'dayjs' import { browser, getUrlCode } from '@/helpers/utils' import OUpload from '@/components/o-upload' import qs from 'query-string' 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, t: route.query.t as any, // 过期时间 qrCodeStatus: false, // 二维码是否失效 qrCodeMessage: '', 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: '', idcardFrontImg: '', idcardBackImg: '' // 身份证反面照 }, btnLoading: false, checkPhone: false, checked: true, columnSubject: [] as any, countDownStatus: true, // 是否发送验证码 countDownTime: 120, // 倒计时时间 // countDownRef: null as any, // 倒计时实例 imgCodeStatus: false, showPopup: false, code: '' }) const onSubmit = async () => { if (state.qrCodeStatus) { showDialog({ title: '提示', message: state.qrCodeMessage, theme: 'round-button', confirmButtonColor: '#ff8057' }) return } 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 window.location.href = 'https://mp.weixin.qq.com/s?__biz=MzkxMDMwOTI5Nw==&mid=2247485261&idx=1&sn=70c79a832a609bf9fae01c9e90fb4f69&chksm=c12c2593f65bac85d26362bca470f6abc2bfc087d9f4dcf87c00094420bdf5a3acb1b870199b#rd' } 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('信息获取失败,请联系老师') } // 判断是否是微信,只能微信中打开 // if (!browser().weixin) { // state.showPopup = true // return // } else { // //授权 // const code = getUrlCode() // if (!code) { // const newUrl = // window.location.origin + // window.location.pathname + // '#' + // route.path + // '?' + // qs.stringify({ // ...route.query // }) // getAppIdAndCode(newUrl) // return // } else { // state.code = code // } // } // t: route.query.t, // 过期时间 try { const res = await request.post('/api-school/open/schoolTeacherStudent/queryQrCodeStatus', { data: { schoolId: state.id, qrCodeEffectiveStartTime: state.t ? dayjs(Number(state.t)).format('YYYY-MM-DD HH:mm:ss') : null } }) if (res.code === 999) { showDialog({ title: '提示', message: res.message, theme: 'round-button', confirmButtonColor: '#FF8057' }) state.qrCodeStatus = true state.qrCodeMessage = res.message } } catch (e: any) { // console.log(e) } 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: { orchestraId: state.id, page: 1, rows: 50 } } ) const rows = data.rows || [] const tempSubjects: any = [] rows.forEach((item) => { tempSubjects.push({ text: item.name, value: item.subjectId }) }) state.columnSubject = tempSubjects } catch { showDialog({ message: '信息获取失败,请联系老师', theme: 'round-button', confirmButtonColor: '#FF8057' }) } }) const getAppIdAndCode = async (url?: string) => { try { const { data } = await request.get('/api-school/open/paramConfig/wechatAppId') // 判断是否有微信appId if (data) { closeToast() goAuth(data, url) } } catch { // } } const goAuth = (wxAppId: string, urlString?: string) => { // 用户授权 console.log(urlString || window.location.href, 'urlString || window.location.href') const urlNow = encodeURIComponent(urlString || window.location.href) console.log(urlNow, 'urlNow') const scope = 'snsapi_base' //snsapi_userinfo //静默授权 用户无感知 const appid = wxAppId || 'wx8654c671631cfade' const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&connect_redirect=1#wechat_redirect` window.location.replace(url) } const onPreview = (type: string) => { if (type === 'REGISTER') { window.open( window.location.origin + window.location.pathname + '#/preview-protocol', '_blank' ) } else if (type === 'PRIVACY') { window.open( window.location.origin + window.location.pathname + '#/privacyProtocol', '_blank' ) } else if (type === 'WITHDRAW') { // window.open(window.location.origin + window.location.pathname + '#/cashProtocol', '_blank') } } return () => (

{state.name}

提示:手机号码将成为您管乐团管理端登录账号
{{ input: () => ( ) }} {{ input: () => ( ) }}
{{ input: () => ( ) }} {{ button: () => state.countDownStatus ? ( ) : ( ) }}
{ state.checked = !state.checked }} > 请认真阅读并勾选 onPreview('REGISTER')}> 《管乐团用户注册协议》 onPreview('PRIVACY')}> 《隐私协议》 onPreview('WITHDRAW')}> 《共享经济平台注册经营者协议》

恭喜您已成功登记为

{state.name}
【管理老师】

请下载管乐团管理端APP

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

温馨提示

请使用微信打开

) } })