register.vue 5.5 KB

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