register.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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="submit-btn-box">
  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. if (valid) {
  116. this.$tongji.trackEvent('活动', '注册', '', 0);
  117. const res = await registerForInvite(this, this.form);
  118. this.$toast.success(res.msg);
  119. this.openSzxApp();
  120. }
  121. } finally {
  122. this.submitting = false;
  123. }
  124. },
  125. openSzxApp() {
  126. this.$callSzx.open({ param: {}, path: '' });
  127. },
  128. async sendSmsCode() {
  129. try {
  130. this.codeSending = true;
  131. const validationResult = await this.$refs.providerPhome.validate();
  132. if (validationResult.valid) {
  133. this.$tongji.trackEvent('活动', '发送短信', '', 0);
  134. const res = await sendSmsCode(this, {
  135. type: 'common',
  136. authorizationType: 5,
  137. phone: this.form.phone,
  138. });
  139. this.codeTime = 60;
  140. this.codeInterval = setInterval(
  141. () => --this.codeTime <= 0 && clearInterval(this.codeInterval),
  142. 1000,
  143. );
  144. this.$toast.success(res.msg);
  145. }
  146. } finally {
  147. this.codeSending = false;
  148. }
  149. },
  150. },
  151. };
  152. </script>
  153. <style lang="scss" scoped>
  154. .register-for-invite {
  155. color: #333;
  156. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  157. background-size: 100% auto;
  158. // background-position-y: -44px;
  159. overflow: hidden;
  160. padding-bottom: 30px;
  161. min-height: 100vh;
  162. }
  163. .box {
  164. width: 373px;
  165. box-sizing: border-box;
  166. margin: auto;
  167. border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
  168. border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
  169. // border-image-width: 200px;
  170. // border-image-slice: 200%;
  171. border-width: 38px 15px 15px;
  172. // border-width: 1px;
  173. border-style: solid;
  174. position: relative;
  175. + .box {
  176. margin-top: 30px;
  177. }
  178. .box-header {
  179. position: absolute;
  180. top: -30px;
  181. // left: 141px;
  182. left: 0;
  183. right: 0;
  184. text-align: center;
  185. padding: 0 130px;
  186. color: #fff;
  187. }
  188. .box-main {
  189. padding: 30px 15px 20px;
  190. }
  191. }
  192. .box1 {
  193. margin-top: 275px;
  194. }
  195. .submit-btn-box {
  196. // 解决百度APP广告屏蔽导致按钮被隐藏
  197. display: flex !important;
  198. margin-top: 24px;
  199. // align-items: center;
  200. justify-content: center;
  201. }
  202. .submit-btn {
  203. display: block;
  204. // margin: auto;
  205. width: 302px !important;
  206. height: 62px !important;
  207. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  208. background-size: 100% 100%;
  209. color: #dd1b0d !important;
  210. font-size: 22px !important;
  211. font-weight: bold !important;
  212. }
  213. </style>