HomeLease/pages/realNameAuthentication/realNameAuthentication.vue

294 lines
7.3 KiB
Vue
Raw Normal View History

2025-09-08 15:11:14 +08:00
<template>
2025-09-09 14:03:07 +08:00
<view class="page">
2025-09-08 15:11:14 +08:00
<custom-nav-bar :fill="false" :show-back="true" background-color="transparent" title="" />
2025-09-09 14:03:07 +08:00
<image class="bj" mode="" src="https://api.ccttiot.com/image-1757389708427.png"></image>
2025-09-09 16:31:55 +08:00
<view v-if="!isReal" class="sfxx">
2025-09-09 14:03:07 +08:00
<view class="tit"> 请输入您的有效身份信息</view>
<view class="name"> 姓名 <input v-model="name" placeholder="请填写姓名" type="text" /></view>
<view class="name">
身份证号 <input v-model="zfzh" placeholder="请填写身份证号" type="text" />
</view>
<view class="" style="width: 100%; text-align: center; margin-top: 20rpx; color: #ccc">
您当前还未完成实名认证
2025-09-08 15:11:14 +08:00
</view>
</view>
2025-09-09 14:03:07 +08:00
<view v-else class="sfxx">
<view class="tit"> 请输入您的有效身份信息</view>
<view class="name">
姓名 <input v-model="name" :disabled="true" placeholder="请填写姓名" type="text" />
</view>
<view class="name">
身份证号 <input v-model="zfzh" :disabled="true" placeholder="请填写身份证号" type="text" />
</view>
<view class="" style="width: 100%; text-align: center; margin-top: 20rpx; color: #ccc">
您当前已完成实名认证
</view>
</view>
2025-09-09 16:31:55 +08:00
<view v-if="!isReal" class="anniu" @click="btnshiming">
2025-09-09 14:03:07 +08:00
<!-- <text>进入人脸识别</text> -->
<text>提交</text>
2025-09-08 15:11:14 +08:00
</view>
<view v-if="isRefresh" class="refresh" @click="toGetshuaxin">
<text>刷新实名状态</text>
</view>
<uv-toast ref="toast"></uv-toast>
2025-09-08 15:11:14 +08:00
</view>
</template>
<script>
2025-09-09 14:03:07 +08:00
import {
putRealName,
refreshRealName,
} from '../../api/realNameAuthentication/realNameAuthentication'
2025-09-08 15:11:14 +08:00
export default {
data() {
return {
isRefresh: false,
2025-09-09 16:31:55 +08:00
isReal: false,
2025-09-09 14:03:07 +08:00
bgc: {
backgroundColor: '',
2025-09-08 15:11:14 +08:00
},
2025-09-09 14:03:07 +08:00
name: '',
zfzh: '',
2025-09-09 16:31:55 +08:00
2025-09-09 14:03:07 +08:00
backData: null,
smflag: true,
}
},
onLoad(option) {
if (option.isReal === 'true') {
2025-09-10 11:58:27 +08:00
console.log('路由传入的实名', option.isReal)
this.isReal = true
2025-09-10 11:58:27 +08:00
console.log('vue挂载的实名', this.isReal)
2025-09-08 15:11:14 +08:00
}
},
2025-09-09 14:03:07 +08:00
onShow() {
// if (this.backData === true) {
// console.log('接收数据:', this.backData);
// this.getshuaxin();
// this.backData = null; // 重置
// }
this.smflag = true
2025-09-09 14:03:07 +08:00
},
2025-09-08 15:11:14 +08:00
methods: {
toGetshuaxin() {
uni.$uv.debounce(this.getshuaxin, 500, true)
},
// 刷新人脸识别状态
async getshuaxin() {
try {
// 显示加载Toast30秒超时自动隐藏
2025-09-12 09:05:57 +08:00
uni.showLoading({
title: '正在刷新实名信息',
mask: 'true',
})
const res = await refreshRealName()
2025-09-12 09:05:57 +08:00
uni.hideLoading()
2025-09-09 14:03:07 +08:00
if (res.code === 200) {
this.handleRefreshSuccess(res.data)
2025-09-09 14:03:07 +08:00
} else {
this.handleRefreshFail(res.msg || '人脸认证失败')
2025-09-09 14:03:07 +08:00
}
} catch (error) {
2025-09-12 09:05:57 +08:00
uni.hideLoading()
this.handleRefreshFail(error.message || '网络异常')
}
},
// 处理成功响应
handleRefreshSuccess(data) {
if (data.pass) {
uni.showModal({
title: '认证成功',
showCancel: false,
complete: () => uni.navigateBack(),
})
} else {
this.handleRefreshFail('人脸验证未通过')
}
},
// 统一处理失败
handleRefreshFail(message) {
// uni.showModal({
// title: '提示',
// content: message,
// showCancel: false,
// // complete: () => uni.navigateBack(),
// })
2025-09-08 15:11:14 +08:00
},
2025-09-09 14:40:31 +08:00
2025-09-09 14:03:07 +08:00
// 点击进行实名认证
btnshiming() {
if (this.smflag === true) {
this.smflag = false
let data = {
userName: this.name,
idCard: this.zfzh,
}
console.log('身份信息', data)
putRealName(data)
.then(res => {
if (res.code === 200) {
let https = encodeURIComponent(res.data.jumpUrl)
this.backData = true
uni.navigateTo({
url: '/page_user/facialRecognition/facialRecognition?https=' + https,
})
this.isRefresh = true
}
// else if (res.code === 500 && res.msg === null) {
// uni.showToast({
// title: '已提交,请等待系统反馈',
// icon: 'none',
// duration: 2000,
// })
// this.smflag = true
// } else {
// uni.showToast({
// title: res.msg,
// icon: 'none',
// duration: 2000,
// })
// this.smflag = true
// }
})
.catch(error => {
if (error.code === 500 && error === null) {
uni.showToast({ title: '已提交,请等待系统反馈', icon: 'none' })
} else {
uni.showToast({ title: error || '系统错误', icon: 'none' })
console.log('@@@@@@@@', error)
}
2025-09-09 14:03:07 +08:00
this.smflag = true
})
2025-09-08 15:11:14 +08:00
}
2025-09-09 14:03:07 +08:00
// this.$u.put(`/app/realName/realName`,data).then(res =>{ //人脸
// if(res.code === 200){
// let https = encodeURIComponent(res.data.jumpUrl)
// this.backData = true
// uni.navigateTo({
// url:'/page_fenbao/renlian?https=' + https
// })
// }else{
// uni.showToast({
// title: res.msg,
// icon: 'none',
// duration: 2000
// })
// }
// })
2025-09-08 15:11:14 +08:00
},
},
}
</script>
2025-09-09 14:03:07 +08:00
<style lang="scss">
.anniu {
width: 750rpx;
height: 174rpx;
background: #ffffff;
box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0, 0, 0, 0.3);
border-radius: 0rpx 0rpx 0rpx 0rpx;
line-height: 174rpx;
text-align: center;
position: fixed;
left: 0;
bottom: 0;
text {
display: inline-block;
width: 682rpx;
height: 84rpx;
background: #f15a04;
border-radius: 42rpx 42rpx 42rpx 42rpx;
text-align: center;
line-height: 84rpx;
font-weight: 600;
font-size: 36rpx;
color: #ffffff;
}
}
.refresh {
width: 250rpx;
height: 174rpx;
line-height: 174rpx;
text-align: center;
padding: 0 250rpx;
text {
display: inline-block;
width: 250rpx;
height: 84rpx;
background: #f15a04;
border-radius: 42rpx 42rpx 42rpx 42rpx;
text-align: center;
line-height: 84rpx;
font-weight: 600;
2025-09-09 14:03:07 +08:00
font-size: 36rpx;
color: #ffffff;
2025-09-08 15:11:14 +08:00
}
2025-09-09 14:03:07 +08:00
}
2025-09-08 15:11:14 +08:00
2025-09-09 14:03:07 +08:00
.sfxx {
width: 676rpx;
height: 480rpx;
background: #ffffff;
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin: auto;
margin-top: 460rpx;
border-radius: 30rpx;
.name {
width: 624rpx;
height: 92rpx;
margin: auto;
background: #efefef;
border-radius: 46rpx 46rpx 46rpx 46rpx;
margin-top: 46rpx;
2025-09-08 15:11:14 +08:00
display: flex;
2025-09-09 14:03:07 +08:00
align-items: center;
font-size: 32rpx;
color: #3d3d3d;
padding-left: 40rpx;
box-sizing: border-box;
justify-content: space-between;
input {
width: 430rpx;
padding-right: 20rpx;
box-sizing: border-box;
2025-09-08 15:11:14 +08:00
}
}
2025-09-09 14:03:07 +08:00
.tit {
width: 676rpx;
height: 118rpx;
background: #efefef;
font-weight: 600;
font-size: 36rpx;
color: #3d3d3d;
line-height: 118rpx;
padding-left: 38rpx;
box-sizing: border-box;
border-radius: 30rpx 30rpx 0 0;
}
2025-09-08 15:11:14 +08:00
}
2025-09-09 14:03:07 +08:00
.bj {
width: 750rpx;
height: 696rpx;
2025-09-08 15:11:14 +08:00
position: fixed;
2025-09-09 14:03:07 +08:00
top: 0;
2025-09-08 15:11:14 +08:00
left: 0;
2025-09-09 14:03:07 +08:00
z-index: -1;
2025-09-08 15:11:14 +08:00
}
</style>