better-staridc-MNBT
1<?php
2/**
3 * 管理员端 - 实名认证审核列表
4 */
5if (!defined('IN_CRONLITE')) {
6 exit;
7}
8$title = '实名认证审核';
9mnbt_admin_include('head');
10$statusMap = [
11 'pending' => ['待审核', 'warning'],
12 'approved' => ['已通过', 'success'],
13 'rejected' => ['已驳回', 'danger'],
14];
15?>
16<div class="container-fluid p-t-15">
17 <div class="card">
18 <div class="card-header">
19 <h4 style="display:inline-block">实名认证审核</h4>
20 <span class="float-right">
21 <select class="form-control form-control-sm" id="fStatus" style="display:inline-block;width:120px;">
22 <option value="">全部状态</option>
23 <option value="pending">待审核</option>
24 <option value="approved">已通过</option>
25 <option value="rejected">已驳回</option>
26 </select>
27 <input type="text" class="form-control form-control-sm" id="fKeyword" placeholder="用户名 / 姓名" style="display:inline-block;width:160px;">
28 <button class="btn btn-primary btn-sm" id="btnSearch"><i class="mdi mdi-magnify"></i> 查询</button>
29 </span>
30 </div>
31 <div class="card-body">
32 <table class="table table-hover table-striped text-center">
33 <thead>
34 <tr>
35 <th>ID</th>
36 <th>用户名</th>
37 <th>姓名</th>
38 <th>手机号</th>
39 <th>身份证号</th>
40 <th>状态</th>
41 <th>备注</th>
42 <th>提交时间</th>
43 <th>操作</th>
44 </tr>
45 </thead>
46 <tbody id="tbList">
47 <tr><td colspan="9" style="color:#999">加载中…</td></tr>
48 </tbody>
49 </table>
50 <div class="text-center" id="pgWrap" style="margin-top:10px;"></div>
51 </div>
52 </div>
53</div>
54
55<!-- 驳回原因 Modal -->
56<div class="modal fade" id="rejectModal" tabindex="-1">
57 <div class="modal-dialog modal-sm">
58 <div class="modal-content">
59 <div class="modal-header">
60 <h5 class="modal-title">驳回认证</h5>
61 <button type="button" class="close" data-dismiss="modal">×</button>
62 </div>
63 <div class="modal-body">
64 <input type="hidden" id="rejectId">
65 <div class="form-group">
66 <label>驳回原因</label>
67 <textarea class="form-control" id="rejectNote" rows="3" placeholder="请填写驳回原因,将展示给用户"></textarea>
68 </div>
69 </div>
70 <div class="modal-footer">
71 <button class="btn btn-secondary" data-dismiss="modal">取消</button>
72 <button class="btn btn-danger" id="btnRejectOk">确认驳回</button>
73 </div>
74 </div>
75 </div>
76</div>
77
78<script>
79var curPage = 1;
80var statusMap = {pending:['待审核','warning'], approved:['已通过','success'], rejected:['已驳回','danger']};
81
82function loadList(page) {
83 curPage = page || 1;
84 $.post('ajax.php', {
85 gn: 'realname_admin_list',
86 page: curPage,
87 per_page: 20,
88 status: $('#fStatus').val(),
89 keyword: $('#fKeyword').val()
90 }, function (res) {
91 try { res = typeof res === 'string' ? JSON.parse(res) : res; } catch (e) {}
92 if (!res || res.code !== 'ok') { alert(res && res.code ? res.code : '加载失败'); return; }
93 var html = '';
94 if (!res.items || !res.items.length) {
95 html = '<tr><td colspan="9" style="color:#999">暂无数据</td></tr>';
96 } else {
97 $.each(res.items, function (i, it) {
98 var st = statusMap[it.status] || [it.status, 'secondary'];
99 html += '<tr>'
100 + '<td>' + it.id + '</td>'
101 + '<td>' + it.username + '</td>'
102 + '<td>' + it.real_name + '</td>'
103 + '<td>' + it.phone + '</td>'
104 + '<td>' + it.id_card + '</td>'
105 + '<td><span class="badge badge-' + st[1] + '">' + st[0] + '</span></td>'
106 + '<td style="max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="' + (it.audit_note || '') + '">' + (it.audit_note || '') + '</td>'
107 + '<td>' + it.created_at + '</td>'
108 + '<td>'
109 + '<a class="btn btn-info btn-xs" href="plugin.php?p=realname&page=audit_detail&id=' + it.id + '">详情</a> ';
110 if (it.status === 'pending') {
111 html += '<button class="btn btn-success btn-xs" onclick="approve(' + it.id + ')">通过</button> ';
112 html += '<button class="btn btn-danger btn-xs" onclick="openReject(' + it.id + ')">驳回</button>';
113 }
114 html += '</td></tr>';
115 });
116 }
117 $('#tbList').html(html);
118 // 分页
119 var pg = '';
120 if (res.pages > 1) {
121 pg = '<nav><ul class="pagination pagination-sm" style="justify-content:center">';
122 for (var i = 1; i <= res.pages; i++) {
123 pg += '<li class="page-item ' + (i === curPage ? 'active' : '') + '"><a class="page-link" href="javascript:;" onclick="loadList(' + i + ')">' + i + '</a></li>';
124 }
125 pg += '</ul></nav>';
126 }
127 $('#pgWrap').html(pg);
128 });
129}
130
131function approve(id) {
132 if (!confirm('确认通过该认证?')) return;
133 $.post('ajax.php', { gn: 'realname_admin_approve', id: id }, function (res) {
134 try { res = typeof res === 'string' ? JSON.parse(res) : res; } catch (e) {}
135 if (res && res.code === 'ok') { alert('已通过'); loadList(); } else { alert(res && res.code ? res.code : '操作失败'); }
136 });
137}
138
139function openReject(id) {
140 $('#rejectId').val(id);
141 $('#rejectNote').val('');
142 $('#rejectModal').modal('show');
143}
144
145$('#btnRejectOk').on('click', function () {
146 var id = $('#rejectId').val();
147 var note = $('#rejectNote').val();
148 if (!note) { alert('请填写驳回原因'); return; }
149 $.post('ajax.php', { gn: 'realname_admin_reject', id: id, note: note }, function (res) {
150 try { res = typeof res === 'string' ? JSON.parse(res) : res; } catch (e) {}
151 if (res && res.code === 'ok') { $('#rejectModal').modal('hide'); alert('已驳回'); loadList(); } else { alert(res && res.code ? res.code : '操作失败'); }
152 });
153});
154
155$('#btnSearch').on('click', function () { loadList(1); });
156loadList(1);
157</script>
158<?php mnbt_admin_include('foot'); ?>