register.vue 5.6 KB

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