register.vue 5.3 KB

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