better-staridc-MNBT
1<?php
2/**
3 * qmzl_domain - 用户端信息模板管理页
4 *
5 * 信息模板用于域名注册时提交所有者实名信息(上游实名认证)。
6 * 支持:列表 / 创建 / 编辑 / 删除 / 提交实名认证(证件照片上传)。
7 */
8if (!defined('IN_CRONLITE')) exit;
9$mode = qmzl_mode();
10$qzCss = qmzl_asset_url('qmzl.css');
11$qzJs = qmzl_asset_url('qmzl.js');
12$qzMdi = mnbt_asset_url('css/materialdesignicons.min.css');
13$qzJq = mnbt_asset_url('js/jquery.min.js');
14$qzApi = qmzl_url(qmzl_route_prefix() . '/api');
15$qzAccUrl = qmzl_url(qmzl_route_prefix() . '/account');
16$qzIdxUrl = qmzl_url(qmzl_route_prefix());
17?>
18<!DOCTYPE html>
19<html lang="zh-CN">
20<head>
21<meta charset="UTF-8">
22<meta name="viewport" content="width=device-width, initial-scale=1.0">
23<title>信息模板 - 域名服务</title>
24<link rel="stylesheet" href="<?= htmlspecialchars($qzMdi, ENT_QUOTES, 'UTF-8') ?>">
25<link rel="stylesheet" href="<?= htmlspecialchars($qzCss, ENT_QUOTES, 'UTF-8') ?>">
26<style>
27body { margin: 0; background: var(--qz-bg); color: var(--qz-text); font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; padding: 24px 16px 48px; }
28.file-box { display: flex; align-items: center; gap: 10px; min-width: 0; }
29.file-name { font-size: 12px; color: var(--qz-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
30.qz-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
31.qz-nav a { display: inline-block; padding: 6px 14px; border-radius: 20px; font-size: 13px; background: #fff; border: 1px solid var(--qz-border); color: var(--qz-text-2); text-decoration: none; transition: all .15s; }
32.qz-nav a:hover { border-color: var(--qz-brand); color: var(--qz-brand); }
33
34/* 模板表单弹窗:加宽 + flex 行布局(避免 grid 重叠) */
35#qz-mask-form .qz-modal { max-width: 780px; }
36#qz-mask-form .qz-modal-body { padding: 20px 24px; }
37.f-rows { display: flex; flex-direction: column; gap: 14px; }
38.f-row { display: flex; gap: 20px; }
39.f-cell { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
40.f-cell--full { flex-basis: 100%; }
41@media (max-width: 640px) { .f-row { flex-direction: column; gap: 14px; } }
42</style>
43</head>
44<body>
45<div class="qz-wrap">
46
47 <div class="qz-head">
48 <h1>信息模板</h1>
49 <p>域名注册时需提交所有者实名信息,请先创建并完成实名认证。</p>
50 <div class="qz-nav" style="margin-top:12px;">
51 <a href="<?= htmlspecialchars($qzIdxUrl, ENT_QUOTES, 'UTF-8') ?>">域名注册</a>
52 <?php if ($mode === 'client'): ?>
53 <a href="<?= htmlspecialchars($qzAccUrl, ENT_QUOTES, 'UTF-8') ?>">云账号</a>
54 <?php endif; ?>
55 </div>
56 </div>
57
58 <?php if ($mode === 'client'): ?>
59 <div id="qz-tip-unbound" class="qz-tip qz-tip--warn" style="display:none;">
60 尚未绑定启明智联账号。<a href="<?= htmlspecialchars($qzAccUrl, ENT_QUOTES, 'UTF-8') ?>" style="color:var(--qz-brand);font-weight:600;">立即绑定</a>
61 </div>
62 <?php endif; ?>
63
64 <div class="qz-card">
65 <div class="qz-card-head">
66 <h3>模板列表</h3>
67 <button type="button" class="qz-btn qz-btn--sm" id="qz-btn-add"><span class="mdi mdi-plus"></span> 新建模板</button>
68 </div>
69 <div class="qz-card-body" id="qz-tpl-list">
70 <div class="qz-loading">加载中...</div>
71 </div>
72 </div>
73
74</div>
75
76<!-- 模板表单弹窗 -->
77<div class="qz-mask" id="qz-mask-form">
78 <div class="qz-modal">
79 <div class="qz-modal-head">
80 <h3 id="qz-form-title">新建模板</h3>
81 <button type="button" class="qz-modal-close" data-close>×</button>
82 </div>
83 <div class="qz-modal-body">
84 <input type="hidden" id="f-id" value="0">
85 <div class="f-rows">
86 <div class="f-row">
87 <div class="f-cell">
88 <label>模板类型 <span class="req">*</span></label>
89 <select class="qz-select" id="f-type">
90 <option value="personal">个人</option>
91 <option value="enterprise">企业</option>
92 </select>
93 </div>
94 <div class="f-cell">
95 <label>证件类型 <span class="req">*</span></label>
96 <select class="qz-select" id="f-idtype"></select>
97 </div>
98 </div>
99 <div class="f-row">
100 <div class="f-cell">
101 <label>所有者(中文)<span class="req">*</span></label>
102 <input type="text" class="qz-input" id="f-zh_owner" maxlength="120">
103 <span class="qz-hint">个人填姓名,企业填公司名</span>
104 </div>
105 <div class="f-cell">
106 <label>联系人全名(中文)<span class="req">*</span></label>
107 <input type="text" class="qz-input" id="f-zh_all_name" maxlength="120">
108 </div>
109 </div>
110 <div class="f-row">
111 <div class="f-cell">
112 <label>所有者(英文/拼音大写)<span class="req">*</span></label>
113 <input type="text" class="qz-input" id="f-en_owner" maxlength="120" placeholder="ZHANG SAN">
114 </div>
115 <div class="f-cell">
116 <label>联系人姓氏(英文)<span class="req">*</span></label>
117 <input type="text" class="qz-input" id="f-en_last_name" maxlength="60" placeholder="ZHANG">
118 </div>
119 </div>
120 <div class="f-row">
121 <div class="f-cell">
122 <label>联系人名字(英文)<span class="req">*</span></label>
123 <input type="text" class="qz-input" id="f-en_first_name" maxlength="60" placeholder="SAN">
124 </div>
125 <div class="f-cell">
126 <label>电子邮箱 <span class="req">*</span></label>
127 <input type="email" class="qz-input" id="f-email" maxlength="120">
128 </div>
129 </div>
130 <div class="f-row">
131 <div class="f-cell">
132 <label>手机号码 <span class="req">*</span></label>
133 <input type="text" class="qz-input" id="f-phone" maxlength="30">
134 </div>
135 <div class="f-cell">
136 <label>证件号码 <span class="req">*</span></label>
137 <input type="text" class="qz-input" id="f-idnum" maxlength="60">
138 </div>
139 </div>
140 <div class="f-row">
141 <div class="f-cell">
142 <label>邮政编码</label>
143 <input type="text" class="qz-input" id="f-postal_code" maxlength="20" value="">
144 </div>
145 <div class="f-cell">
146 <label>国家代码</label>
147 <input type="text" class="qz-input" id="f-country" maxlength="10" value="CN">
148 </div>
149 </div>
150 <div class="f-row">
151 <div class="f-cell f-cell--full">
152 <label>中文地址 <span class="req">*</span></label>
153 <input type="text" class="qz-input" id="f-zh_address" maxlength="255" placeholder="省市区 + 详细地址">
154 </div>
155 </div>
156 <div class="f-row">
157 <div class="f-cell f-cell--full">
158 <label>英文地址(拼音大写)<span class="req">*</span></label>
159 <input type="text" class="qz-input" id="f-en_address" maxlength="255" placeholder="XXX ROAD, XXX DISTRICT, BEIJING, CHINA">
160 </div>
161 </div>
162 <div class="f-row">
163 <div class="f-cell f-cell--full">
164 <label>证件正面照片 <span class="req">*</span></label>
165 <div class="file-box">
166 <label class="qz-btn qz-btn--ghost qz-btn--sm" style="cursor:pointer;flex-shrink:0;">选择文件<input type="file" id="f-img_front" accept="image/*" style="display:none;"></label>
167 <span class="file-name" id="f-img_front-name">未选择</span>
168 </div>
169 </div>
170 </div>
171 <div class="f-row">
172 <div class="f-cell f-cell--full">
173 <label>证件反面照片(可选)</label>
174 <div class="file-box">
175 <label class="qz-btn qz-btn--ghost qz-btn--sm" style="cursor:pointer;flex-shrink:0;">选择文件<input type="file" id="f-img_back" accept="image/*" style="display:none;"></label>
176 <span class="file-name" id="f-img_back-name">未选择</span>
177 </div>
178 </div>
179 </div>
180 </div>
181 </div>
182 <div class="qz-modal-foot">
183 <button type="button" class="qz-btn qz-btn--ghost" data-close>取消</button>
184 <button type="button" class="qz-btn" id="qz-btn-save"><span class="mdi mdi-content-save"></span> 保存</button>
185 </div>
186 </div>
187</div>
188
189<!-- 实名认证弹窗 -->
190<div class="qz-mask" id="qz-mask-cert">
191 <div class="qz-modal" style="max-width:440px;">
192 <div class="qz-modal-head">
193 <h3>提交实名认证</h3>
194 <button type="button" class="qz-modal-close" data-close>×</button>
195 </div>
196 <div class="qz-modal-body">
197 <input type="hidden" id="c-id" value="0">
198 <div class="qz-tip">提交证件照片进行实名认证,审核通过后(状态为“已认证”)方可注册域名。</div>
199 <div class="qz-form-item" style="margin-bottom:12px;">
200 <label>证件正面照片 <span class="req">*</span></label>
201 <div class="file-box">
202 <label class="qz-btn qz-btn--ghost qz-btn--sm" style="cursor:pointer;">选择文件<input type="file" id="c-img_front" accept="image/*" style="display:none;"></label>
203 <span class="file-name" id="c-img_front-name">未选择</span>
204 </div>
205 </div>
206 <div class="qz-form-item">
207 <label>证件反面照片(可选)</label>
208 <div class="file-box">
209 <label class="qz-btn qz-btn--ghost qz-btn--sm" style="cursor:pointer;">选择文件<input type="file" id="c-img_back" accept="image/*" style="display:none;"></label>
210 <span class="file-name" id="c-img_back-name">未选择</span>
211 </div>
212 </div>
213 </div>
214 <div class="qz-modal-foot">
215 <button type="button" class="qz-btn qz-btn--ghost" data-close>取消</button>
216 <button type="button" class="qz-btn" id="qz-btn-cert"><span class="mdi mdi-shield-check-outline"></span> 提交认证</button>
217 </div>
218 </div>
219</div>
220
221<script src="<?= htmlspecialchars($qzJq, ENT_QUOTES, 'UTF-8') ?>"></script>
222<script src="<?= htmlspecialchars($qzJs, ENT_QUOTES, 'UTF-8') ?>"></script>
223<script>
224$(function () {
225 var QZ_MODE = <?= json_encode($mode, JSON_UNESCAPED_UNICODE) ?>;
226 var QZ_API = <?= json_encode($qzApi, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?>;
227 var IDTYPE = {
228 personal: [['SFZ', '身份证'], ['HZ', '护照'], ['GAJMTX', '港澳通行证'], ['TWJMTX', '台湾通行证']],
229 enterprise: [['YYZZ', '营业执照'], ['ORG', '组织机构代码证'], ['TYDM', '统一社会信用代码证']]
230 };
231 var STATUS = { 0: ['未认证', 'red'], 1: ['已认证', 'green'], 2: ['审核中', 'yellow'], 3: ['认证失败', 'red'], 4: ['异常', 'red'] };
232 var editing = null; // 当前编辑的模板对象
233
234 if (QZ_MODE === 'client') {
235 QZ.post(QZ_API + '/account_info', {}, function (res) {
236 if (!(res.data && res.data.bound)) $('#qz-tip-unbound').show();
237 }, function () { $('#qz-tip-unbound').show(); });
238 }
239
240 function renderIdType() {
241 var type = $('#f-type').val();
242 var $sel = $('#f-idtype');
243 $sel.empty();
244 $.each(IDTYPE[type] || IDTYPE.personal, function (i, it) {
245 $sel.append('<option value="' + it[0] + '">' + it[1] + '</option>');
246 });
247 }
248
249 function loadList() {
250 QZ.post(QZ_API + '/templates', {}, function (res) {
251 var list = (res.data && res.data.list) || [];
252 var $box = $('#qz-tpl-list');
253 if (!list.length) {
254 $box.html('<div class="qz-empty">暂无模板,点击右上角“新建模板”创建</div>');
255 return;
256 }
257 var html = '<table class="qz-table"><thead><tr>' +
258 '<th>所有者</th><th>类型</th><th>邮箱</th><th>手机</th><th>认证状态</th><th style="width:220px;">操作</th>' +
259 '</tr></thead><tbody>';
260 $.each(list, function (i, t) {
261 var st = STATUS[String(t.status)] || ['未知', 'gray'];
262 var typeName = t.type === 'enterprise' ? '企业' : '个人';
263 html += '<tr>' +
264 '<td>' + QZ.esc(t.zh_owner || t.en_owner || '未命名') + '</td>' +
265 '<td>' + typeName + '</td>' +
266 '<td>' + QZ.esc(t.email || '-') + '</td>' +
267 '<td>' + QZ.esc(t.phone || '-') + '</td>' +
268 '<td><span class="qz-badge qz-badge--' + st[1] + '">' + st[0] + '</span></td>' +
269 '<td class="qz-actions">' +
270 '<button type="button" class="qz-btn qz-btn--ghost qz-btn--sm" data-act="edit" data-id="' + t.id + '">编辑</button>' +
271 '<button type="button" class="qz-btn qz-btn--ghost qz-btn--sm" data-act="cert" data-id="' + t.id + '">实名认证</button>' +
272 '<button type="button" class="qz-btn qz-btn--danger qz-btn--sm" data-act="del" data-id="' + t.id + '">删除</button>' +
273 '</td></tr>';
274 });
275 html += '</tbody></table>';
276 $box.html(html);
277
278 $box.find('[data-act]').on('click', function () {
279 var act = $(this).data('act'), id = parseInt($(this).data('id'), 10);
280 var t = null;
281 $.each(list, function (i, x) { if (parseInt(x.id, 10) === id) t = x; });
282 if (!t) return;
283 if (act === 'edit') openForm(t);
284 else if (act === 'cert') openCert(id);
285 else if (act === 'del') delTemplate(id);
286 });
287 }, function (msg) {
288 $('#qz-tpl-list').html('<div class="qz-empty">' + QZ.esc(msg) + '</div>');
289 });
290 }
291
292 /* ---------- 表单 ---------- */
293 function openForm(t) {
294 editing = t || null;
295 $('#f-id').val(t ? t.id : 0);
296 $('#qz-form-title').text(t ? '编辑模板' : '新建模板');
297 $('#f-type').val(t ? (t.type || 'personal') : 'personal');
298 renderIdType();
299 $('#f-zh_owner').val(t ? (t.zh_owner || '') : '');
300 $('#f-zh_all_name').val(t ? (t.zh_all_name || '') : '');
301 $('#f-en_owner').val(t ? (t.en_owner || '') : '');
302 $('#f-en_last_name').val(t ? (t.en_last_name || '') : '');
303 $('#f-en_first_name').val(t ? (t.en_first_name || '') : '');
304 $('#f-email').val(t ? (t.email || '') : '');
305 $('#f-phone').val(t ? (t.phone || '') : '');
306 $('#f-idtype').val(t ? (t.idtype || 'SFZ') : 'SFZ');
307 $('#f-idnum').val(t ? (t.idnum || '') : '');
308 $('#f-zh_address').val(t ? (t.zh_address || '') : '');
309 $('#f-en_address').val(t ? (t.en_address || '') : '');
310 $('#f-postal_code').val(t ? (t.postal_code || '') : '');
311 $('#f-country').val(t ? (t.country || 'CN') : 'CN');
312 $('#f-img_front').val(''); $('#f-img_front-name').text('未选择');
313 $('#f-img_back').val(''); $('#f-img_back-name').text('未选择');
314 $('#qz-mask-form').addClass('show');
315 }
316
317 function buildFormData() {
318 var fd = new FormData();
319 if (editing && editing.id) fd.append('id', editing.id);
320 fd.append('type', $('#f-type').val());
321 fd.append('zh_owner', $('#f-zh_owner').val());
322 fd.append('zh_all_name', $('#f-zh_all_name').val());
323 fd.append('en_owner', $('#f-en_owner').val());
324 fd.append('en_last_name', $('#f-en_last_name').val());
325 fd.append('en_first_name', $('#f-en_first_name').val());
326 fd.append('email', $('#f-email').val());
327 fd.append('phone', $('#f-phone').val());
328 fd.append('idtype', $('#f-idtype').val());
329 fd.append('idnum', $('#f-idnum').val());
330 fd.append('zh_address', $('#f-zh_address').val());
331 fd.append('en_address', $('#f-en_address').val());
332 fd.append('postal_code', $('#f-postal_code').val());
333 fd.append('country', $('#f-country').val());
334 if ($('#f-img_front')[0].files[0]) fd.append('img_front', $('#f-img_front')[0].files[0]);
335 if ($('#f-img_back')[0].files[0]) fd.append('img_back', $('#f-img_back')[0].files[0]);
336 return fd;
337 }
338
339 $('#f-type').on('change', renderIdType);
340
341 $('#f-img_front').on('change', function () {
342 $('#f-img_front-name').text(this.files[0] ? this.files[0].name : '未选择');
343 });
344 $('#f-img_back').on('change', function () {
345 $('#f-img_back-name').text(this.files[0] ? this.files[0].name : '未选择');
346 });
347
348 $('#qz-btn-save').on('click', function () {
349 var $btn = $(this);
350 // 基础校验
351 var required = ['zh_owner', 'en_owner', 'email', 'phone', 'zh_address', 'en_address', 'idnum'];
352 var labels = { zh_owner: '所有者(中文)', en_owner: '所有者(英文)', email: '邮箱', phone: '手机', zh_address: '中文地址', en_address: '英文地址', idnum: '证件号码' };
353 for (var i = 0; i < required.length; i++) {
354 var v = $('#f-' + required[i]).val();
355 if (!$.trim(v || '')) { QZ.toast('请填写' + labels[required[i]], 'error'); return; }
356 }
357 $btn.prop('disabled', true);
358 QZ.postForm(QZ_API + '/template_save', buildFormData(), function (res) {
359 QZ.toast(res.msg || '已保存', 'success');
360 $('#qz-mask-form').removeClass('show');
361 $btn.prop('disabled', false);
362 loadList();
363 }, function (msg) {
364 QZ.toast(msg, 'error');
365 $btn.prop('disabled', false);
366 });
367 });
368
369 /* ---------- 实名认证 ---------- */
370 function openCert(id) {
371 $('#c-id').val(id);
372 $('#c-img_front').val(''); $('#c-img_front-name').text('未选择');
373 $('#c-img_back').val(''); $('#c-img_back-name').text('未选择');
374 $('#qz-mask-cert').addClass('show');
375 }
376
377 $('#c-img_front').on('change', function () {
378 $('#c-img_front-name').text(this.files[0] ? this.files[0].name : '未选择');
379 });
380 $('#c-img_back').on('change', function () {
381 $('#c-img_back-name').text(this.files[0] ? this.files[0].name : '未选择');
382 });
383
384 $('#qz-btn-cert').on('click', function () {
385 var id = $('#c-id').val();
386 if (!id) { QZ.toast('参数错误', 'error'); return; }
387 if (!$('#c-img_front')[0].files[0]) { QZ.toast('请选择证件正面照片', 'error'); return; }
388 var fd = new FormData();
389 fd.append('id', id);
390 fd.append('img_front', $('#c-img_front')[0].files[0]);
391 if ($('#c-img_back')[0].files[0]) fd.append('img_back', $('#c-img_back')[0].files[0]);
392 var $btn = $(this).prop('disabled', true);
393 QZ.postForm(QZ_API + '/template_certify', fd, function (res) {
394 QZ.toast(res.msg || '已提交', 'success');
395 $('#qz-mask-cert').removeClass('show');
396 $btn.prop('disabled', false);
397 loadList();
398 }, function (msg) {
399 QZ.toast(msg, 'error');
400 $btn.prop('disabled', false);
401 });
402 });
403
404 /* ---------- 删除 ---------- */
405 function delTemplate(id) {
406 if (!confirm('确定删除该模板?')) return;
407 QZ.post(QZ_API + '/template_delete', { id: id }, function (res) {
408 QZ.toast('已删除', 'success');
409 loadList();
410 }, function (msg) { QZ.toast(msg, 'error'); });
411 }
412
413 /* ---------- 通用 ---------- */
414 $('#qz-btn-add').on('click', function () { openForm(null); });
415 $('[data-close]').on('click', function () { $(this).closest('.qz-mask').removeClass('show'); });
416 $('.qz-mask').on('click', function (e) { if (e.target === this) $(this).removeClass('show'); });
417
418 loadList();
419});
420</script>
421</body>
422</html>