register.vue 5.8 KB

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