Jelajahi Sumber

人脸认证

xiongzhu 3 tahun lalu
induk
melakukan
6e137f1e71

+ 6 - 0
src/router/index.js

@@ -618,6 +618,12 @@ const routes = [
         name: 'walletAgreement',
         component: () => import('../views/user/WalletAgreement.vue'),
         meta: {}
+    },
+    {
+        path: '/faceAuth',
+        name: 'faceAuth',
+        component: () => import('../views/account/FaceAuth.vue'),
+        meta: {}
     }
 ];
 

+ 9 - 3
src/views/Mine.vue

@@ -217,7 +217,8 @@ export default {
             },
             shareMoney: 0,
             refreshFlag: Number(localStorage.getItem('refreshFlag') || '0'),
-            enableWallet: false
+            enableWallet: false,
+            faceAuth: false
         };
     },
     components: { Level, Post },
@@ -248,11 +249,12 @@ export default {
                     });
 
                 this.getProduct();
-                this.$http.get('/sysConfig/get/share_lvzhoushi_num,enable_wallet').then(res => {
+                this.$http.get('/sysConfig/get/share_lvzhoushi_num,enable_wallet,enable_face_auth').then(res => {
                     if (res['share_lvzhoushi_num'] && res['share_lvzhoushi_num'].value) {
                         this.shareMoney = Number(res['share_lvzhoushi_num'].value);
                     }
                     this.enableWallet = res['enable_wallet'].value === '1';
+                    this.faceAuth = res['enable_face_auth'].value === '1';
                 });
             }
 
@@ -279,7 +281,11 @@ export default {
             if (this.authStatus === '认证中' || this.authStatus === '认证失败') {
                 this.$router.push('/waiting');
             } else if (this.authStatus === '未认证') {
-                this.$router.push('/Authentication');
+                if (this.faceAuth) {
+                    this.$router.push('/faceAuth');
+                } else {
+                    this.$router.push('/verified');
+                }
             }
         },
         getProduct() {

+ 360 - 0
src/views/account/FaceAuth.vue

@@ -0,0 +1,360 @@
+<template>
+    <div class="login">
+        <div class="tabs">
+            <div class="text1">个人认证</div>
+            <div class="text2">
+                <span>账户实名认证后不能修改,</span>
+                <span>请使用本人身份信息完成认证</span>
+            </div>
+        </div>
+
+        <van-form @submit="submit" @failed="failed" ref="form">
+            <van-field
+                label="姓名"
+                name="姓名"
+                placeholder="请输入您真实姓名"
+                v-model="form.name"
+                :rules="[{ required: true, message: '请输入您真实姓名' }]"
+            >
+            </van-field>
+
+            <!-- <van-field
+                type="tel"
+                label="手机号码"
+                name="手机号码"
+                placeholder="请输入您的手机号码"
+                v-model="form.phone"
+                :maxlength="11"
+                :rules="[
+                    { required: true, message: '请输入您的手机号码' },
+                    {
+                        pattern: phonePattern,
+                        message: '手机号码格式错误'
+                    }
+                ]"
+            >
+            </van-field>
+
+            <van-field
+                label="电子邮箱"
+                name="电子邮箱"
+                placeholder="请输入电子邮箱"
+                v-model="form.email"
+                :rules="[
+                    { required: true, message: '请输入电子邮箱' },
+                    {
+                        pattern: emailPattern,
+                        message: '电子邮箱格式错误'
+                    }
+                ]"
+            >
+            </van-field> -->
+
+            <van-field
+                label="身份证号"
+                name="身份证号"
+                placeholder="请输入身份证号"
+                v-model="form.idNo"
+                :rules="[
+                    { required: true, message: '请输入身份证号' },
+                    {
+                        pattern: IDPattern,
+                        message: '身份证号格式错误'
+                    }
+                ]"
+            >
+            </van-field>
+
+            <!-- <van-field
+                label="身份证照片(正面照)"
+                name="正面照"
+                v-model="form.idFront"
+                class="img"
+                :rules="[
+                    {
+                        validator: val => {
+                            return !!this.form.idFront;
+                        },
+                        message: '请上传身份证正面照片'
+                    }
+                ]"
+            >
+                <template #input>
+                    <div class="img-content">
+                        <van-image :src="form.idFront || require('@assets/svgs/bg-png.svg')" fit="cover" radius="20" />
+                        <van-uploader name="idFront" result-type="file" :after-read="afterRead" />
+                    </div>
+                </template>
+            </van-field>
+            <van-field
+                label="身份证照片(反面照)"
+                name="反面照"
+                v-model="form.idBack"
+                class="img"
+                :rules="[
+                    {
+                        validator: val => {
+                            return !!this.form.idBack;
+                        },
+                        message: '请上传身份证反面照片'
+                    }
+                ]"
+            >
+                <template #input>
+                    <div class="img-content">
+                        <van-image :src="form.idBack || require('@assets/svgs/bg-png.svg')" fit="cover" radius="20" />
+                        <van-uploader name="idBack" result-type="file" :after-read="afterRead" />
+                    </div>
+                </template>
+            </van-field> -->
+
+            <div class="button" ref="btn">
+                <van-button
+                    round
+                    block
+                    @click="submit"
+                    :color="`linear-gradient(to right, ${$colors.prim}, ${$colors.warn})`"
+                    class="sure"
+                >
+                    身份验证
+                </van-button>
+            </div>
+        </van-form>
+        <a id="auth" :href="url"></a>
+    </div>
+</template>
+
+<script>
+import { mapState } from 'vuex';
+import phone from '../../mixins/phone';
+export default {
+    computed: {
+        ...mapState(['userInfo'])
+    },
+
+    mixins: [phone],
+    data() {
+        return {
+            active: 'phone',
+            emailPattern: /^([a-zA-Z0-9]+[_|_|\-|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,6}$/,
+            IDPattern: /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/,
+            form: {
+                name: '',
+                phone: '',
+                email: '',
+                idNo: '',
+                idFront: '',
+                idBack: '',
+                status: ''
+            },
+            btn: null,
+            url: ''
+        };
+    },
+    mounted() {
+        this.btn = this.$refs.btn;
+    },
+    methods: {
+        submit() {
+            this.$refs.form
+                .validate()
+                .then(() => {
+                    this.$toast.loading({
+                        message: '等待认证',
+                        forbidClick: true
+                    });
+                    let form = { ...this.form };
+                    form.userId = this.userInfo.id;
+                    form.status = 'PENDING';
+                    form.org = false;
+                    this.$http
+                        .post('/user/faceAuth', {
+                            ...form
+                        })
+                        .then(res => {
+                            console.log(res);
+                            if (/micromessenger/i.test(navigator.userAgent)) {
+                                document.location.replace(res.url);
+                            } else {
+                                this.url =
+                                    'alipays://platformapi/startapp?appId=20000067&url=' + encodeURIComponent(res.url);
+                                this.$nextTick(() => {
+                                    document.getElementById('auth').click();
+                                });
+                            }
+
+                            let timer = setInterval(() => {
+                                this.$http.get('/user/my').then(res => {
+                                    if (res.authStatus === 'SUCCESS') {
+                                        clearInterval(timer);
+                                        this.$toast('认证成功');
+                                        this.$store.commit('setUserInfo', res);
+                                        this.$router.go(-1);
+                                    }
+                                });
+                            }, 3000);
+                            setTimeout(() => {
+                                clearInterval(timer);
+                                this.$toast('认证超时,请稍后重试');
+                                this.$router.go(-1);
+                            }, 180000);
+                        })
+                        .catch(e => {});
+                })
+                .catch(() => {
+                    this.bs.value.refresh();
+                });
+        },
+        afterRead(file, e) {
+            this.updateFile(file, 'id', 1000).then(img => {
+                this.form[e.name] = img;
+            });
+        },
+        failed() {
+            console.log('验证失败');
+        }
+    }
+};
+</script>
+
+<style lang="less" scoped>
+.login {
+    padding: 10px 16px 150px;
+}
+
+.tabs {
+    padding-bottom: 12px;
+    .text1 {
+        font-size: 20px;
+        font-weight: bold;
+        color: @text0;
+        line-height: 30px;
+    }
+    .text2 {
+        font-size: 12px;
+        color: @text3;
+        line-height: 22px;
+        margin-top: 4px;
+        span {
+            &:last-child {
+                color: @prim;
+            }
+        }
+    }
+}
+.van-cell::after {
+    border-bottom-color: @tabBorder;
+}
+
+.icon {
+    display: block;
+    margin-top: 12px;
+}
+/deep/ .van-form {
+    // margin-top: 28px;
+    .van-cell {
+        padding: 0px 0;
+
+        .van-field__left-icon {
+            margin-right: 8px;
+        }
+    }
+
+    .van-field__body {
+        height: 70px;
+        align-items: center;
+    }
+
+    .van-field__label {
+        font-size: 14px;
+        font-weight: bold;
+        color: @text0;
+        line-height: 24px;
+        margin-top: 25px;
+    }
+}
+.button {
+    margin-top: 60px;
+
+    .del {
+        margin-top: 20px;
+        border-color: @text0;
+    }
+
+    .sure {
+        color: @bg !important;
+    }
+
+    .van-button {
+        font-weight: bold;
+    }
+}
+
+.sub-code {
+    padding-right: 0;
+    border-width: 0;
+}
+
+.img {
+    display: flex;
+    padding: 20px 0 10px;
+
+    .img-label {
+        font-size: 14px;
+        font-weight: bold;
+        color: @text0;
+        line-height: 20px;
+        margin: 5px 12px 5px 0;
+        min-width: 86px;
+    }
+}
+
+.img-content {
+    position: relative;
+    /deep/.van-uploader {
+        position: absolute;
+        left: 0;
+        top: 0;
+        opacity: 0;
+        .van-uploader__upload {
+            width: 160px;
+            height: 160px;
+        }
+    }
+}
+
+.button {
+    position: fixed;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    background-color: @bg2;
+    padding: 6px 42px;
+    z-index: 20;
+    .bottom(6px);
+    border-top: 1px solid @tabBorder;
+}
+
+/deep/.img {
+    &.van-cell {
+        margin-top: 20px;
+        .van-field__body {
+            height: 160px;
+        }
+        .van-field__label {
+            margin-top: 5px;
+        }
+    }
+}
+
+/deep/.van-field__control {
+    font-size: @font1 !important;
+    color: @text0;
+}
+#auth {
+    width: 0;
+    height: 0;
+    margin: 0;
+    padding: 0;
+}
+</style>

