299 lines
8.0 KiB
Vue
299 lines
8.0 KiB
Vue
<template>
|
|
<s-layout title="实名认证" navbar="transparent">
|
|
<view class="realname-page">
|
|
<!-- <image src="/static/transparent_bg.png" class="transparent_bg" /> -->
|
|
|
|
<view class="realname-bg m-x-24 m-y-24 p-b-68">
|
|
<view class="card m-b-20 flex-center ju-flex-start size30" v-if="showStatusCard">
|
|
<view class="icon h_30 w_30 m-r-10">
|
|
<image :src="$url + statusObj[dataObj.approvalStatus]?.icon" class="w100 h100" />
|
|
</view>
|
|
{{ statusObj[dataObj.approvalStatus]?.name }}
|
|
</view>
|
|
<view class="card">
|
|
<view class="head-title"> 上传身份证 </view>
|
|
<view class="img-box m-t-16" @click="upImg(1)">
|
|
<view v-if="!dataObj.cardPortraitUrl">
|
|
<view class="updata-img">
|
|
<image src="/static/id_card_zheng.png" />
|
|
</view>
|
|
上传身份证人像面
|
|
</view>
|
|
<image :src="dataObj.cardPortraitUrl" v-else />
|
|
</view>
|
|
|
|
<view class="img-box m-t-24" @click="upImg(2)">
|
|
<view v-if="!dataObj.cardEmblemUrl">
|
|
<view class="updata-img">
|
|
<image src="/static/id_card_fan.png" />
|
|
</view>
|
|
上传身份证国徽面
|
|
</view>
|
|
<image :src="dataObj.cardEmblemUrl" v-else />
|
|
</view>
|
|
</view>
|
|
<view class="card size28 flex-between m-t-38">
|
|
<text>姓名</text>
|
|
<view class="ipt-bar">
|
|
<uni-easyinput
|
|
maxlength="6"
|
|
:clearable="false"
|
|
:inputBorder="false"
|
|
v-model="dataObj.userName"
|
|
placeholder="请输入姓名"
|
|
/>
|
|
</view>
|
|
</view>
|
|
<view class="card size28 flex-between m-t-28">
|
|
<text>身份证</text>
|
|
<view class="ipt-bar">
|
|
<uni-easyinput
|
|
maxlength="18"
|
|
:clearable="false"
|
|
:inputBorder="false"
|
|
v-model="dataObj.cardNumber"
|
|
placeholder="请输入身份证号码"
|
|
/>
|
|
</view>
|
|
</view>
|
|
<view class="btn" v-if="showForm" @click="submit()"> 提交审核 </view>
|
|
</view>
|
|
</view>
|
|
</s-layout>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { getCurrentInstance, ref, computed } from 'vue';
|
|
import { baseUrl } from '@/sheep/config';
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import * as api from '@/sheep/api/home/pay';
|
|
let realStatus = ref();
|
|
const dataObj = ref({
|
|
id: '',
|
|
userId: '',
|
|
userName: '',
|
|
cardNumber: '',
|
|
cardPortraitUrl: '',
|
|
cardEmblemUrl: '',
|
|
approvalStatus: '', //0-审批中,1-审批通过,2-失败
|
|
});
|
|
let statusObj = {
|
|
1: {
|
|
name: '实名认证成功',
|
|
icon: 'home/audit_status_1.svg',
|
|
},
|
|
2: {
|
|
name: '实名认证失败,请重新提交信息',
|
|
icon: 'home/audit_status_2.svg',
|
|
},
|
|
0: {
|
|
name: '实名认证审核中',
|
|
icon: 'home/audit_status_0.svg',
|
|
},
|
|
};
|
|
|
|
// 统一的显示/隐藏控制
|
|
const showStatusCard = computed(() => dataObj.value.approvalStatus !== '');
|
|
const showForm = computed(
|
|
() => dataObj.value.approvalStatus === '' || dataObj.value.approvalStatus === 2,
|
|
);
|
|
onLoad((e) => {
|
|
let user = JSON.parse(uni.getStorageSync('user-store')).userInfo;
|
|
|
|
dataObj.value.userId = user.id;
|
|
// dataObj.value.approvalStatus = Number(e.status)
|
|
realStatus.value = e.status;
|
|
//1.获取实名认证信息
|
|
getUserData();
|
|
});
|
|
let getUserData = (id) => {
|
|
api.getRealName({}).then((res) => {
|
|
//2.判断状态
|
|
//如果res.data为空,没有提交实名状态
|
|
if (res.data) {
|
|
dataObj.value = res.data;
|
|
}
|
|
console.log(dataObj.value);
|
|
});
|
|
};
|
|
const submit = () => {
|
|
let pattern = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[0-9Xx]$/;
|
|
if (!dataObj.value.cardPortraitUrl) {
|
|
uni.showToast({
|
|
title: '请上传身份证人像面',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
} else if (!dataObj.value.cardEmblemUrl) {
|
|
uni.showToast({
|
|
title: '请上传身份证国徽面',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
} else if (!dataObj.value.userName) {
|
|
uni.showToast({
|
|
title: '请输入姓名',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
} else if (!dataObj.value.cardNumber) {
|
|
uni.showToast({
|
|
title: '请输入身份证号',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
} else if (!pattern.test(dataObj.value.cardNumber)) {
|
|
uni.showToast({
|
|
title: '请输入有效身份证号',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
} else {
|
|
console.log(dataObj.value);
|
|
if (!dataObj.value?.approvalStatus || dataObj.value?.approvalStatus == 0) {
|
|
api.createRealName(dataObj.value).then((res) => {
|
|
if (res.code === 0) {
|
|
getUserData();
|
|
}
|
|
});
|
|
} else if (dataObj.value?.approvalStatus == 2) {
|
|
api.updateRealName(dataObj.value).then((res) => {
|
|
if (res.code === 0) {
|
|
getUserData();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
const upImg = (type) => {
|
|
if (!showForm.value) {
|
|
return;
|
|
}
|
|
uni.chooseImage({
|
|
count: 1, //默认9
|
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
success: function (res) {
|
|
console.log(res);
|
|
const tempFilePaths = res.tempFilePaths;
|
|
const tempFiles = res.tempFiles;
|
|
let resSize = tempFiles[0].size;
|
|
if (resSize > 1048576) {
|
|
uni.showToast({
|
|
title: '上传图片大小不能超过1MB',
|
|
icon: 'error',
|
|
});
|
|
return;
|
|
}
|
|
const token = uni.getStorageSync('token') ? uni.getStorageSync('token') : undefined;
|
|
let tenant_id = uni.getStorageSync('tenant-id');
|
|
uni.uploadFile({
|
|
url: baseUrl + '/app-api/infra/file/upload', //仅为示例,非真实的接口地址
|
|
filePath: tempFilePaths[0],
|
|
name: 'file',
|
|
formData: {
|
|
directory: 'card',
|
|
'tenant-id': tenant_id,
|
|
token: token,
|
|
},
|
|
header: {},
|
|
success: (uploadFileRes) => {
|
|
let url = JSON.parse(uploadFileRes.data).data;
|
|
console.log(url);
|
|
console.log(type);
|
|
if (type === 1) {
|
|
dataObj.value.cardPortraitUrl = url;
|
|
} else if (type === 2) {
|
|
dataObj.value.cardEmblemUrl = url;
|
|
}
|
|
// upData({
|
|
// avatar: url
|
|
// });
|
|
},
|
|
});
|
|
},
|
|
});
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.transparent_bg {
|
|
width: 100%;
|
|
height: 708rpx;
|
|
|
|
// position: fixed;
|
|
// top: 0;
|
|
// left: 0;
|
|
image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
.realname-bg {
|
|
z-index: 100;
|
|
}
|
|
|
|
.card {
|
|
padding: 30rpx;
|
|
background: #fff;
|
|
border-radius: 12rpx;
|
|
|
|
.ipt-bar {
|
|
// min-width: 300rpx;
|
|
|
|
::v-deep .uni-input-input {
|
|
// color: #fff;
|
|
text-align: right;
|
|
}
|
|
|
|
::v-deep .uni-easyinput__placeholder-class {
|
|
text-align: right;
|
|
}
|
|
}
|
|
|
|
.head-title {
|
|
font-size: 28rpx;
|
|
// color: #FFFFFF;
|
|
line-height: 52rpx;
|
|
}
|
|
|
|
.img-box {
|
|
width: 590rpx;
|
|
height: 324rpx;
|
|
background: #f2f5f7;
|
|
border-radius: 12rpx;
|
|
margin: 0 26rpx;
|
|
text-align: center;
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
line-height: 34rpx;
|
|
overflow: hidden;
|
|
// padding: 28rpx 0;
|
|
|
|
.updata-img {
|
|
width: 256rpx;
|
|
height: 182rpx;
|
|
margin: 28rpx auto 46rpx;
|
|
border-radius: 12rpx;
|
|
// border: 1rpx solid #999;
|
|
}
|
|
|
|
image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
|
|
.btn {
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
background: linear-gradient(to right, #fa8735 0%, #fe3b48 100%);
|
|
color: #fff;
|
|
margin: 140rpx 112rpx 0;
|
|
font-size: 32rpx;
|
|
border-radius: 50rpx;
|
|
text-align: center;
|
|
}
|
|
</style>
|