<template> <view class="pages"> <u-navbar :custom-back="btnback" title="实名认证" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff' title-size='36' height='44'></u-navbar> <!-- 未有实名认证 --> <view class="" v-if="flags"> <view class="listval"> <view class="tit"> 真实姓名</view> <view class="but"> <input type="text" placeholder="请输入真实姓名" v-model="name"/> </view> </view> <view class="listval"> <view class="tit"> 身份证号</view> <view class="but"> <input type="text" placeholder="请输入身份证号" v-model="names" /> </view> </view> <view class="listval"> <view class="yz" v-if="yzflag"> </view> <view class="yz" v-else> </view> </view> <view class="" style="width: 100%;margin-top: 50rpx;color: red;text-align: center;"> 提现需实名认证,请输入真实有效实名信息! </view> </view> <view class="" v-else> <view class="listval"> <view class="tit"> 真实姓名</view> <view class="but"> <input type="text" placeholder="请输入真实姓名" disabled="true" v-model="name"/> </view> </view> <view class="listval"> <view class="tit"> 身份证号</view> <view class="but"> <input type="text" placeholder="请输入身份证号" disabled="true" v-model="names" /> </view> </view> <view class="listval"> <view class="yz" v-if="yzflag"> </view> <view class="yz" v-else> </view> </view> <view class="" style="width: 100%;margin-top: 50rpx;color: red;text-align: center;"> 提现需实名认证,请输入真实有效实名信息! </view> </view> <!-- 已有实名认证 --> <view class="baocun" @click="btnyanz" v-if="flag"> 进行人脸验证 </view> <view class="baocun" @click="btnyz" v-else> 进行人脸验证 </view> </view> </template> <script> export default { data() { return { bgc: { backgroundColor: "#8883f0", }, name: '', names: '', tel: '', flag: false, yzflag: true, type:'', user:{}, flags:false } }, onLoad(option) { this.type = option.type this.getuserinfo() }, // 分享到好友(会话) onShareAppMessage: function() { return { title: '创亿康', path: '/pages/index/index' } }, // 分享到朋友圈 onShareTimeline: function() { return { title: '创亿康', query: '', path: '/pages/index/index' } }, methods: { getuserinfo() { this.$u.get("/app/user/userInfo").then((res) => { if (res.code == 200) { this.name = res.data.realName this.names = res.data.realIdCard if(res.data.isReal == true){ this.flags = false this.flag = true }else{ this.flags = true this.flag = false } } }) }, // 直接进行验证 btnyanz(){ this.$u.put("/app/user/riskRealName").then((res) => { if (res.code == 200) { let https = encodeURIComponent(res.data.jumpUrl) uni.navigateTo({ url: '/pages/sjshiming?https=' + https }) } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) } }) }, btnback(){ uni.reLaunch({ url:'/page_user/yetx' }) }, btnyz() { function isAgeOver18(idCard) { // 提取出生年份 const birthYear = idCard.substr(6, 4); // 身份证号码的第7到第10位是出生年份 // 获取当前年份 const currentYear = new Date().getFullYear(); // 计算年龄 const age = currentYear - parseInt(birthYear, 10); // 判断是否年满18岁 return age >= 18; } const idCard = this.names // 调用函数并输出结果 if (isAgeOver18(idCard)) { console.log('身份证对应的用户已年满18岁'); let data = { realName: this.name, realIdCard: this.names, type:this.type } this.$u.put('/app/user/realName', data).then(res => { if (res.code == 200) { let https = encodeURIComponent(res.data.jumpUrl) uni.navigateTo({ url: '/pages/sjshiming?https=' + https }) } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) } }) } else { console.log('身份证对应的用户未满18岁'); uni.showToast({ title: '实名认证需年满18岁', icon: 'none', duration: 2000 }) } } } } </script> <style lang="scss" scoped> /deep/ .u-title { padding-bottom: 15rpx; } /deep/ .u-icon__icon { padding-bottom: 15rpx; } .pages { background-color: #F7FAFE !important; height: 100vh; width: 100%; padding: 0 50rpx; box-sizing: border-box; .baocun { width: 584rpx; height: 90rpx; background: linear-gradient(90deg, #8883F0 0%, #A29EFF 100%); border-radius: 54rpx 54rpx 54rpx 54rpx; margin: auto; text-align: center; line-height: 90rpx; position: fixed; left: 50%; transform: translateX(-50%); bottom: 60rpx; font-weight: 500; font-size: 40rpx; color: #FFFFFF; } .listval { width: 100%; display: flex; justify-content: space-between; margin-top: 34rpx; .yz { color: red; } .rl { border-bottom: 1rpx solid #3D3D3D; } .tit { margin-top: 12rpx; font-size: 32rpx; color: #3D3D3D; } .but { width: 462rpx; height: 70rpx; background: #F0F0F0; border-radius: 12rpx 12rpx 12rpx 12rpx; input { height: 70rpx; line-height: 70rpx; padding-left: 22rpx; } } } } </style>