+ 44 - 14
src/views/account/Login.vue

@@ -142,6 +142,28 @@ export default {
     },
     mounted() {
         console.log(this.$store.state.loginBackUrl);
+        try {
+            window.cordova.plugins.UmengPlugin.login(
+                res => {
+                    this.$toast.loading('登录中');
+                    this.$http
+                        .post('/auth/oneKeyLogin', { token: res.token, umengKey: res.umengKey })
+                        .then(res => {
+                            this.$toast.clear();
+                            localStorage.setItem('nineToken', res);
+                            this.$store.dispatch('getUserInfo');
+                            this.finish();
+                        })
+                        .catch(e => {
+                            this.$toast.clear();
+                            window.cordova.plugins.UmengPlugin.closeLogin();
+                        });
+                },
+                err => {
+                    console.log(err);
+                }
+            );
+        } catch {}
     },
     methods: {
         sendPhone(e) {
@@ -163,20 +185,7 @@ export default {
             });
             this.check().then(() => {
                 this.$toast.success('登录成功');
-                setTimeout(() => {
-                    if (this.$store.state.loginBackUrl) {
-                        this.$router.replace(this.$store.state.loginBackUrl);
-                    } else if (
-                        !fromRoute ||
-                        !fromRoute.name ||
-                        fromRoute.name === 'userRegister' ||
-                        fromRoute.name === 'userLogin'
-                    ) {
-                        this.$router.replace('/home');
-                    } else {
-                        this.$router.back();
-                    }
-                }, 1500);
+                this.finish();
             });
         },
         check() {
@@ -217,6 +226,27 @@ export default {
                     alert('error');
                 }
             );
+        },
+        finish() {
+            setTimeout(() => {
+                if (this.$store.state.loginBackUrl) {
+                    this.$router.replace(this.$store.state.loginBackUrl);
+                } else if (
+                    !fromRoute ||
+                    !fromRoute.name ||
+                    fromRoute.name === 'userRegister' ||
+                    fromRoute.name === 'userLogin'
+                ) {
+                    this.$router.replace('/home');
+                } else {
+                    this.$router.back();
+                }
+                setTimeout(() => {
+                    try {
+                        window.cordova.plugins.UmengPlugin.closeLogin();
+                    } catch {}
+                }, 100);
+            }, 1500);
         }
     },
     watch: {

+ 1 - 1
src/views/user/Exchange.vue

@@ -150,7 +150,7 @@ export default {
             } else if (this.status == 'sale') {
                 return {
                     query: {
-                        fromUserId: this.$store.state.userInfo.id,
+                        fromUserId: this.$store.state.userInfo.id
                         // operation: '转让,转赠'
                     }
                 };