import { defineComponent } from 'vue' import { CellGroup, Field, Button, Row, Col, Toast, Checkbox, Icon, Popup } from 'vant' import { checkPhone } from '@/helpers/validate' import request from '@/helpers/request' import { setLogin, state } from '@/state' import { removeAuth, setAuth } from '@/helpers/utils' import styles from './index.module.less' import logo from './images/logo.png' import iconTeacher from '@/common/images/icon_teacher.png' import activeButtonIcon from '@common/images/icon_checkbox.png' import inactiveButtonIcon from '@common/images/icon_checkbox_default.png' import ColPopup from '@/components/col-popup' import InviteCode from './invite-code' import TeacherChange from './teacher-change' export default defineComponent({ name: 'login', data() { const query = this.$route.query return { id: query.id, username: '', teacherInfo: {} as any, // 当前老师信息 imgCodeStatus: false, checked: false, teacherChangeStatus: false, changeInfo: {} as any // 更换老师信息 } }, computed: { codeDisable() { console.log(this.username ? true : false) return (this as any).username ? true : false } }, async mounted() { removeAuth() try { const res = await request.get('/api-student/open/getTeacher', { params: { userId: this.id } }) console.log(res) this.teacherInfo = res.data || {} } catch {} }, methods: { async onSendCode() { // 发送验证码 if (!checkPhone(this.username)) { return Toast('请输入正确的手机号码') } if (!this.checked) { return Toast('请阅读并同意协议') } this.imgCodeStatus = true }, previewProtocol(type: string) { if (type === 'user') { this.$router.push({ path: '/registerProtocol', query: { showHeader: 1 } }) } else if (type === 'privacy') { this.$router.push({ path: '/privacyProtocol', query: { showHeader: 1 } }) } }, async onLoginSuccess(isUpdate: boolean = false) { try { const res = await request.get('/api-student/open/bindTeacher', { params: { phone: this.username, userId: this.id, isUpdate } }) this.changeInfo = res.data || {} const { old, now } = res.data if (!isUpdate && now && old && now.userId !== old.userId) { this.teacherChangeStatus = true } else { this.$router.push('/inviteSuccess') } } catch {} } }, render() { return (

酷乐秀 你的器乐学习好帮手

{this.teacherInfo.realName}{' '} 老师邀请您注册酷乐秀一起体验器乐学习的乐趣吧!
手机号
未注册的手机号码将自动注册酷乐秀账号
( ) }} > 我已阅读并同意 { this.previewProtocol('user') }} > 《用户注册协议》 { this.previewProtocol('privacy') }} > 《隐私政策》
{this.imgCodeStatus && ( )} { this.teacherChangeStatus = false this.$router.push('/inviteSuccess') }} onChangeTeacher={(isUpdate: boolean) => { this.onLoginSuccess(isUpdate) }} />
) } })