register.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <v-container class="register-for-invite pa-0" fluid :class="`type-${type}`">
  3. <activity-invite-user-box class="box1">
  4. <template #title>快速注册</template>
  5. <validation-observer ref="observer" slim>
  6. <v-form @submit.prevent="submit()">
  7. <validation-provider
  8. v-slot="{ errors }"
  9. ref="providerPhome"
  10. name="手机号码"
  11. rules="phone"
  12. slim
  13. >
  14. <v-text-field
  15. v-model="form.phone"
  16. v-mask="$mask.phone"
  17. label=""
  18. name="phone"
  19. required
  20. :error-messages="errors"
  21. placeholder="请输入11位手机号"
  22. solo
  23. type="tel"
  24. flat
  25. maxlength="11"
  26. />
  27. </validation-provider>
  28. <validation-provider
  29. v-slot="{ errors }"
  30. name="短信验证码"
  31. rules="code"
  32. slim
  33. >
  34. <v-text-field
  35. v-model="form.code"
  36. v-mask="'######'"
  37. label=""
  38. :error-messages="errors"
  39. name="code"
  40. maxlength="6"
  41. required
  42. placeholder="请输入验证码"
  43. solo
  44. flat
  45. type="tel"
  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="submit-btn-box">
  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. </activity-invite-user-box>
  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. computed: {
  105. type() {
  106. return Number(this.$route.query.type);
  107. },
  108. },
  109. watch: {},
  110. methods: {
  111. maskPhone(value) {
  112. return [/\d/, /\d/];
  113. },
  114. async submit() {
  115. try {
  116. this.submitting = true;
  117. const valid = await this.$refs.observer.validate();
  118. if (valid) {
  119. this.$tongji.trackEvent('活动', '注册', '', 0);
  120. const res = await registerForInvite(this, this.form);
  121. this.$toast.success(res.msg);
  122. this.openSzxApp();
  123. }
  124. } finally {
  125. this.submitting = false;
  126. }
  127. },
  128. openSzxApp() {
  129. this.$callSzx.open({ param: {}, path: '' });
  130. },
  131. async sendSmsCode() {
  132. try {
  133. this.codeSending = true;
  134. const validationResult = await this.$refs.providerPhome.validate();
  135. if (validationResult.valid) {
  136. this.$tongji.trackEvent('活动', '发送短信', '', 0);
  137. const res = await sendSmsCode(this, {
  138. type: 'common',
  139. authorizationType: 5,
  140. phone: this.form.phone,
  141. });
  142. this.codeTime = 60;
  143. this.codeInterval = setInterval(
  144. () => --this.codeTime <= 0 && clearInterval(this.codeInterval),
  145. 1000,
  146. );
  147. this.$toast.success(res.msg);
  148. }
  149. } finally {
  150. this.codeSending = false;
  151. }
  152. },
  153. },
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. .register-for-invite {
  158. color: #333;
  159. background-size: 100% auto;
  160. // background-position-y: -44px;
  161. overflow: hidden;
  162. padding-bottom: 30px;
  163. min-height: 100vh;
  164. &.type-1 {
  165. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  166. }
  167. &.type-2 {
  168. background-image: url('~/assets/image/activity/invite-user/bg-2@2x.png');
  169. }
  170. }
  171. // .box {
  172. // width: 373px;
  173. // box-sizing: border-box;
  174. // margin: auto;
  175. // // border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
  176. // border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
  177. // // border-image-width: 200px;
  178. // // border-image-slice: 200%;
  179. // border-width: 38px 15px 15px;
  180. // // border-width: 1px;
  181. // border-style: solid;
  182. // position: relative;
  183. // + .box {
  184. // margin-top: 30px;
  185. // }
  186. // .box-header {
  187. // position: absolute;
  188. // top: -30px;
  189. // // left: 141px;
  190. // left: 0;
  191. // right: 0;
  192. // text-align: center;
  193. // padding: 0 130px;
  194. // color: #fff;
  195. // }
  196. // .box-main {
  197. // padding: 30px 15px 20px;
  198. // }
  199. // }
  200. .box1 {
  201. margin-top: 275px;
  202. }
  203. .submit-btn-box {
  204. // 解决百度APP广告屏蔽导致按钮被隐藏
  205. display: flex !important;
  206. margin-top: 24px;
  207. // align-items: center;
  208. justify-content: center;
  209. }
  210. .submit-btn {
  211. display: block;
  212. // margin: auto;
  213. width: 302px !important;
  214. height: 62px !important;
  215. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  216. background-size: 100% 100%;
  217. color: #dd1b0d !important;
  218. font-size: 22px !important;
  219. font-weight: bold !important;
  220. }
  221. </style>