feat: 接入腾讯云与阿里云实人认证

This commit is contained in:
kate522 committed 2026-08-01 13:21:21 +08:00
1 parent 92e445dbd4
commit 4de67311cc
37 files changed
+2410 -1158

No files matched your search

+1 -1
View File
@@ -415,7 +415,7 @@ if (!function_exists('aksrt_resolve_allow_view_rule')) :
}
}
if (!$ok && $need_auth) {
$verify = sanitize_key((string) get_user_meta($user_id, 'aksrt_user_verify_status', true));
$verify = class_exists('\\AKSRT\\User\\AuthApply') && \AKSRT\User\AuthApply::is_verified($user_id) ? 'verified' : '';
if (in_array($verify, ['verified', '1', 'yes'], true)) {
$ok = true;
}
@@ -1,8 +1,6 @@
<?php
/**
* User center panel: official certification.
*
* Zibll parity: compact center card + in-place application modal.
* User center panel: cloud identity verification.
*
* @package AKSRT
*/
@@ -14,101 +12,92 @@ use AKSRT\User\AuthApply;
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
$settings = class_exists(AuthApply::class) ? AuthApply::settings() : ['enabled' => false, 'allow_apply' => false];
$status = $user_id > 0 && class_exists(AuthApply::class) ? AuthApply::get_status($user_id) : '';
$info = $user_id > 0 && class_exists(AuthApply::class) ? AuthApply::get_auth_info($user_id) : [];
$apply = $user_id > 0 && class_exists(AuthApply::class) ? AuthApply::get_apply_payload($user_id) : [];
$reason = $user_id > 0 && class_exists(AuthApply::class) ? (string) get_user_meta($user_id, AuthApply::REASON_META, true) : '';
$evidence = class_exists(AuthApply::class) ? AuthApply::get_evidence_items($apply, $user_id) : [];
$type_labels = [];
foreach ((array) ($settings['types'] ?? []) as $type) {
$type_labels[(string) ($type['slug'] ?? '')] = (string) ($type['label'] ?? '');
}
$apply_type = sanitize_key((string) ($apply['type'] ?? ''));
$status = class_exists(AuthApply::class) ? AuthApply::get_status($user_id) : '';
$info = class_exists(AuthApply::class) ? AuthApply::get_auth_info($user_id) : [];
$apply = class_exists(AuthApply::class) ? AuthApply::get_apply_payload($user_id) : [];
$record = is_array($apply['_application'] ?? null) ? $apply['_application'] : [];
$stage = sanitize_key((string) ($record['status'] ?? ''));
$reason = (string) ($record['review_note'] ?? $record['provider_result_summary'] ?? '');
$can_apply = !empty($settings['enabled']) && !empty($settings['allow_apply']) && $status !== 'verified';
$config = [
'restBase' => untrailingslashit(rest_url('aksrt/v1/identity/applications')),
'nonce' => wp_create_nonce('wp_rest'),
'currentUuid' => (string) ($record['application_uuid'] ?? ''),
'currentStage' => $stage,
'allowManual' => !empty($settings['allow_manual_fallback']),
];
?>
<div class="aksrt-user-auth-panel uc-auth-panel">
<?php if ($status === 'verified') :
$name = (string) ($info['name'] ?? $apply['name'] ?? __('官方认证', 'aksrt'));
$desc = (string) ($info['desc'] ?? $apply['desc'] ?? '');
$time = (string) ($info['time'] ?? get_user_meta($user_id, 'aksrt_user_verify_reviewed_at', true));
?>
<div class="uc-auth-card uc-auth-card--verified">
<span class="uc-auth-card__art"><i class="fas fa-check-circle" aria-hidden="true"></i></span>
<div class="uc-auth-card__content">
<small><?php esc_html_e('已通过官方认证', 'aksrt'); ?></small>
<h2><?php echo esc_html($name); ?></h2>
<?php if ($desc !== '') : ?><p><?php echo esc_html($desc); ?></p><?php endif; ?>
<?php if ($time !== '') : ?><time><?php printf(esc_html__('认证时间:%s', 'aksrt'), esc_html($time)); ?></time><?php endif; ?>
</div>
</div>
<?php else : ?>
<div class="uc-auth-card">
<span class="uc-auth-card__art"><i class="fas fa-id-badge" aria-hidden="true"></i></span>
<div class="uc-auth-card__content">
<small><?php esc_html_e('身份权益', 'aksrt'); ?></small>
<h2><?php esc_html_e('官方认证', 'aksrt'); ?></h2>
<p><?php echo esc_html((string) ($settings['desc'] ?? __('认证后将展示官方身份标识。', 'aksrt'))); ?></p>
<?php if (empty($settings['allow_apply'])) : ?>
<div class="uc-auth-card__notice"><?php echo wp_kses_post(nl2br(esc_html((string) ($settings['disable_desc'] ?? __('暂时不能申请身份认证', 'aksrt'))))); ?></div>
<?php elseif ($blocked_level) : ?>
<div class="uc-auth-card__notice"><?php printf(esc_html__('达到 %s 后即可申请', 'aksrt'), esc_html(class_exists('\AKSRT\User\Level') ? \AKSRT\User\Level::get_level_name($limit) : ('LV' . $limit))); ?></div>
<?php elseif (in_array($status, ['rejected', 'cancelled'], true) && $reason !== '') : ?>
<div class="uc-auth-card__notice">
<strong><?php echo $status === 'cancelled' ? esc_html__('认证已取消', 'aksrt') : esc_html__('上次申请未通过', 'aksrt'); ?></strong><br>
<?php echo nl2br(esc_html($reason)); ?>
</div>
<?php endif; ?>
<?php if ($can_apply) : ?>
<button type="button" class="btn-primary uc-auth-apply-open" data-auth-modal-open>
<?php echo $status === 'pending' ? esc_html__('查看申请进度', 'aksrt') : esc_html__('申请认证', 'aksrt'); ?>
</button>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="aksrt-user-auth-panel uc-auth-panel" data-identity-root data-identity-config="<?php echo esc_attr(wp_json_encode($config)); ?>">
<?php if ($status === 'verified') : ?>
<div class="uc-auth-card uc-auth-card--verified">
<span class="uc-auth-card__art"><i class="fas fa-check-circle" aria-hidden="true"></i></span>
<div class="uc-auth-card__content">
<small><?php esc_html_e('已通过云端实人认证', 'aksrt'); ?></small>
<h2><?php echo esc_html((string) ($info['name'] ?? __('官方认证', 'aksrt'))); ?></h2>
<?php if (!empty($info['desc'])) : ?><p><?php echo esc_html((string) $info['desc']); ?></p><?php endif; ?>
<?php if (!empty($info['time'])) : ?><time><?php printf(esc_html__('认证时间:%s', 'aksrt'), esc_html((string) $info['time'])); ?></time><?php endif; ?>
</div>
</div>
<?php else : ?>
<div class="uc-auth-card">
<span class="uc-auth-card__art"><i class="fas fa-id-badge" aria-hidden="true"></i></span>
<div class="uc-auth-card__content">
<small><?php esc_html_e('身份权益', 'aksrt'); ?></small>
<h2><?php esc_html_e('官方认证', 'aksrt'); ?></h2>
<p><?php echo esc_html((string) ($settings['desc'] ?? __('个人认证将进行人脸实人核身,企业认证还会核验企业主体与法定代表人关系。', 'aksrt'))); ?></p>
<?php if (!$can_apply) : ?>
<div class="uc-auth-card__notice"><?php echo wp_kses_post(nl2br(esc_html((string) ($settings['disable_desc'] ?? __('暂时不能申请身份认证', 'aksrt'))))); ?></div>
<?php elseif ($reason !== '') : ?>
<div class="uc-auth-card__notice"><?php echo nl2br(esc_html($reason)); ?></div>
<?php endif; ?>
<?php if ($can_apply) : ?><button type="button" class="btn-primary" data-auth-modal-open><?php echo $status === 'pending' ? esc_html__('查看认证进度', 'aksrt') : esc_html__('开始认证', 'aksrt'); ?></button><?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ($can_apply) : ?>
<div class="aksrt-modal uc-auth-modal" id="uc-auth-modal" aria-hidden="true">
<div class="aksrt-modal__overlay" data-auth-modal-close></div>
<div class="aksrt-modal__box uc-auth-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="uc-auth-modal-title">
<div class="aksrt-modal__header uc-auth-modal__header">
<div><span><i class="fas fa-id-badge" aria-hidden="true"></i></span><strong id="uc-auth-modal-title"><?php esc_html_e('申请身份认证', 'aksrt'); ?></strong></div>
<button type="button" class="aksrt-modal__close" data-auth-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
</div>
<div class="aksrt-modal__body uc-auth-modal__body">
<?php if ($status === 'pending') : ?>
<div class="uc-auth-pending">
<span><i class="fas fa-hourglass-half" aria-hidden="true"></i></span>
<h3><?php esc_html_e('您的申请正在审核中', 'aksrt'); ?></h3>
<p><?php esc_html_e('请耐心等待,审核结果会通过消息中心通知。', 'aksrt'); ?></p>
</div>
<div class="uc-auth-apply-detail">
<dl><dt><?php esc_html_e('认证身份', 'aksrt'); ?></dt><dd><?php echo esc_html((string) ($apply['name'] ?? '')); ?></dd></dl>
<?php if ($apply_type !== '') : ?><dl><dt><?php esc_html_e('认证类型', 'aksrt'); ?></dt><dd><?php echo esc_html($type_labels[$apply_type] ?? $apply_type); ?></dd></dl><?php endif; ?>
<?php if (!empty($apply['desc'])) : ?><dl><dt><?php esc_html_e('身份简介', 'aksrt'); ?></dt><dd><?php echo esc_html((string) $apply['desc']); ?></dd></dl><?php endif; ?>
<?php if (!empty($apply['msg'])) : ?><dl><dt><?php esc_html_e('申请说明', 'aksrt'); ?></dt><dd><?php echo esc_html((string) $apply['msg']); ?></dd></dl><?php endif; ?>
<?php if (!empty($apply['time'])) : ?><dl><dt><?php esc_html_e('申请时间', 'aksrt'); ?></dt><dd><?php echo esc_html((string) $apply['time']); ?></dd></dl><?php endif; ?>
</div>
<?php if ($evidence !== []) : ?>
<div class="aksrt-user-auth-panel__imgs uc-auth-proof-list"><?php foreach ($evidence as $item) : ?><div class="preview-item"><img src="<?php echo esc_url((string) $item['thumbnail_url']); ?>" alt="" loading="lazy"></div><?php endforeach; ?></div>
<?php endif; ?>
<button type="button" class="btn-primary uc-auth-modal__confirm" data-auth-modal-close><?php esc_html_e('确定', 'aksrt'); ?></button>
<?php else : ?>
<form class="aksrt-user-auth-form uc-auth-form" enctype="multipart/form-data">
<label><span><?php esc_html_e('认证类型', 'aksrt'); ?></span><select class="form-control" name="type" required><?php foreach ((array) ($settings['types'] ?? []) as $type) : ?><option value="<?php echo esc_attr((string) $type['slug']); ?>"><?php echo esc_html((string) $type['label']); ?></option><?php endforeach; ?></select></label>
<label><span><?php esc_html_e('认证身份', 'aksrt'); ?></span><input type="text" class="form-control" name="name" required minlength="4" maxlength="16" placeholder="<?php esc_attr_e('请输入 4-16 个字符', 'aksrt'); ?>"></label>
<label><span>真实姓名</span><input type="text" class="form-control" name="real_name" maxlength="50" placeholder="认证方式要求时必须填写"></label>
<label><span><?php esc_html_e('身份简介', 'aksrt'); ?></span><textarea class="form-control" name="desc" rows="3" maxlength="300" placeholder="<?php esc_attr_e('认证通过后公开展示的身份说明', 'aksrt'); ?>"></textarea></label>
<label><span><?php esc_html_e('申请说明', 'aksrt'); ?></span><textarea class="form-control" name="msg" rows="3" maxlength="500" placeholder="<?php esc_attr_e('说明申请缘由,便于管理员审核', 'aksrt'); ?>"></textarea></label>
<label class="uc-auth-upload"><span><?php esc_html_e('证明材料', 'aksrt'); ?></span><input type="file" name="image[]" accept="image/jpeg,image/png,image/gif,image/webp" multiple data-auth-files><small><?php esc_html_e('最多上传 3 张图片,单张不超过 2MB(可选)。', 'aksrt'); ?></small><div class="uc-auth-upload__previews" data-auth-previews></div></label>
<?php wp_nonce_field('aksrt_user_auth_apply', '_wpnonce', false); ?>
<input type="hidden" name="action" value="aksrt_user_auth_apply">
<button type="submit" class="btn-primary uc-auth-submit"><i class="fas fa-check" aria-hidden="true"></i><?php esc_html_e('确认提交', 'aksrt'); ?></button>
<div class="uc-auth-form__message" data-auth-message role="status"></div>
</form>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ($can_apply) : ?>
<div class="aksrt-modal uc-auth-modal" id="uc-auth-modal" aria-hidden="true">
<div class="aksrt-modal__overlay" data-auth-modal-close></div>
<div class="aksrt-modal__box uc-auth-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="uc-auth-modal-title">
<div class="aksrt-modal__header uc-auth-modal__header">
<div><span><i class="fas fa-id-badge" aria-hidden="true"></i></span><strong id="uc-auth-modal-title"><?php esc_html_e('身份认证', 'aksrt'); ?></strong></div>
<button type="button" class="aksrt-modal__close" data-auth-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
</div>
<div class="aksrt-modal__body uc-auth-modal__body">
<div data-auth-status <?php echo $record === [] ? 'hidden' : ''; ?>>
<div class="uc-auth-pending">
<span><i class="fas fa-shield-alt" aria-hidden="true"></i></span>
<h3 data-auth-stage><?php echo esc_html($stage ?: __('准备认证', 'aksrt')); ?></h3>
<p data-auth-status-message><?php esc_html_e('认证结果以服务端向云服务商主动查询为准。', 'aksrt'); ?></p>
</div>
<a class="btn-primary" data-auth-continue target="_blank" rel="noopener noreferrer" hidden><?php esc_html_e('打开云端核身页面', 'aksrt'); ?></a>
<button type="button" class="btn-primary" data-auth-refresh><?php esc_html_e('刷新结果', 'aksrt'); ?></button>
<?php if (!empty($settings['allow_manual_fallback'])) : ?><button type="button" class="button" data-auth-manual-open hidden><?php esc_html_e('上传材料转人工审核', 'aksrt'); ?></button><?php endif; ?>
</div>
<form class="aksrt-user-auth-form uc-auth-form" data-auth-create <?php echo $record !== [] ? 'hidden' : ''; ?>>
<label><span><?php esc_html_e('认证类型', 'aksrt'); ?></span><select class="form-control" name="type" required><option value="personal"><?php esc_html_e('个人认证', 'aksrt'); ?></option><option value="enterprise"><?php esc_html_e('企业认证', 'aksrt'); ?></option></select></label>
<label><span><?php esc_html_e('公开认证名称', 'aksrt'); ?></span><input class="form-control" name="public_name" minlength="2" maxlength="64" required></label>
<label><span><?php esc_html_e('公开身份简介', 'aksrt'); ?></span><textarea class="form-control" name="public_desc" maxlength="300"></textarea></label>
<label><span><?php esc_html_e('真实姓名/法定代表人姓名', 'aksrt'); ?></span><input class="form-control" name="person_name" maxlength="50" required autocomplete="name"></label>
<label><span><?php esc_html_e('身份证号码', 'aksrt'); ?></span><input class="form-control" name="id_number" maxlength="20" required autocomplete="off"></label>
<div data-enterprise-fields hidden>
<label><span><?php esc_html_e('企业名称', 'aksrt'); ?></span><input class="form-control" name="company_name" maxlength="191"></label>
<label><span><?php esc_html_e('统一社会信用代码', 'aksrt'); ?></span><input class="form-control" name="company_code" maxlength="32"></label>
</div>
<label><input type="checkbox" name="consent" value="1" required> <?php esc_html_e('我同意为身份认证目的将必要身份信息提交给站点当前配置的云服务商;站点不保存人脸素材,并仅保留脱敏结果。', 'aksrt'); ?></label>
<input type="hidden" name="return_url" value="<?php echo esc_url(aksrt_get_user_center_tab_url('auth')); ?>">
<button type="submit" class="btn-primary"><?php esc_html_e('创建认证会话', 'aksrt'); ?></button>
<div data-auth-message role="status"></div>
</form>
<form data-auth-manual hidden enctype="multipart/form-data">
<label><span><?php esc_html_e('证明材料', 'aksrt'); ?></span><input type="file" name="evidence[]" accept="image/jpeg,image/png,image/webp" multiple required></label>
<small><?php esc_html_e('最多 3 张,单张不超过 2MB。材料仅本人和身份审核管理员可查看。', 'aksrt'); ?></small>
<button type="submit" class="btn-primary"><?php esc_html_e('提交人工审核', 'aksrt'); ?></button>
</form>
</div>
</div>
</div>
<?php endif; ?>
</div>