|
@@ -1,15 +1,60 @@
|
|
|
<template>
|
|
|
- <div class="register-for-invite">
|
|
|
+ <v-container class="register-for-invite" fluid>
|
|
|
<div class="">注册</div>
|
|
|
- <form @submit.prevent>
|
|
|
- <input v-model="form.phone" label="phone" name="phone" />
|
|
|
- <input v-model="form.code" label="code" name="code" maxlength="6" />
|
|
|
- <div class="">
|
|
|
- <button @click="register()">注册</button>
|
|
|
- <button @click="sendSmsCode()">发送验证码</button>
|
|
|
- </div>
|
|
|
- </form>
|
|
|
- </div>
|
|
|
+ <validation-observer ref="observer" v-slot="{ invalid }" slim>
|
|
|
+ <v-form @submit.prevent="submit()">
|
|
|
+ <validation-provider
|
|
|
+ v-slot="{ errors }"
|
|
|
+ name="手机号码"
|
|
|
+ rules="required|min:11|max:11"
|
|
|
+ slim
|
|
|
+ >
|
|
|
+ <v-text-field
|
|
|
+ v-model="form.phone"
|
|
|
+ label="手机号码"
|
|
|
+ name="phone"
|
|
|
+ required
|
|
|
+ :error-messages="errors"
|
|
|
+ maxlength="11"
|
|
|
+ type="tel"
|
|
|
+ />
|
|
|
+ </validation-provider>
|
|
|
+ <validation-provider
|
|
|
+ v-slot="{ errors }"
|
|
|
+ name="验证码"
|
|
|
+ rules="required|min:6|max:6"
|
|
|
+ slim
|
|
|
+ >
|
|
|
+ <v-text-field
|
|
|
+ v-model="form.code"
|
|
|
+ label="验证码"
|
|
|
+ :error-messages="errors"
|
|
|
+ name="code"
|
|
|
+ maxlength="6"
|
|
|
+ required
|
|
|
+ >
|
|
|
+ <template #append-outer>
|
|
|
+ <v-btn
|
|
|
+ :loading="codeSending"
|
|
|
+ :disabled="codeTime > 0"
|
|
|
+ small
|
|
|
+ @click="sendSmsCode()"
|
|
|
+ >
|
|
|
+ <template v-if="codeTime > 0">{{ codeTime }}s</template>
|
|
|
+ <template v-else>发送验证码</template>
|
|
|
+ </v-btn>
|
|
|
+ </template>
|
|
|
+ </v-text-field>
|
|
|
+ </validation-provider>
|
|
|
+
|
|
|
+ <div class="">
|
|
|
+ <v-btn type="submit" :disabled="invalid" :loading="submitting"
|
|
|
+ >注册并下载app</v-btn
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </v-form>
|
|
|
+ </validation-observer>
|
|
|
+ </v-container>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -26,6 +71,9 @@ export default {
|
|
|
invitationUserName: null,
|
|
|
activityId: null,
|
|
|
},
|
|
|
+ codeSending: false,
|
|
|
+ codeTime: 0,
|
|
|
+ submitting: false,
|
|
|
};
|
|
|
},
|
|
|
fetch() {
|
|
@@ -35,19 +83,39 @@ export default {
|
|
|
head: {
|
|
|
title: '注册',
|
|
|
},
|
|
|
+ watch: {},
|
|
|
methods: {
|
|
|
- async register() {
|
|
|
- this.$tongji.trackEvent('活动', '注册', '', 0);
|
|
|
- await registerForInvite(this, this.form);
|
|
|
+ async submit() {
|
|
|
+ try {
|
|
|
+ this.submitting = true;
|
|
|
+ this.$tongji.trackEvent('活动', '注册', '', 0);
|
|
|
+ const validationResult = await this.$refs.observer.validate();
|
|
|
+ if (validationResult) {
|
|
|
+ await registerForInvite(this, this.form);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ this.submitting = false;
|
|
|
+ }
|
|
|
},
|
|
|
async sendSmsCode() {
|
|
|
- this.$tongji.trackEvent('活动', '发送短信', '', 0);
|
|
|
- const res = await sendSmsCode(this, {
|
|
|
- type: 'common',
|
|
|
- authorizationType: 4,
|
|
|
- phone: this.form.phone,
|
|
|
- });
|
|
|
- this.$message({ content: res.msg });
|
|
|
+ try {
|
|
|
+ this.codeSending = true;
|
|
|
+ this.$tongji.trackEvent('活动', '发送短信', '', 0);
|
|
|
+ const res = await sendSmsCode(this, {
|
|
|
+ type: 'common',
|
|
|
+ authorizationType: 4,
|
|
|
+ phone: this.form.phone,
|
|
|
+ });
|
|
|
+ this.codeTime = 60;
|
|
|
+ this.codeInterval = setInterval(() => {
|
|
|
+ if (--this.codeTime <= 0) {
|
|
|
+ clearInterval(this.codeInterval);
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ this.$toast.success(res.msg);
|
|
|
+ } finally {
|
|
|
+ this.codeSending = false;
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
};
|