123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <template>
- <v-container class="register-for-invite" fluid>
- <div class="title">注册</div>
- <validation-observer ref="observer" v-slot="{ invalid }" slim>
- <v-form @submit.prevent="submit()">
- <validation-provider
- v-slot="{ errors }"
- ref="providerPhome"
- 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>
- import { registerForInvite } from '~/api/user/client.js';
- import { sendSmsCode } from '~/api/message/phone.js';
- export default {
- auth: false,
- name: 'RegisterForInvite',
- data() {
- return {
- form: {
- phone: '17603013019',
- code: '',
- invitationUserName: null,
- activityId: null,
- },
- codeSending: false,
- codeTime: 0,
- submitting: false,
- };
- },
- fetch() {
- this.form.invitationUserName = this.$route.query.invitationUserName;
- this.form.activityId = this.$route.query.activityId;
- },
- head: {
- title: '注册',
- },
- watch: {},
- methods: {
- async submit() {
- try {
- this.submitting = true;
- const valid = await this.$refs.observer.validate();
- if (valid) {
- this.$tongji.trackEvent('活动', '注册', '', 0);
- const res = await registerForInvite(this, this.form);
- this.$toast.success(res.msg);
- }
- } finally {
- this.submitting = false;
- }
- },
- async sendSmsCode() {
- try {
- this.codeSending = true;
- const validationResult = await this.$refs.providerPhome.validate();
- if (validationResult.valid) {
- 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;
- }
- },
- },
- };
- </script>
|