feat(identity): align auth flow with reference theme
This commit is contained in:
@@ -1,123 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* User center panel: cloud identity verification.
|
||||
*
|
||||
* Visible UI mirrors the reference theme (Zibll) `官方认证` panel:
|
||||
* a `colorful-bg c-blue zib-widget` hero card with centered badge icon,
|
||||
* panel title and a left-aligned status block. The cloud-apply modal flow
|
||||
* lives in the `<template>` below and is driven by user-center-auth.js.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
/** User center identity certification panel. @package AKSRT */
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use AKSRT\User\AuthApply;
|
||||
use AKSRT\Identity\EvidenceService;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
||||
$snapshot = class_exists(AuthApply::class) ? AuthApply::snapshot($user_id) : [
|
||||
'status' => '',
|
||||
'stage' => '',
|
||||
'can_apply' => false,
|
||||
'verified' => false,
|
||||
'info' => [],
|
||||
'apply' => [],
|
||||
'active' => null,
|
||||
'latest' => null,
|
||||
'poll_interval' => 5,
|
||||
];
|
||||
$settings = class_exists(AuthApply::class) ? AuthApply::settings() : ['enabled' => false, 'allow_apply' => false];
|
||||
$status = (string) ($snapshot['status'] ?? '');
|
||||
$snapshot = AuthApply::snapshot($user_id);
|
||||
$settings = AuthApply::settings();
|
||||
$info = is_array($snapshot['info'] ?? null) ? $snapshot['info'] : [];
|
||||
$active = is_array($snapshot['active'] ?? null) ? $snapshot['active'] : [];
|
||||
$latest = is_array($snapshot['latest'] ?? null) ? $snapshot['latest'] : [];
|
||||
$stage = sanitize_key((string) ($active['status'] ?? ''));
|
||||
$locks_application = $stage !== '';
|
||||
$reason = (string) (($latest['review_note'] ?? '') ?: ($latest['provider_result_summary'] ?? ''));
|
||||
$application = is_array($snapshot['application'] ?? null) ? $snapshot['application'] : [];
|
||||
$status = (string) ($snapshot['status'] ?? '');
|
||||
$can_apply = !empty($snapshot['can_apply']);
|
||||
$config = [
|
||||
'restBase' => untrailingslashit(rest_url('aksrt/v1/identity/applications')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
'currentUuid' => $locks_application ? (string) ($active['application_uuid'] ?? '') : '',
|
||||
'currentStage' => $locks_application ? $stage : '',
|
||||
'provider' => sanitize_key((string) ($settings['provider'] ?? 'aliyun')),
|
||||
'allowManual' => !empty($settings['allow_manual_fallback']),
|
||||
'pollInterval' => max(5, (int) ($snapshot['poll_interval'] ?? 5)),
|
||||
'snapshot' => class_exists(AuthApply::class) ? AuthApply::snapshot_view($user_id) : [],
|
||||
];
|
||||
$auth_icon = '<i class="fa fas fa-id-badge" aria-hidden="true"></i>';
|
||||
$config = [
|
||||
'restBase' => untrailingslashit(rest_url('aksrt/v1/identity/applications')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
];
|
||||
?>
|
||||
<div class="colorful-bg c-blue flex jc zib-widget" style="padding: 40px 20px;" data-identity-root data-identity-config="<?php echo esc_attr(wp_json_encode($config)); ?>">
|
||||
<div class="colorful-make"></div>
|
||||
<div class="text-center">
|
||||
<div class="em4x"><?php echo $auth_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<div class="mt10 em14 padding-w10 font-bold mb40"><?php esc_html_e('官方认证', 'aksrt'); ?></div>
|
||||
|
||||
<?php if ($status === 'verified') : ?>
|
||||
<div class="text-left">
|
||||
<div class="mt10 em14 padding-w10 font-bold mb40"><?php echo esc_html(!empty($snapshot['verified']) ? __('我的认证信息', 'aksrt') : __('申请身份认证', 'aksrt')); ?></div>
|
||||
<div class="text-left" data-auth-summary>
|
||||
<?php if (!empty($snapshot['verified'])) : ?>
|
||||
<div class="em12"><?php echo $auth_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><b class="ml6"><?php echo esc_html((string) ($info['name'] ?? __('官方认证', 'aksrt'))); ?></b></div>
|
||||
<?php if (!empty($info['time'])) : ?>
|
||||
<div class="muted-2-color mt10"><?php printf(esc_html__('认证时间:%s', 'aksrt'), esc_html((string) $info['time'])); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="text-left">
|
||||
<?php if (!empty($info['desc'])) : ?><div class="muted-2-color mt10"><?php echo esc_html((string) $info['desc']); ?></div><?php endif; ?>
|
||||
<?php if (!empty($info['time'])) : ?><div class="muted-2-color mt10"><?php printf(esc_html__('认证时间:%s', 'aksrt'), esc_html((string) $info['time'])); ?></div><?php endif; ?>
|
||||
<?php elseif ($status === 'pending') : ?>
|
||||
<div class="c-red mb10"><?php esc_html_e('您的申请正在审核中,请耐心等待', 'aksrt'); ?></div>
|
||||
<div><?php echo $auth_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><b class="ml3"><?php echo esc_html((string) ($application['public_name'] ?? '')); ?></b></div>
|
||||
<?php if (!empty($application['description'])) : ?><div class="muted-2-color mt10"><?php echo esc_html((string) $application['description']); ?></div><?php endif; ?>
|
||||
<?php if (!empty($application['manual_reason'])) : ?><div class="muted-2-color mt10"><?php printf(esc_html__('申请说明:%s', 'aksrt'), esc_html((string) $application['manual_reason'])); ?></div><?php endif; ?>
|
||||
<?php if (!empty($application['created_at'])) : ?><div class="muted-2-color mt10"><?php printf(esc_html__('申请时间:%s', 'aksrt'), esc_html((string) $application['created_at'])); ?></div><?php endif; ?>
|
||||
<?php $evidence_items = (new EvidenceService())->items($application); ?>
|
||||
<?php if ($evidence_items) : ?><div class="mt20 flex" style="gap:8px;flex-wrap:wrap;"><?php foreach ($evidence_items as $item) : ?><a href="<?php echo esc_url($item['url']); ?>" target="_blank" rel="noopener noreferrer"><img src="<?php echo esc_url($item['thumbnail_url']); ?>" alt="<?php esc_attr_e('身份认证证明材料', 'aksrt'); ?>" style="width:64px;height:64px;object-fit:cover;border-radius:4px;"></a><?php endforeach; ?></div><?php endif; ?>
|
||||
<?php else : ?>
|
||||
<div class="em12 mb10"><?php echo $auth_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><b class="ml6"><?php esc_html_e('申请认证', 'aksrt'); ?></b></div>
|
||||
<?php if ($reason !== '') : ?>
|
||||
<div class="c-red mb10"><i class="fa mr6 fa-info-circle" aria-hidden="true"></i><?php echo esc_html($reason); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($can_apply && !empty($settings['desc'])) : ?><div class="muted-color mb20"><?php echo nl2br(esc_html((string) $settings['desc'])); ?></div><?php endif; ?>
|
||||
<?php if ($can_apply) : ?>
|
||||
<div class="muted-color mb20"><?php echo esc_html((string) ($settings['desc'] ?? __('个人认证将进行人脸实人核身,企业认证还会核验企业主体与法定代表人关系。', 'aksrt'))); ?></div>
|
||||
<button type="button" class="but jb-blue padding-lg btn-block mt20" data-auth-modal-open><?php echo $locks_application ? esc_html__('查看认证进度', 'aksrt') : esc_html__('申请认证', 'aksrt'); ?></button>
|
||||
<button type="button" class="but jb-blue padding-lg btn-block mt20" data-auth-modal-open><?php esc_html_e('申请认证', 'aksrt'); ?></button>
|
||||
<?php else : ?>
|
||||
<div class="c-red"><i class="fa mr6 fa-info-circle" aria-hidden="true"></i><?php esc_html_e('抱歉!暂时不能申请身份认证', 'aksrt'); ?></div>
|
||||
<?php if (!empty($settings['disable_desc'])) : ?>
|
||||
<div class="muted-color mt20"><?php echo nl2br(esc_html((string) $settings['disable_desc'])); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (empty($settings['allow_apply']) && !empty($settings['disable_desc'])) : ?><div class="muted-color mt20"><?php echo nl2br(esc_html((string) $settings['disable_desc'])); ?></div><?php elseif (empty($snapshot['level_ok']) && !empty($snapshot['minimum_level'])) : ?><div class="muted-color mt20"><?php printf(esc_html__('由于您的等级较低,暂时无法申请身份认证,请升级到 %s 之后再来申请。', 'aksrt'), esc_html(\AKSRT\User\Level::get_level_name((int) $snapshot['minimum_level']))); ?></div><?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($can_apply) : ?>
|
||||
<template data-auth-modal-template>
|
||||
<div class="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="fa fas fa-id-badge" aria-hidden="true"></i></span><strong id="uc-auth-modal-title"><?php esc_html_e('身份认证', 'aksrt'); ?></strong></div>
|
||||
<div><span><?php echo $auth_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span><strong id="uc-auth-modal-title"><?php esc_html_e('申请身份认证', 'aksrt'); ?></strong></div>
|
||||
<button type="button" class="aksrt-modal__close" data-aksrt-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
|
||||
</div>
|
||||
<div class="aksrt-modal__body uc-auth-modal__body">
|
||||
<div data-auth-status <?php echo !$locks_application ? 'hidden' : ''; ?>>
|
||||
<div class="uc-auth-pending">
|
||||
<span><i class="fa 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 $locks_application ? 'hidden' : ''; ?>>
|
||||
<label class="uc-auth-field"><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>
|
||||
<div class="uc-auth-enterprise-fields" data-enterprise-fields hidden>
|
||||
<label class="uc-auth-field"><span><?php esc_html_e('企业全称', 'aksrt'); ?></span><input class="form-control" name="company_name" maxlength="191"></label>
|
||||
<label class="uc-auth-field"><span><?php esc_html_e('统一社会信用代码', 'aksrt'); ?></span><input class="form-control" name="company_code" maxlength="32" autocomplete="off"></label>
|
||||
</div>
|
||||
<label class="uc-auth-field"><span data-auth-person-label><?php esc_html_e('真实姓名', 'aksrt'); ?></span><input class="form-control" name="person_name" maxlength="50" required autocomplete="name"></label>
|
||||
<label class="uc-auth-field"><span data-auth-id-label><?php esc_html_e('身份证号码', 'aksrt'); ?></span><input class="form-control" name="id_number" maxlength="18" pattern="[0-9]{15}|[0-9]{17}[0-9Xx]" required autocomplete="off"></label>
|
||||
<label class="uc-auth-consent"><input type="checkbox" name="consent" value="1" required><span><?php esc_html_e('我同意为身份认证目的将必要身份信息提交给站点当前配置的云服务商;站点不保存人脸素材,并仅保留脱敏结果。', 'aksrt'); ?></span></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 uc-auth-submit"><?php esc_html_e('创建认证会话', 'aksrt'); ?></button>
|
||||
<form class="aksrt-user-auth-form uc-auth-form" data-auth-create enctype="multipart/form-data">
|
||||
<label class="uc-auth-field"><span><?php esc_html_e('认证身份', 'aksrt'); ?></span><input class="form-control" name="name" minlength="4" maxlength="16" required placeholder="<?php esc_attr_e('请输入身份名称', 'aksrt'); ?>"></label>
|
||||
<label class="uc-auth-field"><span><?php esc_html_e('身份简介', 'aksrt'); ?></span><textarea class="form-control" name="description" rows="2" placeholder="<?php esc_attr_e('请输入申请的身份简介', 'aksrt'); ?>"></textarea></label>
|
||||
<label class="uc-auth-field"><span><?php esc_html_e('申请说明', 'aksrt'); ?></span><textarea class="form-control" name="message" rows="2" placeholder="<?php esc_attr_e('请输入申请缘由及说明', 'aksrt'); ?>"></textarea></label>
|
||||
<label class="uc-auth-field"><span><?php esc_html_e('证明材料(选填)', 'aksrt'); ?></span><input class="form-control" type="file" name="evidence[]" accept="image/gif,image/jpeg,image/png" multiple></label>
|
||||
<small class="muted-2-color"><?php esc_html_e('最多上传 3 张图片,单张不超过 2MB。材料仅本人和认证审核管理员可查看。', 'aksrt'); ?></small>
|
||||
<button type="submit" class="btn-primary uc-auth-submit"><?php esc_html_e('确认提交', 'aksrt'); ?></button>
|
||||
<div class="uc-auth-form__message" 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>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user