Quellcode durchsuchen

feat(邀请好友注册): upd

曾志翔 vor 3 Jahren
Ursprung
Commit
0e9ec9721c

+ 1 - 0
assets/style/variables.scss

@@ -3,3 +3,4 @@
 // The variables you want to modify
 // $font-size-root: 20px;
 // $c: red;
+$snackbar-bottom: env(safe-area-inset-bottom, 0px);

+ 3 - 2
nuxt.config.js

@@ -1,4 +1,4 @@
-import unpluginVueComponents from 'unplugin-vue-components/webpack';
+// import unpluginVueComponents from 'unplugin-vue-components/webpack';
 // import colors from 'vuetify/es5/util/colors'
 import zhHans from 'vuetify/lib/locale/zh-Hans';
 import dotenv from 'dotenv';
@@ -23,7 +23,7 @@ export default {
   // Global page headers: https://go.nuxtjs.dev/config-head
   head: {
     titleTemplate: '%s',
-    title: 'android-cloud-H5-nuxt',
+    title: '双子星云手机',
     htmlAttrs: {
       lang: 'zh-CN',
     },
@@ -79,6 +79,7 @@ export default {
     '~/plugins/native',
     '~/plugins/filters',
     '~/plugins/vue-data-dict',
+    { src: '~/plugins/v-mask', mode: 'client' },
     // '~/plugins/jweixin',
     // '~/plugins/umeng-datasources',
     // '@/plugins/vant',

+ 11 - 0
package-lock.json

@@ -22,6 +22,7 @@
         "normalize.css": "^8.0.1",
         "numeral": "^2.0.6",
         "nuxt": "^2.15.8",
+        "v-mask": "^2.3.0",
         "vant": "^2.12.47",
         "vee-validate": "^3.4.14",
         "vue": "^2.6.14",
@@ -18480,6 +18481,11 @@
         "uuid": "bin/uuid"
       }
     },
+    "node_modules/v-mask": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmmirror.com/v-mask/-/v-mask-2.3.0.tgz",
+      "integrity": "sha512-ap7pTtCTvj25CqX4VYXqudCBd0+XvYyhiiLbzWQQR7AMQosJ2+DPu0a94P9stk0EGmGcmYxJaPkFkfjD8hquWQ=="
+    },
     "node_modules/v8-compile-cache": {
       "version": "2.3.0",
       "resolved": "https://registry.npmmirror.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
@@ -35219,6 +35225,11 @@
       "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
       "dev": true
     },
