register-fission.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <v-container class="register-for-invite pa-0" fluid :class="`type-${type}`">
  3. <div class="box1">
  4. <validation-observer ref="observer" class="mlr10" slim>
  5. <v-form @submit.prevent="submit()">
  6. <validation-provider v-slot="{ errors }" ref="providerPhome" name="手机号码" rules="phone" slim>
  7. <div style="display: flex;">
  8. <div class="label-item">
  9. 手机号
  10. </div>
  11. <v-text-field v-model="form.phone" v-mask="$mask.phone" background-color="#F6F6F6" name="phone" required :error-messages="errors" placeholder="请输入11位手机号" solo type="tel" flat maxlength="11" @blur="makePoint(form.channelCode + '_Promotion _activities_输入手机号')" />
  12. </div>
  13. </validation-provider>
  14. <validation-provider v-slot="{ errors }" name="短信验证码" rules="code" slim>
  15. <div style="display: flex;">
  16. <div class="label-item">
  17. 验证码
  18. </div>
  19. <v-text-field ref="code" v-model="form.code" v-mask="'######'" class="w220" background-color="#F6F6F6" label="" :error-messages="errors" name="code" maxlength="6" required placeholder="请输入验证码" solo flat type="tel" @blur="makePoint(form.channelCode + '_Promotion _activities_输入验证码')">
  20. <template #append>
  21. <v-btn :loading="codeSending" :disabled="codeTime > 0" small depressed color="#1E3ADE" plain class="text-base" @click="sendSmsCode()">
  22. <template v-if="codeTime > 0">{{ codeTime }}s后重新获取</template>
  23. <template v-else>获取验证码</template>
  24. </v-btn>
  25. </template>
  26. </v-text-field>
  27. </div>
  28. </validation-provider>
  29. <div class="submit-btn-box">
  30. <v-btn type="submit" :loading="submitting" class="submit-btn" rounded>注册并下载APP</v-btn>
  31. </div>
  32. </v-form>
  33. </validation-observer>
  34. </div>
  35. </v-container>
  36. </template>
  37. <script>
  38. import { Toast } from 'vant';
  39. import { registerForInvite } from '~/api/user/client.js';
  40. import { sendSmsCode } from '~/api/message/phone.js';
  41. export default {
  42. auth: false,
  43. name: 'RegisterForInvite',
  44. data() {
  45. return {
  46. form: {
  47. phone: '',
  48. code: '',
  49. invitationUserName: null,
  50. activityId: null,
  51. invitationType: 5
  52. },
  53. codeSending: false,
  54. codeTime: 0,
  55. submitting: false,
  56. client: 1
  57. };
  58. },
  59. fetch() {
  60. this.form.invitationUserName = this.$route.query.invitationUserName;
  61. this.form.activityId = this.$route.query.activityId;
  62. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  63. this.client = 1;
  64. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  65. this.client = 2;
  66. } else if (this.$userAgent.isMiniProgram) {
  67. this.client = 5;
  68. } else {
  69. this.client = 7;
  70. }
  71. },
  72. head: {
  73. title: '注册',
  74. },
  75. computed: {
  76. type() {
  77. return 2;
  78. },
  79. },
  80. mounted() {
  81. this.makePoint('activity_download_PV')
  82. this.makePoint('activity_download_UV')
  83. },
  84. methods: {
  85. maskPhone(value) {
  86. return [/\d/, /\d/];
  87. },
  88. makePoint(positionButton) {
  89. this.$axios.$post('/public/v5/buriedPointRecord/reportRecords', [
  90. {
  91. client: this.client,
  92. eventCode: '28_分享活动',
  93. userName: '',
  94. positionButton,
  95. operationTime: this.getCurrentTime(),
  96. phoneNumber: '',
  97. deviceId: ''
  98. },
  99. ]);
  100. },
  101. getCurrentTime() {
  102. const date = new Date(); // 当前时间
  103. const year = date.getFullYear() // 年
  104. const month = this.repair(date.getMonth() + 1); // 月
  105. const day = this.repair(date.getDate()); // 日
  106. const hour = this.repair(date.getHours()); // 时
  107. const minute = this.repair(date.getMinutes()); // 分
  108. const second = this.repair(date.getSeconds()); // 秒
  109. // 当前时间
  110. const curTime = year + "-" + month + "-" + day +
  111. " " + hour + ":" + minute + ":" + second;
  112. return curTime;
  113. },
  114. repair(i) {
  115. if (i >= 0 && i <= 9) {
  116. return "0" + i;
  117. } else {
  118. return i;
  119. }
  120. },
  121. async submit() {
  122. try {
  123. this.makePoint('activity_Share_注册并下载app按钮')
  124. this.submitting = true;
  125. const valid = await this.$refs.observer.validate();
  126. if (valid) {
  127. this.$tongji.trackEvent('活动', '注册', '', 0);
  128. await registerForInvite(this, this.form);
  129. Toast({
  130. message: '注册成功',
  131. position: 'top',
  132. duration: 3000
  133. });
  134. this.openSzxApp();
  135. }
  136. } catch (error) {
  137. Toast({
  138. message: error.message,
  139. position: 'top',
  140. duration: 3000
  141. });
  142. if(error.response.data.status === 1114) {
  143. this.openSzxApp();
  144. }
  145. } finally {
  146. this.submitting = false;
  147. }
  148. },
  149. openSzxApp() {
  150. this.$callSzx.open({ param: {}, path: '' });
  151. },
  152. async sendSmsCode() {
  153. try {
  154. this.codeSending = true;
  155. const validationResult = await this.$refs.providerPhome.validate();
  156. if (validationResult.valid) {
  157. this.$tongji.trackEvent('活动', '发送短信', '', 0);
  158. this.makePoint('activity_Share_获得验证码')
  159. const res = await sendSmsCode(this, {
  160. type: 'common',
  161. authorizationType: 5,
  162. phone: this.form.phone,
  163. });
  164. this.codeTime = 60;
  165. this.codeInterval = setInterval(
  166. () => --this.codeTime <= 0 && clearInterval(this.codeInterval),
  167. 1000,
  168. );
  169. Toast({
  170. message: res.msg,
  171. position: 'top',
  172. duration: 3000
  173. });
  174. }
  175. } catch (error) {
  176. Toast({
  177. message: error.message,
  178. duration: 3000
  179. });
  180. } finally {
  181. this.codeSending = false;
  182. }
  183. },
  184. },
  185. };
  186. </script>
  187. <style lang="scss" scoped>
  188. .mlr10 {
  189. margin: 4px;
  190. border: 1px solid #FDAF7D;
  191. border-radius: 18px 18px 18px 18px;
  192. overflow: hidden;
  193. width: 344px;
  194. height: 227px;
  195. box-sizing: border-box;
  196. padding: 25px 19px 23px 18px;
  197. }
  198. .register-for-invite {
  199. color: #333;
  200. background-size: 100% auto;
  201. // background-position-y: -44px;
  202. overflow: hidden;
  203. padding-bottom: 30px;
  204. min-height: 880px;
  205. &.type-1 {
  206. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  207. }
  208. &.type-2 {
  209. background-image: url('~/assets/image/activity/invite-user/bj@2x.png');
  210. }
  211. &.type-3 {
  212. background-image: url('~/assets/image/activity/invite-user/bg-3@2x.png');
  213. }
  214. }
  215. .box1 {
  216. margin: 265px auto 0;
  217. width: 350px;
  218. height: 234px;
  219. background: #FFFFFF;
  220. border-radius: 18px 18px 18px 18px;
  221. overflow: hidden;
  222. }
  223. .submit-btn-box {
  224. // 解决百度APP广告屏蔽导致按钮被隐藏
  225. display: flex !important;
  226. justify-content: center;
  227. }
  228. .submit-btn {
  229. display: block;
  230. width: 308px !important;
  231. height: 40px !important;
  232. background: linear-gradient(0deg, #F34927 0%, #FDAF7D 100%);
  233. border-radius: 20px;
  234. text-align: center;
  235. font-size: 18px;
  236. font-weight: 500;
  237. color: #FFFFFF !important;
  238. line-height: 40px;
  239. }
  240. .label-item {
  241. width: 64px;
  242. font-size: 14px;
  243. color: #333;
  244. height: 12.8vw;
  245. line-height: 12.8vw;
  246. text-align: center;
  247. }
  248. .w220 {
  249. width: 220px;
  250. }
  251. </style>