|
|
@@ -7,41 +7,53 @@
|
|
|
登录信息
|
|
|
<span>1/2</span>
|
|
|
</div>
|
|
|
- <c-input placeholder="邮箱" v-model="email"></c-input>
|
|
|
+ <c-input placeholder="邮箱" type="email" v-model="email"></c-input>
|
|
|
<div class="verified-code-wrapper">
|
|
|
- <c-input placeholder="邮箱验证码" v-model="emailCode"></c-input>
|
|
|
- <c-button class="secondary" @click="handleSendEmailCode">发送验证码</c-button>
|
|
|
+ <c-input placeholder="邮箱验证码" type="number" v-model="emailCode"></c-input>
|
|
|
+ <c-button class="secondary" :disabled="typeof this.emailButtonContent === typeof 0"
|
|
|
+ @click="handleSendEmailCode">{{ emailButtonContent }}
|
|
|
+ </c-button>
|
|
|
</div>
|
|
|
<section class="tip mb-24">
|
|
|
<div>关于邮箱的说明:</div>
|
|
|
- <div>1. 邮箱需为南京大学校邮</div>
|
|
|
+ <div>1. 邮箱需为南京大学校邮(@nju.edu.cn | @smail.nju.edu.cn)</div>
|
|
|
<div>2. 系统根据邮箱判定您的身份为教师还是学生</div>
|
|
|
</section>
|
|
|
- <c-input placeholder="密码" v-model="password"></c-input>
|
|
|
- <c-input placeholder="确认密码" v-model="passwordEnsure"></c-input>
|
|
|
- <c-button class="secondary full-width mb-16" @click="step = 2">下一步</c-button>
|
|
|
+ <c-input placeholder="密码" type="password" v-model="password"></c-input>
|
|
|
+ <c-input placeholder="确认密码" type="password" v-model="passwordEnsure"></c-input>
|
|
|
+ <section class="tip absolute password-warning" v-if="passwordWarning">
|
|
|
+ <div>{{passwordWarning}}</div>
|
|
|
+ </section>
|
|
|
+ <section class="tip absolute password-checked" v-if="password && passwordEnsure && !passwordWarning">
|
|
|
+ <div>{{iconMap['success']}} 密码验证通过</div>
|
|
|
+ </section>
|
|
|
+ <c-button class="secondary full-width mb-16 next-step" @click="step = 2">下一步</c-button>
|
|
|
</section>
|
|
|
- <section class="step=2" v-show="step === 2">
|
|
|
- <section class="tip">
|
|
|
- <div>已填写的邮箱:{{}}</div>
|
|
|
+ <section class="step=2" v-show="step === 2">
|
|
|
+ <section class="tip mb-8">
|
|
|
+ <div>已填写的邮箱:{{email}}</div>
|
|
|
</section>
|
|
|
<c-button @click="step = 1" class="warning full-width mb-16">上一步</c-button>
|
|
|
<div class="sub-title">
|
|
|
其他信息
|
|
|
<span>2/2</span>
|
|
|
</div>
|
|
|
- <c-input placeholder="姓名"></c-input>
|
|
|
- <section class="tip">
|
|
|
+ <c-input placeholder="姓名" v-model="name"></c-input>
|
|
|
+ <section class="tip mb-16">
|
|
|
<div>请使用真实姓名,便于学生、老师之间辨认</div>
|
|
|
</section>
|
|
|
- <c-input placeholder="手机"></c-input>
|
|
|
+ <c-input placeholder="手机" type="number" v-model="phone"></c-input>
|
|
|
<div class="verified-code-wrapper">
|
|
|
- <c-input placeholder="手机验证码"></c-input>
|
|
|
- <c-button class="secondary">发送验证码</c-button>
|
|
|
+ <c-input placeholder="手机验证码" type="number" v-model="phoneCode"></c-input>
|
|
|
+ <c-button class="secondary" @click="handleSendPhoneCode"
|
|
|
+ :disabled="typeof this.phoneButtonContent === typeof 0">{{phoneButtonContent}}
|
|
|
+ </c-button>
|
|
|
</div>
|
|
|
+ <section class="tip mb-16">
|
|
|
+ <div>重要提示:测试期间手机号验证暂未开通,请填写任意6位数字验证码即可通过验证</div>
|
|
|
+ </section>
|
|
|
<div class="button-area">
|
|
|
- <c-button @click="handleSubmit">确认</c-button>
|
|
|
- <c-button class="secondary">帮助</c-button>
|
|
|
+ <c-button class="full-width" :disabled="!formChecked()" @click="handleSubmit">确认</c-button>
|
|
|
</div>
|
|
|
</section>
|
|
|
<background></background>
|
|
|
@@ -53,30 +65,136 @@
|
|
|
import CInput from '@/components/CInput'
|
|
|
import CButton from '@/components/CButton'
|
|
|
import Background from '@/components/Background'
|
|
|
+import { sendEmailCode, sendPhoneCode } from '@/server/code'
|
|
|
+import { register } from '@/server/user'
|
|
|
+import iconMap from '@/utils/icon-map'
|
|
|
|
|
|
export default {
|
|
|
components: { CButton, CInput, Background },
|
|
|
data () {
|
|
|
return {
|
|
|
+ iconMap: iconMap,
|
|
|
step: 1,
|
|
|
email: '',
|
|
|
emailCode: '',
|
|
|
+ emailButtonContent: '发送验证码',
|
|
|
+ phoneButtonContent: '发送验证码',
|
|
|
password: '',
|
|
|
passwordEnsure: '',
|
|
|
+ passwordWarning: '',
|
|
|
name: '',
|
|
|
phone: '',
|
|
|
- phoneCode: ''
|
|
|
+ phoneCode: '',
|
|
|
+ message: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ password (newValue) {
|
|
|
+ this.passwordWarning = newValue && this.passwordEnsure && this.password !== this.passwordEnsure ? '两次输入的密码不一致' : ''
|
|
|
+ },
|
|
|
+ passwordEnsure (newValue) {
|
|
|
+ this.passwordWarning = newValue && this.password && this.password !== this.passwordEnsure ? '两次输入的密码不一致' : ''
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ formChecked () {
|
|
|
+ if (!(this.email && this.emailCode && this.password && this.passwordEnsure)) {
|
|
|
+ this.message = '上一页信息尚未完全填写'
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!(this.name && this.phone && this.phoneCode)) {
|
|
|
+ this.message = '本页信息尚未完全填写'
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.password !== this.passwordEnsure) {
|
|
|
+ this.message = '两次输入的密码不一致'
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.password !== this.passwordEnsure) {
|
|
|
+ this.message = '两次输入的密码不一致'
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
handleSubmit () {
|
|
|
- this.$router.push('/teacher')
|
|
|
+ if (!this.formChecked()) {
|
|
|
+ this.$showMessage({ message: this.message, type: 'error' })
|
|
|
+ } else {
|
|
|
+ register({
|
|
|
+ name: this.name,
|
|
|
+ email: this.email,
|
|
|
+ emailCode: this.emailCode,
|
|
|
+ phone: this.phone,
|
|
|
+ phoneCode: this.phoneCode,
|
|
|
+ password: this.password
|
|
|
+ }).then(() => {
|
|
|
+ this.$router.push({ name: 'login' })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleSendEmailCode () {
|
|
|
+ this.$showMessage({ message: '正在尝试发送验证码', type: 'info' })
|
|
|
+ if (this.email.match(/.+@(nju.edu.cn|smail.nju.edu.cn)/)) {
|
|
|
+ this.setEmailCodeCd()
|
|
|
+ sendEmailCode(this.email)
|
|
|
+ } else {
|
|
|
+ this.$showMessage({ message: '本邮箱不符合南京大学校邮格式', type: 'error' })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setEmailCodeCd () {
|
|
|
+ this._emailCodeCdInterval && clearInterval(this._emailCodeCdInterval)
|
|
|
+ this.emailButtonContent = 60
|
|
|
+ this._emailCodeCdInterval = setInterval(() => {
|
|
|
+ this.emailButtonContent--
|
|
|
+ if (typeof this.emailButtonContent !== typeof 0 || this.emailButtonContent <= 0) {
|
|
|
+ clearInterval(this._emailCodeCdInterval)
|
|
|
+ this.emailButtonContent = '发送验证码'
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
+ handleSendPhoneCode () {
|
|
|
+ this.$showMessage({ message: '正在尝试发送验证码', type: 'info' })
|
|
|
+ if (this.phone.match(/[0-9]{11}/)) {
|
|
|
+ this.setPhoneCodeCd()
|
|
|
+ sendPhoneCode(this.phone)
|
|
|
+ } else {
|
|
|
+ this.$showMessage({ message: '手机号码应为大陆11位手机号码', type: 'error' })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setPhoneCodeCd () {
|
|
|
+ this._phoneCodeCdInterval && clearInterval(this._phoneCodeCdInterval)
|
|
|
+ this.phoneButtonContent = 60
|
|
|
+ this._phoneCodeCdInterval = setInterval(() => {
|
|
|
+ this.phoneButtonContent--
|
|
|
+ if (typeof this.phoneButtonContent !== typeof 0 || this.phoneButtonContent <= 0) {
|
|
|
+ clearInterval(this._phoneCodeCdInterval)
|
|
|
+ this._phoneCodeCdInterval = '发送验证码'
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+@import "~@/style/theme.scss";
|
|
|
+
|
|
|
+.login-view-container {
|
|
|
+ min-height: 100vh;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+
|
|
|
+ & > div {
|
|
|
+ max-width: 360px;
|
|
|
+ padding: 60px 24px;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
.title {
|
|
|
span {
|
|
|
font-family: 'Courier New', 'Courier', monospace;
|
|
|
@@ -99,22 +217,8 @@ export default {
|
|
|
font-size: 12px;
|
|
|
}
|
|
|
|
|
|
-.login-view-container {
|
|
|
- height: 95vh;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
-
|
|
|
- & > div {
|
|
|
- max-width: 360px;
|
|
|
- padding: 0 24px;
|
|
|
- width: 100%;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
.c-input {
|
|
|
margin-bottom: 16px;
|
|
|
- background: #f2f6fa;
|
|
|
}
|
|
|
|
|
|
.button-area {
|
|
|
@@ -142,4 +246,22 @@ export default {
|
|
|
margin-left: 12px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.next-step {
|
|
|
+ margin-top: 56px;
|
|
|
+}
|
|
|
+
|
|
|
+.absolute {
|
|
|
+ position: absolute;
|
|
|
+}
|
|
|
+
|
|
|
+.password-warning {
|
|
|
+ color: $theme-orange;
|
|
|
+ font-family: 'iconfont', sans-serif;
|
|
|
+}
|
|
|
+
|
|
|
+.password-checked {
|
|
|
+ color: $theme-green;
|
|
|
+ font-family: 'iconfont', sans-serif;
|
|
|
+}
|
|
|
</style>
|