123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <template>
- <view class="content">
- <!-- <view class="bgimg">
- <image class="img" src="https://zhibo.liuniu946.com/img/bgRz.png" mode="widthFix"></image>
- </view> -->
- <view class='list userBox' v-if="!upDataLoding">
- <view class='item acea-row row-between-wrapper'>
- <view class="title">姓名</view>
- <view class='input'>
- <input class="inputText" type='text' name='name' v-model='form.name' maxlength="16"></input>
- </view>
- </view>
- <view class='item acea-row row-between-wrapper'>
- <view class="title">身份证</view>
- <view class='input acea-row row-between-wrapper'>
- <input class="inputText" type='text' name='card' v-model='form.card'></input>
- </view>
- </view>
- </view>
- <button v-if="!upDataLoding" class="add-btn" @click="pushData('add')">提交</button>
- <view v-else class="titleType">
- <text v-if="renus">
- 已通过实名认证
- </text>
- <text v-else>
- 已提交资料请等待审核结果
- </text>
- </view>
- </view>
- </template>
- <script>
- import {
- realName,
- checkUser,
- rate
- } from '@/api/user.js';
- // #ifdef APP
- const aliyunVerify = uni.requireNativePlugin('AP-FaceDetectModule');
- // #endif
- import {
- HTTP_REQUEST_URL
- } from '@/config/app.js';
- export default {
- data() {
- return {
- loding: false, //判断是否在点击中
- form: {
- name: '',
- card: '',
- // img: ''
- },
- upFileLoding: false, //防止上传图片时多次重复点击
- upDataLoding: false, //判断是否上传过数据
- renus: false, //判断是否已经通过实名认证
- };
- },
- onLoad(option) {
- this.init();
- },
- methods: {
- init() {
- const that = this;
- uni.showLoading({
- title: '数据获取中',
- mask: true
- });
- // 获取数据判断是否已经验证过
- rate({})
- .then(e => {
- // 如果已经提交数据跳转验证页
- if (e.data.is_auth == 1) {
- that.upDataLoding = true;
- console.log(1);
- that.getYz();
- } else {
- uni.hideLoading()
- }
- if (e.data.is_auth == 2) {
- that.upDataLoding = true;
- that.renus = true;
- that.$util.Tips({
- title: `已通过实名认证`
- });
- }
- if (e.data.is_auth == 3) {
- that.$api.msg(e.data.off);
- }
- })
- .catch(e => {
- uni.hideLoading()
- });
- },
- // 获取验证
- getYz() {
- const that = this;
- // #ifdef H5
- let metaInfo = JSON.stringify(window.getMetaInfo());
- let router = getApp().$router;
- // #endif
- // #ifdef APP
- console.log(aliyunVerify,'aliyunVerify');
- let metaInfo = aliyunVerify.getMetaInfo();
- let p = uni.getSystemInfoSync().platform;
- if (p === "ios") {
- metaInfo = JSON.stringify(metaInfo);
- }
- // #endif
- checkUser({
- metaInfo: metaInfo,
- // #ifdef H5
- url: HTTP_REQUEST_URL+'/pages/user/approve'
- // #endif
- }).then(({
- data
- }) => {
- uni.hideLoading()
- // #ifdef H5
- window.location.href = data.url + ""
- // #endif
- // #ifdef APP
- that.aliyunVerify(data.id)
- // #endif
- console.log(data, 'data');
- }).catch((err) => {
- uni.hideLoading()
- })
- },
- // #ifdef APP
- // 调用刷脸认证
- aliyunVerify(id) {
- const that = this;
- aliyunVerify.verify({
- "certifyId": id, // 填写从服务端获取的certifyId
- },
- function(res) {
- if (res.code == 1000) {
- uni.showLoading({
- title: '刷脸成功,等待通过',
- mask: true
- });
- setTimeout(() => {
- that.init();
- }, 3000)
- } else {
- if (res.code == 1001) {
- uni.showModal({
- title: '提示',
- content: '系统错误请重启APP重新验证',
- showCancel: false,
- });
- }
- if (res.code == 1003) {
- uni.showModal({
- title: '提示',
- content: '验证取消是否重新验证?',
- success: re => {
- if (re.confirm) {
- that.aliyunVerify(id)
- }
- },
- });
- }
- if (res.code == 2002) {
- uni.showModal({
- title: '提示',
- content: '网络错误请检查是否开启网络连接',
- showCancel: false,
- });
- }
- if (res.code == 2003) {
- uni.showModal({
- title: '提示',
- content: '设备时间错误,请校验时候后重试',
- showCancel: false,
- });
- }
- if (res.code == 2006) {
- uni.showModal({
- title: '提示',
- content: '刷脸失败,是否重试?',
- success: re => {
- if (re.confirm) {
- that.aliyunVerify(id)
- }
- },
- });
- }
- }
- }
- );
- },
- // #endif
- upImg(e) {
- const that = this;
- if (that.upFileLoding) {
- return
- }
- that.upFileLoding = true;
- setTimeout(() => {
- that.upFileLoding = false;
- }, 1000);
- upload({
- filename: ''
- }).then(data => {
- this.form.img = data[0].url;
- }).catch((err) => {
- console.log(err);
- })
- },
- ToIndex() {
- let obj = this;
- let ur = uni.getStorageSync('present') || '/pages/index/index';
- // 用于处理缓存bug
- if (ur == 'pages/product/product') {
- ur = '/pages/index/index';
- }
- uni.switchTab({
- url: ur,
- fail(e) {
- uni.navigateTo({
- url: ur,
- fail(e) {
- uni.navigateTo({
- url: '/pages/index/index'
- });
- }
- });
- }
- });
- },
- pushData() {
- const that = this;
- const da = that.form;
- // 判断是否已经提交过数据
- if (that.upDataLoding) {
- that.init();
- return
- }
- if (that.loding) {
- return;
- }
- if (!da.name) {
- uni.showModal({
- title: '提示',
- content: '请填写真实姓名',
- showCancel: false
- });
- return;
- }
- if (!da.card) {
- uni.showModal({
- title: '提示',
- content: '请填写身份证',
- showCancel: false
- });
- return;
- }
- // if (!da.img) {
- // uni.showModal({
- // title: '提示',
- // content: '请选择图片',
- // showCancel: false
- // });
- // return;
- // }
- const data = {
- // cidimg: da.img,
- rname: da.name,
- cid: da.card
- };
- uni.showLoading({
- title: '审核中',
- mask: true
- });
- that.loding = true;
- // 上传
- realName(data)
- .then(e => {
- // 判断是否已经上传过数据
- that.upDataLoding = true;
- that.getYz();
- that.loding = false;
- console.log(e);
- })
- .catch(e => {
- that.loding = false;
- console.log(e);
- uni.hideLoading();
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .content {
- height: 100%;
- padding: 0 30rpx;
- }
- .list {
- border-radius: 20rpx;
- overflow: hidden;
- .item:nth-child(1) {
- border-bottom: 1px solid #e4e7ed;
- }
- .item {
- padding: 30rpx 0;
- }
- .input {
- text-align: right;
- flex-grow: 1;
- }
- }
- .add-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 690rpx;
- height: 80rpx;
- margin: 60rpx auto;
- font-size: 32rpx;
- color: #fff;
- background: #ff0000;
- border-radius: 10rpx;
- // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
- }
- .bgimg {
- text-align: center;
- width: 1200rpx;
- margin-left: -260rpx;
- height: 400rpx;
- background: #ff0000;
- border-bottom-right-radius: 999999rpx;
- border-bottom-left-radius: 999999rpx;
- .img {
- width: 400rpx;
- margin-top: 50rpx;
- }
- }
- .titleType {
- margin-top: -250rpx !important;
- text-align: center;
- color: #FFF;
- font-size: 32rpx;
- text-shadow: 4rpx 4rpx 6rpx #666;
- letter-spacing: 0.5em;
- font-weight: bold;
- }
- .userBox {
- box-shadow: 0px 2px 16px 1px rgba(89, 89, 89, 0.24) !important;
- background-color: white !important;
- margin-top: 30rpx;
- padding: 0 30rpx;
- .inputText {
- width: 100%;
- }
- .title {
- width: 150rpx;
- }
- }
- .imglist /deep/ * {
- margin-left: auto !important;
- margin-right: auto !important;
- }
- </style>
|