+    "v-mask": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmmirror.com/v-mask/-/v-mask-2.3.0.tgz",
+      "integrity": "sha512-ap7pTtCTvj25CqX4VYXqudCBd0+XvYyhiiLbzWQQR7AMQosJ2+DPu0a94P9stk0EGmGcmYxJaPkFkfjD8hquWQ=="
+    },
     "v8-compile-cache": {
       "version": "2.3.0",
       "resolved": "https://registry.npmmirror.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",

+ 1 - 0
package.json

@@ -35,6 +35,7 @@
     "normalize.css": "^8.0.1",
     "numeral": "^2.0.6",
     "nuxt": "^2.15.8",
+    "v-mask": "^2.3.0",
     "vant": "^2.12.47",
     "vee-validate": "^3.4.14",
     "vue": "^2.6.14",

+ 1 - 1
pages/activity/invite-user.vue

@@ -145,7 +145,7 @@ export default {
       const url =
         location.origin +
         this.$router.resolve({
-          path: '/register-for-invite',
+          path: '/activity/invite-user/register',
           query: {
             invitationUserName: this.data.inviteUserName,
             activityId: this.data.activityId,

+ 206 - 0
pages/activity/invite-user/register.vue

@@ -0,0 +1,206 @@
+<template>
+  <v-container class="register-for-invite pa-0" fluid>
+    <div class="box box1">
+      <div class="box-header">快速注册</div>
+      <div class="box-main">
+        <validation-observer ref="observer" slim>
+          <v-form @submit.prevent="submit()">
+            <validation-provider
+              v-slot="{ errors }"
+              ref="providerPhome"
+              name="手机号码"
+              rules="required|min:11|max:11"
+              slim
+            >
+              <v-text-field
+                v-model="form.phone"
+                label=""
+                name="phone"
+                required
+                :error-messages="errors"
+                maxlength="11"
+                placeholder="请输入11位手机号"
+                solo
+                type="tel"
+                flat
+              />
+            </validation-provider>
+            <validation-provider
+              v-slot="{ errors }"
+              name="验证码"
+              rules="required|min:6|max:6"
+              slim
+            >
+              <v-text-field
+                v-model="form.code"
+                label=""
+                :error-messages="errors"
+                name="code"
+                maxlength="6"
+                required
+                placeholder="请输入验证码"
+                solo
+                flat
+              >
+                <template #append>
+                  <v-btn
+                    :loading="codeSending"
+                    :disabled="codeTime > 0"
+                    small
+                    depressed
+                    color="#8027E5"
+                    plain
+                    class="text-base"
+                    @click="sendSmsCode()"
+                  >
+                    <template v-if="codeTime > 0">{{ codeTime }}s</template>
+                    <template v-else>发送验证码</template>
+                  </v-btn>
+                </template>
+              </v-text-field>
+            </validation-provider>
+
+            <div class="">
+              <v-btn
+                type="submit"
+                :loading="submitting"
+                class="submit-btn"
+                rounded
+              ></v-btn>
+            </div>
+          </v-form>
+        </validation-observer>
+      </div>
+    </div>
+  </v-container>
+</template>
+
+<script>
+import { registerForInvite } from '~/api/user/client.js';
+import { sendSmsCode } from '~/api/message/phone.js';
+export default {
+  auth: false,
+  name: 'RegisterForInvite',
+  data() {
+    return {
+      form: {
+        phone: '',
+        code: '',
+        invitationUserName: null,
+        activityId: null,
+      },
+      codeSending: false,
+      codeTime: 0,
+      submitting: false,
+    };
+  },
+  fetch() {
+    this.form.invitationUserName = this.$route.query.invitationUserName;
+    this.form.activityId = this.$route.query.activityId;
+  },
+  head: {
+    title: '注册',
+  },
+  watch: {},
+  methods: {
+    maskPhone(value) {
+      return [/\d/, /\d/];
+    },
+    async submit() {
+      try {
+        this.submitting = true;
+        const valid = await this.$refs.observer.validate();
+        if (valid) {
+          this.$tongji.trackEvent('活动', '注册', '', 0);
+          const res = await registerForInvite(this, this.form);
+          this.$toast.success(res.msg);
+          this.toDownload();
+        }
+      } finally {
+        this.submitting = false;
+      }
+    },
+    toDownload() {
+      window.open('https://www.androidscloud.com', '_self');
+    },
+    async sendSmsCode() {
+      try {
+        this.codeSending = true;
+        const validationResult = await this.$refs.providerPhome.validate();
+        if (validationResult.valid) {
+          this.$tongji.trackEvent('活动', '发送短信', '', 0);
+          const res = await sendSmsCode(this, {
+            type: 'common',
+            authorizationType: 4,
+            phone: this.form.phone,
+          });
+          this.codeTime = 60;
+          this.codeInterval = setInterval(
+            () => --this.codeTime <= 0 && clearInterval(this.codeInterval),
+            1000,
+          );
+          this.$toast.success(res.msg);
+        }
+      } finally {
+        this.codeSending = false;
+      }
+    },
+  },
+};
+</script>
+
+
+<style lang="scss" scoped>
+.register-for-invite {
+  color: #333;
+  background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
+  background-size: 100% auto;
+  background-position-y: -44px;
+  overflow: hidden;
+  padding-bottom: 30px;
+  min-height: 100vh;
+}
+.box {
+  width: 373px;
+  box-sizing: border-box;
+  margin: auto;
+  border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
+  border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
+
+  // border-image-width: 200px;
+  // border-image-slice: 200%;
+  border-width: 38px 15px 15px;
+  // border-width: 1px;
+  border-style: solid;
+  position: relative;
+  + .box {
+    margin-top: 30px;
+  }
+  .box-header {
+    position: absolute;
+    top: -30px;
+    // left: 141px;
+    left: 0;
+    right: 0;
+    text-align: center;
+    padding: 0 130px;
+    color: #fff;
+  }
+  .box-main {
+    padding: 30px 15px 20px;
+  }
+}
+.box1 {
+  margin-top: 275px;
+}
+.submit-btn {
+  display: block;
+  margin: auto;
+  width: 302px !important;
+  height: 62px !important;
+  background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
+  background-size: 100% 100%;
+  margin-top: 24px;
+}
+</style>
+

+ 0 - 129
pages/register-for-invite.vue

@@ -1,129 +0,0 @@
-<template>
-  <v-container class="register-for-invite" fluid>
-    <div class="title">注册</div>
-    <validation-observer ref="observer" v-slot="{ invalid }" slim>
-      <v-form @submit.prevent="submit()">
-        <validation-provider
-          v-slot="{ errors }"
-          ref="providerPhome"
-          name="手机号码"
-          rules="required|min:11|max:11"
-          slim
-        >
-          <v-text-field
-            v-model="form.phone"
-            label="手机号码"
-            name="phone"
-            required
-            :error-messages="errors"
-            maxlength="11"
-            type="tel"
-          />
-        </validation-provider>
-        <validation-provider
-          v-slot="{ errors }"
-          name="验证码"
-          rules="required|min:6|max:6"
-          slim
-        >
-          <v-text-field
-            v-model="form.code"
-            label="验证码"
-            :error-messages="errors"
-            name="code"
-            maxlength="6"
-            required
-          >
-            <template #append-outer>
-              <v-btn
-                :loading="codeSending"
-                :disabled="codeTime > 0"
-                small
-                @click="sendSmsCode()"
-              >
-                <template v-if="codeTime > 0">{{ codeTime }}s</template>
-                <template v-else>发送验证码</template>
-              </v-btn>
-            </template>
-          </v-text-field>
-        </validation-provider>
-
-        <div class="">
-          <v-btn type="submit" :disabled="invalid" :loading="submitting"
-            >注册并下载app</v-btn
-          >
-        </div>
-      </v-form>
-    </validation-observer>
-  </v-container>
-</template>
-
-<script>
-import { registerForInvite } from '~/api/user/client.js';
-import { sendSmsCode } from '~/api/message/phone.js';
-export default {
-  auth: false,
-  name: 'RegisterForInvite',
-  data() {
-    return {
-      form: {
-        phone: '',
-        code: '',
-        invitationUserName: null,
-        activityId: null,
-      },
-      codeSending: false,
-      codeTime: 0,
-      submitting: false,
-    };
-  },
-  fetch() {
-    this.form.invitationUserName = this.$route.query.invitationUserName;
-    this.form.activityId = this.$route.query.activityId;
-  },
-  head: {
-    title: '注册',
-  },
-  watch: {},
-  methods: {
-    async submit() {
-      try {
-        this.submitting = true;
-        const valid = await this.$refs.observer.validate();
-        if (valid) {
-          this.$tongji.trackEvent('活动', '注册', '', 0);
-          const res = await registerForInvite(this, this.form);
-          this.$toast.success(res.msg);
-        }
-      } finally {
-        this.submitting = false;
-      }
-    },
-    async sendSmsCode() {
-      try {
-        this.codeSending = true;
-        const validationResult = await this.$refs.providerPhome.validate();
-        if (validationResult.valid) {
-          this.$tongji.trackEvent('活动', '发送短信', '', 0);
-          const res = await sendSmsCode(this, {
-            type: 'common',
-            authorizationType: 4,
-            phone: this.form.phone,
-          });
-          this.codeTime = 60;
-          this.codeInterval = setInterval(() => {
-            if (--this.codeTime <= 0) {
-              clearInterval(this.codeInterval);
-            }
-          }, 1000);
-          this.$toast.success(res.msg);
-        }
-      } finally {
-        this.codeSending = false;
-      }
-    },
-  },
-};
-</script>
-
-

+ 1 - 0
plugins/toast/index.js

@@ -8,6 +8,7 @@ export default function (c, i) {
     isString(optios)
       ? {
           message: optios,
+          // bottom:true
         }
       : optios;
 

+ 1 - 0
plugins/toast/toast.vue

@@ -1,6 +1,7 @@
 <template>
   <v-snackbar
     app
+    bottom
     class="toast"
     :value.sync="value"
     color="rgba(0,0,0,.8)"

+ 30 - 0
plugins/v-mask.js

@@ -0,0 +1,30 @@
+import Vue from 'vue';
+import VueMask from 'v-mask';
+Vue.use(VueMask);
+
+// 身份证
+const idCard = (value) => {
+  // 前17位数字
+  const mask = Array.from({ length: 17 }).fill(/\d/);
+  // 最后一位数字或X
+  mask.push(/(\d|X|x)/);
+  return mask;
+};
+
+const phone = (value) => {
+  const mask = [/1/, ...Array.from({ length: 10 }).fill(/\d/)];
+  return mask;
+};
+
+const bankCard = (value) => {
+  const mask = Array.from({ length: 20 }).fill(/\d/);
+  return mask;
+};
+
+export default function (c, i) {
+  i('mask', {
+    idCard,
+    phone,
+    bankCard,
+  });
+}