|
@@ -0,0 +1,231 @@
|
|
|
+import { defineComponent, reactive, ref } from 'vue'
|
|
|
+import styles from './index.module.less'
|
|
|
+import iconTop from './images/icon-top.png'
|
|
|
+import iconBird from './images/icon-bird.png'
|
|
|
+import iconTitle from './images/icon-title.png'
|
|
|
+import icon1 from './images/icon-1.png'
|
|
|
+import ImgCode from '@/components/col-img-code'
|
|
|
+import activeButtonIcon from '@common/images/icon_checkbox.png'
|
|
|
+import inactiveButtonIcon from '@common/images/icon_checkbox_default.png'
|
|
|
+import iconTips from './images/icon-tips.png'
|
|
|
+import {
|
|
|
+ Button,
|
|
|
+ CellGroup,
|
|
|
+ Checkbox,
|
|
|
+ CountDown,
|
|
|
+ Field,
|
|
|
+ Icon,
|
|
|
+ Toast
|
|
|
+} from 'vant'
|
|
|
+import { checkPhone } from '@/helpers/utils'
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
+import request from '@/helpers/request'
|
|
|
+
|
|
|
+// 用户注册
|
|
|
+export default defineComponent({
|
|
|
+ name: 'student-register',
|
|
|
+ setup() {
|
|
|
+ const router = useRouter()
|
|
|
+ const route = useRoute()
|
|
|
+ const forms = reactive({
|
|
|
+ username: null,
|
|
|
+ phone: null as any,
|
|
|
+ smsCode: null
|
|
|
+ })
|
|
|
+ const checked = ref(false) // 是否同意协议
|
|
|
+
|
|
|
+ const imgCodeStatus = ref(false) // 是否显示图片验证码
|
|
|
+
|
|
|
+ const countDownTime = ref(1000 * 60) // 倒计时时间,单位毫秒
|
|
|
+ const countDownStatus = ref(true)
|
|
|
+
|
|
|
+ const countDownRef = ref<any>(null)
|
|
|
+
|
|
|
+ const onSendCode = async () => {
|
|
|
+ // 发送验证码
|
|
|
+ if (!checkPhone(forms.phone)) {
|
|
|
+ return Toast('请输入正确的手机号码')
|
|
|
+ }
|
|
|
+ imgCodeStatus.value = true
|
|
|
+ }
|
|
|
+ const onCodeSend = () => {
|
|
|
+ countDownStatus.value = false
|
|
|
+ countDownRef.value?.start()
|
|
|
+ }
|
|
|
+ const onFinished = () => {
|
|
|
+ countDownStatus.value = true
|
|
|
+ countDownRef.value?.reset()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 跳转协议
|
|
|
+ const onPreviewProtocol = (type: string) => {
|
|
|
+ if (type === 'user') {
|
|
|
+ router.push({
|
|
|
+ path: '/registerProtocol',
|
|
|
+ query: {
|
|
|
+ showHeader: 1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (type === 'privacy') {
|
|
|
+ router.push({
|
|
|
+ path: '/privacyProtocol',
|
|
|
+ query: {
|
|
|
+ showHeader: 1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提交
|
|
|
+ const onSubmit = async () => {
|
|
|
+ try {
|
|
|
+ if (!forms.username) {
|
|
|
+ return Toast('请输入您的姓名')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!checkPhone(forms.phone)) {
|
|
|
+ return Toast('请输入正确的手机号码')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!forms.smsCode) {
|
|
|
+ return Toast('请输入验证码')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!checked.value) {
|
|
|
+ return Toast('请同意用户注册协议和隐私政策')
|
|
|
+ }
|
|
|
+ // 提交注册信息
|
|
|
+ await request.post('/api-auth/smsLogin', {
|
|
|
+ requestType: 'form',
|
|
|
+ data: {
|
|
|
+ clientId: 'student',
|
|
|
+ clientSecret: 'student',
|
|
|
+ phone: forms.phone,
|
|
|
+ smsCode: forms.smsCode,
|
|
|
+ username: forms.username,
|
|
|
+ inviteUserId: route.query.inviteUserId || null
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 登录成功后,跳转到注册页
|
|
|
+ router.push('/registerDownload')
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return () => (
|
|
|
+ <div class={styles.registerBox}>
|
|
|
+ <img class={styles.iconTop} src={iconTop} />
|
|
|
+ <img class={styles.iconBird} src={iconBird} />
|
|
|
+
|
|
|
+ <div class={styles.contentBox}>
|
|
|
+ <img class={styles.icon1} src={icon1} />
|
|
|
+ <div class={styles.title}>
|
|
|
+ <img src={iconTitle} />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <CellGroup border={false}>
|
|
|
+ <Field
|
|
|
+ border={false}
|
|
|
+ v-model={forms.username}
|
|
|
+ name="姓名"
|
|
|
+ placeholder="请输入您的姓名"
|
|
|
+ type="tel"
|
|
|
+ maxlength={11}
|
|
|
+ />
|
|
|
+ <Field
|
|
|
+ border={false}
|
|
|
+ v-model={forms.phone}
|
|
|
+ type="tel"
|
|
|
+ maxlength={11}
|
|
|
+ name="手机号码"
|
|
|
+ placeholder="请输入手机号码"
|
|
|
+ class={styles.phoneField}
|
|
|
+ />
|
|
|
+
|
|
|
+ <div class={styles.tips}>
|
|
|
+ <img src={iconTips} />
|
|
|
+ <span>该手机号码即为酷乐秀APP登录账号</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <Field
|
|
|
+ border={false}
|
|
|
+ v-model={forms.smsCode}
|
|
|
+ name="验证码"
|
|
|
+ placeholder="请输入验证码"
|
|
|
+ type="tel"
|
|
|
+ maxlength={6}
|
|
|
+ // @ts-ignore
|
|
|
+ vSlots={{
|
|
|
+ button: () =>
|
|
|
+ countDownStatus.value ? (
|
|
|
+ <span class={styles.codeText} onClick={onSendCode}>
|
|
|
+ 获取验证码
|
|
|
+ </span>
|
|
|
+ ) : (
|
|
|
+ <CountDown
|
|
|
+ ref={countDownRef.value}
|
|
|
+ auto-start={false}
|
|
|
+ time={countDownTime.value}
|
|
|
+ onFinish={onFinished}
|
|
|
+ format="sss后重试"
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </CellGroup>
|
|
|
+ <div class={styles.protocol}>
|
|
|
+ <Checkbox
|
|
|
+ v-model={checked.value}
|
|
|
+ v-slots={{
|
|
|
+ icon: (props: any) => (
|
|
|
+ <Icon
|
|
|
+ class={styles.boxStyle}
|
|
|
+ name={props.checked ? activeButtonIcon : inactiveButtonIcon}
|
|
|
+ size="15"
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 我已阅读并同意
|
|
|
+ </Checkbox>
|
|
|
+ <span
|
|
|
+ class={styles.protocolText}
|
|
|
+ onClick={() => {
|
|
|
+ onPreviewProtocol('user')
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 《用户注册协议》
|
|
|
+ </span>
|
|
|
+ 和
|
|
|
+ <span
|
|
|
+ class={styles.protocolText}
|
|
|
+ onClick={() => {
|
|
|
+ onPreviewProtocol('privacy')
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 《隐私政策》
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.btnBox}>
|
|
|
+ <Button round block type="primary" onClick={onSubmit}>
|
|
|
+ 立即登录
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {imgCodeStatus.value ? (
|
|
|
+ <ImgCode
|
|
|
+ v-model:value={imgCodeStatus.value}
|
|
|
+ phone={forms.phone}
|
|
|
+ registerType="REGISTER"
|
|
|
+ onClose={() => {
|
|
|
+ imgCodeStatus.value = false
|
|
|
+ }}
|
|
|
+ onSendCode={onCodeSend}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+})
|