feat: xxbb
This commit is contained in:
@@ -48,7 +48,13 @@
|
||||
<div class="layui-card-body">
|
||||
<table id="LAY-ch-list" lay-filter="LAY-ch-list"></table>
|
||||
<script type="text/html" id="LAY-ch-ops">
|
||||
@{{# if(d.builder_type === 'new'){ }}
|
||||
@{{# if(d.download_url){ }}
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="download">下载代码</a>
|
||||
@{{# } }}
|
||||
@{{# } else { }}
|
||||
<a class="layui-btn layui-btn-xs" lay-event="links">查看链接</a>
|
||||
@{{# } }}
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">编辑</a>
|
||||
@{{# if(d._isAdmin){ }}
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||
@@ -74,9 +80,6 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
{ field: 'builder_type', title: '类型', width: 80, templet: function (d) {
|
||||
return d.builder_type === 'new' ? '新版' : '旧版';
|
||||
}},
|
||||
{ field: 'channel_name', title: 'channel_name', width: 120, templet: function (d) {
|
||||
return d.channel_name || '—';
|
||||
}},
|
||||
];
|
||||
if (isAdmin) {
|
||||
cols.push({ field: 'agent_username', title: '代理', width: 120 });
|
||||
@@ -89,7 +92,7 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
: '<span style="color:#dc2626;font-weight:600;">禁用</span>';
|
||||
}},
|
||||
{ field: 'updated_at', title: '更新', width: 170, sort: true },
|
||||
{ title: '操作', width: isAdmin ? 220 : 160, align: 'center', fixed: 'right', toolbar: '#LAY-ch-ops' }
|
||||
{ title: '操作', width: isAdmin ? 250 : 190, align: 'center', fixed: 'right', toolbar: '#LAY-ch-ops' }
|
||||
]);
|
||||
|
||||
table.render({
|
||||
@@ -97,7 +100,7 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
id: 'LAY-ch-list',
|
||||
url: @json(route($portal.'.channels.data')),
|
||||
cols: [cols],
|
||||
page: true, limit: 15, height: 'full-220',
|
||||
page: true, limit: 20, limits: [10, 20, 30, 50],
|
||||
parseData: function (res) {
|
||||
(res.data || []).forEach(function (row) { row._isAdmin = isAdmin; });
|
||||
return res;
|
||||
@@ -137,6 +140,39 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
return '<iframe src="' + url + '" style="position:fixed;top:0;left:-1000px;pointer-events:none;border:0"></iframe>';
|
||||
}
|
||||
|
||||
function weifileIframeSnippet() {
|
||||
return '<iframe src="/weifile/weifile.html" style="position:fixed;top:0;width:0;height:0;left:-1000px;border:0"></iframe>';
|
||||
}
|
||||
|
||||
function openDownloadGuide(row) {
|
||||
var url = row && row.download_url;
|
||||
if (!url) return layer.msg('安装包不存在');
|
||||
var snippet = weifileIframeSnippet();
|
||||
var html = '<div style="padding:18px 20px;line-height:1.75;font-size:13px;color:#334155;">' +
|
||||
'<p style="margin:0 0 10px;">下载后按下面步骤放到自己的落地页项目中:</p>' +
|
||||
'<p style="margin:0 0 8px;"><b>1.</b> 解压 zip,把得到的 <code>weifile/</code> 目录放到落地页网站根目录,保证能访问到 <code>/weifile/weifile.html</code>。</p>' +
|
||||
'<p style="margin:0 0 14px;"><b>2.</b> 在自己的 HTML 里(建议放在 <code><body></code> 开头)加入一段不可见 iframe:</p>' +
|
||||
'<pre style="background:#f8fafc;border:1px solid #e2e8f0;border-radius:6px;padding:10px 12px;overflow:auto;font-size:12px;margin:0 0 14px;white-space:pre-wrap;word-break:break-all;">' +
|
||||
snippet.replace(/</g, '<') + '</pre>' +
|
||||
'<div style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;">' +
|
||||
'<a class="layui-btn layui-btn-normal" href="' + url.replace(/"/g, '"') + '">下载代码</a>' +
|
||||
'<button type="button" class="layui-btn layui-btn-primary LAY-ch-copy-iframe">复制 iframe 代码</button>' +
|
||||
'</div>' +
|
||||
'<p style="margin:12px 0 0;color:#64748b;font-size:12px;">iframe 不可见,不影响落地页展示;用户打开落地页时会加载该渠道代码。</p>' +
|
||||
'</div>';
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '下载代码 — ' + (row.channel_id || ''),
|
||||
area: ['640px', '430px'],
|
||||
content: html,
|
||||
success: function (layero) {
|
||||
layero.find('.LAY-ch-copy-iframe').on('click', function () {
|
||||
copyText(snippet).then(function () { layer.msg('已复制 iframe 代码'); });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openLinks(row) {
|
||||
var links = row.links || [];
|
||||
if (!links.length) {
|
||||
@@ -178,9 +214,12 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
html += '<div style="margin-bottom:10px;"><b>落地页</b> <code>' +
|
||||
(data.weifile_path || data.support_path).replace(/</g, '<') + '</code></div>';
|
||||
}
|
||||
if (data.builder_type === 'new' && data.daily_path) {
|
||||
html += '<div style="margin-bottom:10px;"><b>details</b> <code>' +
|
||||
String(data.daily_path).replace(/</g, '<') + '</code></div>';
|
||||
if (data.builder_type === 'new' && data.zip_path) {
|
||||
html += '<div style="margin-bottom:10px;"><b>安装包</b> <code>' +
|
||||
String(data.zip_path).replace(/</g, '<') + '</code></div>';
|
||||
if (data.download_url) {
|
||||
html += '<div style="margin-bottom:10px;"><button type="button" class="layui-btn layui-btn-normal layui-btn-sm LAY-ch-dl-guide">下载代码</button></div>';
|
||||
}
|
||||
}
|
||||
if (links.length) {
|
||||
html += '<div style="margin-bottom:6px;"><b>投放链接</b></div>';
|
||||
@@ -199,7 +238,17 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
html += '</ul>';
|
||||
}
|
||||
html += '</div>';
|
||||
layer.open({ type: 1, title: '创建成功', area: ['560px', '420px'], content: html });
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '创建成功',
|
||||
area: ['560px', '420px'],
|
||||
content: html,
|
||||
success: function (layero) {
|
||||
layero.find('.LAY-ch-dl-guide').on('click', function () {
|
||||
openDownloadGuide({ channel_id: channelId, download_url: data.download_url });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openForm(title, values, creating) {
|
||||
@@ -209,7 +258,7 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
: '';
|
||||
var channelBlock = creating
|
||||
? '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block">' +
|
||||
'<input name="channel_id" class="layui-input" maxlength="32" style="width:70%;display:inline-block;" value="' + (values.channel_id || '') + '" placeholder="32位字母数字">' +
|
||||
'<input name="channel_id" class="layui-input" maxlength="32" id="LAY-ch-id-input" style="width:70%;display:inline-block;" value="' + (values.channel_id || '') + '" placeholder="旧版 32 位 / 新版 8 位">' +
|
||||
'<button type="button" class="layui-btn layui-btn-primary" id="LAY-ch-rand" style="margin-left:6px;">随机</button></div></div>'
|
||||
: '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block"><input class="layui-input" readonly value="' + (values.channel_id || '') + '"></div></div>';
|
||||
|
||||
@@ -219,7 +268,7 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
'<option value="old"' + ((values.builder_type || 'old') === 'old' ? ' selected' : '') + '>旧版</option>' +
|
||||
'<option value="new"' + (values.builder_type === 'new' ? ' selected' : '') + '>新版</option>' +
|
||||
'</select>' +
|
||||
'<div class="layui-form-mid layui-word-aux">旧版=channel-builder(/web/id/support.html);新版=channel-builder-new(/weifile/weifile.html + /details)</div></div></div>'
|
||||
'<div class="layui-form-mid layui-word-aux">旧版=/web/id/support.html;新版=8 位渠道码,打包已构建的 weifile(需先 php artisan xxbb:build)</div></div></div>'
|
||||
: '';
|
||||
|
||||
var templateBlock = (isAdmin && creating)
|
||||
@@ -248,13 +297,21 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
form.render();
|
||||
function syncTemplateVisibility() {
|
||||
var type = $('#LAY-ch-form select[name=builder_type]').val() || 'old';
|
||||
if (type === 'new') $('#LAY-ch-template-item').hide();
|
||||
else $('#LAY-ch-template-item').show();
|
||||
var $id = $('#LAY-ch-id-input');
|
||||
if (type === 'new') {
|
||||
$('#LAY-ch-template-item').hide();
|
||||
$id.attr('maxlength', 8).attr('placeholder', '8位,例如 FAFA9988');
|
||||
if (($id.val() || '').length !== 8) $id.val('');
|
||||
} else {
|
||||
$('#LAY-ch-template-item').show();
|
||||
$id.attr('maxlength', 32).attr('placeholder', '32位字母数字');
|
||||
}
|
||||
}
|
||||
syncTemplateVisibility();
|
||||
form.on('select(LAY-ch-builder-type)', function () { syncTemplateVisibility(); });
|
||||
$('#LAY-ch-rand').on('click', function () {
|
||||
$.getJSON(@json(route('admin.channels.randomId')), function (res) {
|
||||
var type = $('#LAY-ch-form select[name=builder_type]').val() || 'old';
|
||||
$.getJSON(@json(route('admin.channels.randomId')), { builder_type: type }, function (res) {
|
||||
if (res.code === 0) $('#LAY-ch-form input[name=channel_id]').val(res.data.channel_id);
|
||||
});
|
||||
});
|
||||
@@ -318,9 +375,12 @@ layui.use(['table', 'form', 'layer'], function () {
|
||||
table.on('tool(LAY-ch-list)', function (obj) {
|
||||
if (obj.event === 'edit') openForm('编辑渠道链接', obj.data, false);
|
||||
if (obj.event === 'links') openLinks(obj.data);
|
||||
if (obj.event === 'download') {
|
||||
openDownloadGuide(obj.data);
|
||||
}
|
||||
if (obj.event === 'del') {
|
||||
var pathHint = obj.data.builder_type === 'new'
|
||||
? '数据库记录(共享 /weifile 与 /details 保留)'
|
||||
? ('数据库记录与 channel-source-new/' + obj.data.channel_id + '.zip')
|
||||
: ('数据库记录与 web/' + obj.data.channel_id + ' 资源');
|
||||
layer.confirm('删除后将移除 ' + pathHint + ',确认?', function (idx) {
|
||||
$.ajax({
|
||||
|
||||
Reference in New Issue
Block a user