<template> <view> <view class="tips" v-if="item.isAuthentication === 1"> <text class="icon"></text> <text>实名认证成功</text> </view> <view class="main"> <view v-if="step === 1"> <u-divider text="本人二代身份证"></u-divider> <view class="r"> <view class="r50"> <ocr v-model="item.p1" text="点击上传人像面" icon="" :read="item.isAuthentication === 1" side="face" @success="success"></ocr> </view> <view class="r50"> <ocr v-model="item.p2" text="点击上传国徽面" icon="" :read="item.isAuthentication === 1" side="back" @success="success"></ocr> </view> </view> </view> <view v-else> <view class="form_group"> <view class="lable re">姓名</view> <input type="text" v-model="item.name" :disabled="true" /> </view> <view class="form_group"> <view class="lable re">身份证</view> <input type="text" v-model="item.idCard" :disabled="true" /> </view> </view> <view class="bos" v-if="item.isAuthentication === 1"> <view class="item b">姓名:</view> <view class="item">{{ item.name }}</view> <view class="item b">身份证:</view> <view class="item">{{ item.idCard }}</view> <view class="item b">有效期:</view> <view class="item">{{ item.endDate }}</view> </view> <view v-if="item.isAuthentication === 0"> <view class="bz"> <text class="icon"></text> <text>为保证用户信息真实可靠,需要实名认证</text> </view> <view class="bz"> <text class="icon"></text> <text>未经您允许不对外提供</text> </view> </view> <button class="btn" @click="next()" v-if="step === 1 && item.isAuthentication != 1">下一步</button> <button class="btn" @click="save()" v-if="step === 2 && item.isAuthentication != 1">确定</button> </view> </view> </template> <script> export default { data() { return { step: 1, item: {} }; }, onLoad() { this.getData(); }, methods: { getData() { this.http.request({ url: '/app/user/info', data: this.item, success: (res) => { this.item = res.data.data; if (this.item.isAuthentication === 1) { uni.setNavigationBarTitle({ title: '我的认证' }); } } }); }, success(res) { if (res.side == 'face') { this.item.name = res.data.name; this.item.idCard = res.data.num; this.item.sex = res.data.sex; this.item.address = res.data.address; this.item.nationality = res.data.nationality; this.item.birth = res.data.birth; } else { this.item.endDate = res.data.end_date; } }, next() { if (!this.item.name) { uni.showModal({ content: '请上传身份证人像面', showCancel: false }); return; } if (!this.item.endDate) { uni.showModal({ content: '请上传身份证国徽面', showCancel: false }); return; } this.step = 2; }, save() { let rule = [ { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' }, { name: 'idCard', checkType: 'notnull', errorMsg: '请输入身份证' }, { name: 'p1', checkType: 'notnull', errorMsg: '请上传身份证人面像' }, { name: 'p2', checkType: 'notnull', errorMsg: '请上传身份证人徽面' } ]; if (!this.verify.check(this.item, rule)) { uni.showModal({ content: this.verify.error, showCancel: false }); return false; } this.http.request({ url: '/app/user/auth', data: this.item, method: 'POST', success: (res) => { uni.showModal({ title: '提示', content: '实名认证成功。', showCancel: false, success: (res) => { uni.navigateBack(); } }); } }); } } }; </script> <style lang="scss"> .bos { background-color: white; padding: 20px; border-radius: 8px; .item { font-size: 14px; padding-top: 7px; } .b { font-weight: bold; } } </style>