register.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <v-container class="register-for-invite pa-0" fluid>
  3. <div class="box box1">
  4. <div class="box-header">快速注册</div>
  5. <div class="box-main">
  6. <validation-observer ref="observer" slim>
  7. <v-form @submit.prevent="submit()">
  8. <validation-provider
  9. v-slot="{ errors }"
  10. ref="providerPhome"
  11. name="手机号码"
  12. rules="required|min:11|max:11"
  13. slim
  14. >
  15. <v-text-field
  16. v-model="form.phone"
  17. v-mask="$mask.phone"
  18. label=""
  19. name="phone"
  20. required
  21. :error-messages="errors"
  22. maxlength="11"
  23. placeholder="请输入11位手机号"
  24. solo
  25. type="tel"
  26. flat
  27. />
  28. </validation-provider>
  29. <validation-provider
  30. v-slot="{ errors }"
  31. name="验证码"
  32. rules="required|min:6|max:6"
  33. slim
  34. >
  35. <v-text-field
  36. v-model="form.code"
  37. v-mask="'######'"
  38. label=""
  39. :error-messages="errors"
  40. name="code"
  41. maxlength="6"
  42. required
  43. placeholder="请输入验证码"
  44. solo
  45. flat
  46. >
  47. <template #append>
  48. <v-btn
  49. :loading="codeSending"
  50. :disabled="codeTime > 0"
  51. small
  52. depressed
  53. color="#8027E5"
  54. plain
  55. class="text-base"
  56. @click="sendSmsCode()"
  57. >
  58. <template v-if="codeTime > 0">{{ codeTime }}s</template>
  59. <template v-else>发送验证码</template>
  60. </v-btn>
  61. </template>
  62. </v-text-field>
  63. </validation-provider>
  64. <div class="">
  65. <v-btn
  66. type="submit"
  67. :loading="submitting"
  68. class="submit-btn"
  69. rounded
  70. ></v-btn>
  71. </div>
  72. </v-form>
  73. </validation-observer>
  74. </div>
  75. </div>
  76. </v-container>
  77. </template>
  78. <script>
  79. import { registerForInvite } from '~/api/user/client.js';
  80. import { sendSmsCode } from '~/api/message/phone.js';
  81. export default {
  82. auth: false,
  83. name: 'RegisterForInvite',
  84. data() {
  85. return {
  86. form: {
  87. phone: '',
  88. code: '',
  89. invitationUserName: null,
  90. activityId: null,
  91. },
  92. codeSending: false,
  93. codeTime: 0,
  94. submitting: false,
  95. };
  96. },
  97. fetch() {
  98. this.form.invitationUserName = this.$route.query.invitationUserName;
  99. this.form.activityId = this.$route.query.activityId;
  100. },
  101. head: {
  102. title: '注册',
  103. },
  104. watch: {},
  105. methods: {
  106. maskPhone(value) {
  107. return [/\d/, /\d/];
  108. },
  109. async submit() {
  110. try {
  111. this.submitting = true;
  112. const valid = await this.$refs.observer.validate();
  113. if (valid) {
  114. this.$tongji.trackEvent('活动', '注册', '', 0);
  115. const res = await registerForInvite(this, this.form);
  116. this.$toast.success(res.msg);
  117. this.toDownload();
  118. }
  119. } finally {
  120. this.submitting = false;
  121. }
  122. },
  123. toDownload() {
  124. window.open('https://www.androidscloud.com', '_self');
  125. },
  126. async sendSmsCode() {
  127. try {
  128. this.codeSending = true;
  129. const validationResult = await this.$refs.providerPhome.validate();
  130. if (validationResult.valid) {
  131. this.$tongji.trackEvent('活动', '发送短信', '', 0);
  132. const res = await sendSmsCode(this, {
  133. type: 'common',
  134. authorizationType: 4,
  135. phone: this.form.phone,
  136. });
  137. this.codeTime = 60;
  138. this.codeInterval = setInterval(
  139. () => --this.codeTime <= 0 && clearInterval(this.codeInterval),
  140. 1000,
  141. );
  142. this.$toast.success(res.msg);
  143. }
  144. } finally {
  145. this.codeSending = false;
  146. }
  147. },
  148. },
  149. };
  150. </script>
  151. <style lang="scss" scoped>
  152. .register-for-invite {
  153. color: #333;
  154. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  155. background-size: 100% auto;
  156. background-position-y: -44px;
  157. overflow: hidden;
  158. padding-bottom: 30px;
  159. min-height: 100vh;
  160. }
  161. .box {
  162. width: 373px;
  163. box-sizing: border-box;
  164. margin: auto;
  165. border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
  166. border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
  167. // border-image-width: 200px;
  168. // border-image-slice: 200%;
  169. border-width: 38px 15px 15px;
  170. // border-width: 1px;
  171. border-style: solid;
  172. position: relative;
  173. + .box {
  174. margin-top: 30px;
  175. }
  176. .box-header {
  177. position: absolute;
  178. top: -30px;
  179. // left: 141px;
  180. left: 0;
  181. right: 0;
  182. text-align: center;
  183. padding: 0 130px;
  184. color: #fff;
  185. }
  186. .box-main {
  187. padding: 30px 15px 20px;
  188. }
  189. }
  190. .box1 {
  191. margin-top: 275px;
  192. }
  193. .submit-btn {
  194. display: block;
  195. margin: auto;
  196. width: 302px !important;
  197. height: 62px !important;
  198. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  199. background-size: 100% 100%;
  200. margin-top: 24px;
  201. }
  202. </style>