import { c as h, R as r, C as i, I as c } from './validate.598a2b58.js' import { d as f, s, f as g, g as d, h as C, i as T, j as y, k as t, l as a, B as m } from './index.879f7421.js' import { C as S } from './index.4aec72fa.js' import { C as D } from './index.fe392820.js' import { F as u } from './index.00975bf6.js' import './index.c463dbd0.js' import './index.9a3a3b84.js' const w = '_login_y7mb5_1', _ = '_loginTitle_y7mb5_7', b = '_codeText_y7mb5_15', F = '_margin34_y7mb5_18', x = '_formTitle_y7mb5_21' var o = { login: w, loginTitle: _, codeText: b, margin34: F, formTitle: x }, N = f({ name: 'login', data() { return { loginType: 'SMS', username: '', password: '', smsCode: '', countDownStatus: !0, countDownTime: 1e3 * 120, imgCodeStatus: !1 } }, computed: { codeDisable() { let e = !0 return ( this.loginType === 'PWD' ? this.username && this.password && (e = !1) : this.username && this.smsCode && (e = !1), e ) }, appName() { return { STUDENT: '\u5B66\u751F\u7AEF', TEACHER: '\u8001\u5E08\u7AEF', SCHOOL: '\u7BA1\u7406\u7AEF' }[s.platformType] } }, mounted() { g(), this.directNext() }, methods: { directNext() { if (s.user.status === 'login' || s.user.status === 'error') { const { returnUrl: e, isRegister: l, ...n } = this.$route.query this.$router.replace({ path: e, query: { ...n } }) } }, async onLogin() { try { const e = { username: this.username, client_id: s.clientId[s.platformType], client_secret: s.clientId[s.platformType] } this.loginType === 'PWD' ? ((e.password = this.password), (e.loginType = 'PASSWORD'), (e.grant_type = 'PASSWORD')) : ((e.password = this.smsCode), (e.loginType = 'SMS'), (e.grant_type = 'SMS')) const { data: l } = await d.post('/api-oauth/userlogin', { requestType: 'form', data: { ...e } }) C(l.token_type + ' ' + l.access_token) const n = await d.get(s.platformApi + '/user/getUserInfo', { initRequest: !0 }) if (s.platformType === 'SCHOOL') { const p = n.data.schoolInfos ? n.data.schoolInfos[0] : {} n.data.school = p } T(n.data), this.directNext() } catch {} }, async onSendCode() { if (!h(this.username)) return y('\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u7801') this.imgCodeStatus = !0 }, onCodeSend() { ;(this.countDownStatus = !1), this.$nextTick(() => { this.$refs.countDownRef.start() }) }, onFinished() { ;(this.countDownStatus = !0), this.$refs.countDownRef.reset() }, onChange() { this.loginType === 'PWD' ? (this.loginType = 'SMS') : this.loginType === 'SMS' && (this.loginType = 'PWD') } }, render() { return t('div', { class: o.login }, [ t('div', { class: o.loginTitle }, [ a('\u60A8\u597D\uFF0C'), t('br', null, null), a(' \u6B22\u8FCE\u4F7F\u7528\u7BA1\u4E50\u56E2'), this.appName ]), t( S, { class: o.margin34, border: !1 }, { default: () => [ t( r, { style: { marginBottom: '16px' } }, { default: () => [ t( i, { span: 24, class: o.formTitle }, { default: () => [a('\u624B\u673A\u53F7')] } ), t( i, { span: 24, class: 'van-hairline--bottom' }, { default: () => [ t( u, { modelValue: this.username, 'onUpdate:modelValue': (e) => (this.username = e), name: '\u624B\u673A\u53F7', placeholder: '\u8BF7\u8F93\u5165\u60A8\u7684\u624B\u673A\u53F7', type: 'tel', maxlength: 11 }, null ) ] } ) ] } ), this.loginType === 'PWD' ? t(r, null, { default: () => [ t( i, { span: 24, class: o.formTitle }, { default: () => [a('\u5BC6\u7801')] } ), t( i, { span: 24, class: 'van-hairline--bottom' }, { default: () => [ t( u, { modelValue: this.password, 'onUpdate:modelValue': (e) => (this.password = e), type: 'password', name: '\u5BC6\u7801', placeholder: '\u8BF7\u8F93\u5165\u5BC6\u7801' }, null ) ] } ) ] }) : t(r, null, { default: () => [ t( i, { span: 24, class: o.formTitle }, { default: () => [a('\u9A8C\u8BC1\u7801')] } ), t( i, { span: 24, class: 'van-hairline--bottom' }, { default: () => [ t( u, { modelValue: this.smsCode, 'onUpdate:modelValue': (e) => (this.smsCode = e), name: '\u9A8C\u8BC1\u7801', placeholder: '\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801', type: 'tel', maxlength: 6 }, { button: () => this.countDownStatus ? t('span', { class: o.codeText, onClick: this.onSendCode }, [ a('\u83B7\u53D6\u9A8C\u8BC1\u7801') ]) : t( D, { ref: 'countDownRef', 'auto-start': !1, time: this.countDownTime, onFinish: this.onFinished, format: 'ss\u79D2' }, null ) } ) ] } ) ] }) ] } ), t('div', { class: o.margin34 }, [ t( m, { round: !0, block: !0, type: 'primary', disabled: this.codeDisable, onClick: this.onLogin }, { default: () => [a('\u63D0\u4EA4')] } ), t( m, { block: !0, round: !0, color: '#F5F7FB', onClick: this.onChange }, { default: () => [ this.loginType === 'PWD' ? '\u9A8C\u8BC1\u7801\u767B\u5F55' : '\u5BC6\u7801\u767B\u5F55' ] } ) ]), this.imgCodeStatus ? t( c, { value: this.imgCodeStatus, 'onUpdate:value': (e) => (this.imgCodeStatus = e), phone: this.username, onClose: () => { this.imgCodeStatus = !1 }, onSendCode: this.onCodeSend }, null ) : null ]) } }) export { N as default }