后台界面:更新签到页面 sign.html;version 提升至 2.11.8 刷新缓存
This commit is contained in:
+137
-61
@@ -75,10 +75,9 @@
|
||||
.icon-upload-preview:hover { border-color: #009688; }
|
||||
.icon-upload-preview img { max-width: 100%; max-height: 100%; }
|
||||
.icon-upload-preview .placeholder { color: #999; font-size: 12px; text-align: center; }
|
||||
.gift-row { display: flex; align-items: center; margin-bottom: 6px; }
|
||||
.gift-row .layui-input, .gift-row select { height: 32px; }
|
||||
.gift-row .gr-count { width: 110px; margin: 0 6px; }
|
||||
.gift-row .gr-oid { width: 150px; margin-right: 6px; }
|
||||
.gift-list-table { width: 100%; border-collapse: collapse; }
|
||||
.gift-list-table th, .gift-list-table td { border: 1px solid #e6e6e6; padding: 6px 8px; font-size: 13px; text-align: center; }
|
||||
.gift-list-table th { background: #fafafa; color: #666; font-weight: normal; }
|
||||
</style>
|
||||
|
||||
<script>
|
||||
@@ -91,6 +90,7 @@
|
||||
setter = layui.setter;
|
||||
|
||||
var activityConfig = null;
|
||||
var propList = [];
|
||||
var typeMap = { 1: '金币', 2: '钻石', 3: '道具' };
|
||||
|
||||
setTimeout(function() {
|
||||
@@ -109,17 +109,34 @@
|
||||
return activityConfig.signActivityConfig;
|
||||
}
|
||||
|
||||
function getPropName(number) {
|
||||
var p = propList.find(function (x) { return String(x.number) === String(number); });
|
||||
return p ? (p.number + ' - ' + p.name) : (number || '');
|
||||
}
|
||||
|
||||
function loadConfig() {
|
||||
admin.req({
|
||||
method: "get",
|
||||
url: setter.baseurl + "adminapi/ActivityConfig/Get",
|
||||
done: function (res) {
|
||||
activityConfig = (res.code === 0 && res.data) ? res.data : { signActivityConfig: {} };
|
||||
initForm();
|
||||
loadProps();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadProps() {
|
||||
admin.req({
|
||||
method: "get",
|
||||
url: setter.baseurl + "adminapi/GameConfig",
|
||||
done: function (res) {
|
||||
propList = (res.code === 0 && res.data && res.data.propConfig) ? res.data.propConfig : [];
|
||||
initForm();
|
||||
},
|
||||
fail: function () { propList = []; initForm(); }
|
||||
});
|
||||
}
|
||||
|
||||
function initForm() {
|
||||
var s = sign();
|
||||
$('input[name="isOpen"]').prop('checked', !!s.isOpen);
|
||||
@@ -151,9 +168,11 @@
|
||||
function giftText(list) {
|
||||
if (!list || !list.length) return '<span style="color:#999;">未配置</span>';
|
||||
return list.map(function (g) {
|
||||
var t = typeMap[g.type] || '金币';
|
||||
var oid = (g.type === 3 && g.otherId) ? ('(' + g.otherId + ')') : '';
|
||||
return t + '×' + (g.count || 0) + oid;
|
||||
var t = g.type || 1;
|
||||
if (t === 1) return '金币×' + (g.count || 0);
|
||||
if (t === 2) return '钻石×' + (g.count || 0);
|
||||
if (t === 3) return '道具 ' + getPropName(g.otherId || '') + '×' + (g.count || 0);
|
||||
return (typeMap[t] || '未知') + '×' + (g.count || 0);
|
||||
}).join('、');
|
||||
}
|
||||
|
||||
@@ -254,52 +273,12 @@
|
||||
});
|
||||
});
|
||||
|
||||
// ==================== 天数编辑弹窗(含奖励编辑) ====================
|
||||
function giftRowHtml(g) {
|
||||
g = g || { type: 1, count: 0, otherId: '' };
|
||||
var oidStyle = g.type === 3 ? '' : 'display:none;';
|
||||
return '<div class="gift-row">' +
|
||||
'<select class="gr-type" style="width:90px;">' +
|
||||
'<option value="1">金币</option><option value="2">钻石</option><option value="3">道具</option>' +
|
||||
'</select>' +
|
||||
'<input type="number" class="layui-input gr-count" placeholder="数量" value="' + (g.count || 0) + '">' +
|
||||
'<input type="text" class="layui-input gr-oid" style="' + oidStyle + '" placeholder="道具编号" value="' + (g.otherId || '') + '">' +
|
||||
'<button type="button" class="layui-btn layui-btn-sm layui-btn-danger gr-del">删除</button>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
function bindGiftRows(container) {
|
||||
container.off('change', '.gr-type').on('change', '.gr-type', function () {
|
||||
var isProp = $(this).val() === '3';
|
||||
$(this).closest('.gift-row').find('.gr-oid').toggle(isProp);
|
||||
});
|
||||
container.off('click', '.gr-del').on('click', '.gr-del', function () {
|
||||
$(this).closest('.gift-row').remove();
|
||||
});
|
||||
container.off('click', '.gr-add').on('click', '.gr-add', function () {
|
||||
container.find('#giftRows').append(giftRowHtml({ type: 1, count: 0, otherId: '' }));
|
||||
});
|
||||
}
|
||||
|
||||
function collectGiftRows(container) {
|
||||
var list = [];
|
||||
container.find('.gift-row').each(function () {
|
||||
var t = parseInt($(this).find('.gr-type').val()) || 1;
|
||||
var c = parseInt($(this).find('.gr-count').val()) || 0;
|
||||
var oid = t === 3 ? ($(this).find('.gr-oid').val() || '') : '';
|
||||
list.push({ type: t, count: c, otherId: oid });
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
// ==================== 天数编辑弹窗(含奖励配置) ====================
|
||||
function showDayEdit(data, isAdd, rowIndex) {
|
||||
var imagePreviewHtml = data.icon
|
||||
? '<img src="' + data.icon + '" style="max-width:100%;max-height:100%;">'
|
||||
: '<div class="placeholder">点击上传</div>';
|
||||
|
||||
var rowsHtml = '';
|
||||
(data.giftList || []).forEach(function (g) { rowsHtml += giftRowHtml(g); });
|
||||
|
||||
var html = '<div style="padding:20px;">' +
|
||||
'<form class="layui-form">' +
|
||||
'<div class="layui-form-item">' +
|
||||
@@ -328,29 +307,30 @@
|
||||
'<div class="layui-form-item">' +
|
||||
'<label class="layui-form-label">奖励</label>' +
|
||||
'<div class="layui-input-block">' +
|
||||
'<div id="giftRows">' + rowsHtml + '</div>' +
|
||||
'<button type="button" class="layui-btn layui-btn-sm layui-btn-normal gr-add" style="margin-top:6px;"><i class="layui-icon layui-icon-add-1"></i> 新增奖励</button>' +
|
||||
'<div style="color:#999;font-size:12px;margin-top:4px;">类型选“道具”时需填写道具编号</div>' +
|
||||
'<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="btn-add-gift"><i class="layui-icon layui-icon-add-1"></i> 新增奖励</button>' +
|
||||
'<table class="gift-list-table" style="margin-top:8px;">' +
|
||||
'<thead><tr><th style="width:80px;">类型</th><th>道具</th><th style="width:90px;">数量</th><th style="width:120px;">操作</th></tr></thead>' +
|
||||
'<tbody id="giftTbody"></tbody>' +
|
||||
'</table>' +
|
||||
'<div style="color:#999;font-size:12px;margin-top:4px;">类型选“道具”时,可从下拉里选择具体道具(含碎片)并设置数量</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'</div>';
|
||||
|
||||
var giftList = (data.giftList || []).map(function (g) {
|
||||
return { type: g.type || 1, count: g.count || 0, otherId: g.otherId || '' };
|
||||
});
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: isAdd ? '添加天数配置' : '编辑天数配置',
|
||||
area: ['620px', '560px'],
|
||||
area: ['640px', '600px'],
|
||||
content: html,
|
||||
btn: ['保存', '取消'],
|
||||
shadeClose: true,
|
||||
success: function (layero) {
|
||||
// 初始化每个奖励行的类型下拉
|
||||
(data.giftList || []).forEach(function (g, i) {
|
||||
var row = layero.find('.gift-row').eq(i);
|
||||
row.find('.gr-type').val(g.type || 1);
|
||||
row.find('.gr-oid').toggle((g.type || 1) === 3);
|
||||
});
|
||||
bindGiftRows(layero);
|
||||
renderGiftRows(layero, giftList);
|
||||
|
||||
var $preview = layero.find('#iconPreview');
|
||||
var $input = layero.find('#iconInput');
|
||||
@@ -393,7 +373,7 @@
|
||||
day: day,
|
||||
name: layero.find('input[name="name"]').val() || ('第' + day + '天'),
|
||||
icon: layero.find('input[name="icon"]').val(),
|
||||
giftList: collectGiftRows(layero)
|
||||
giftList: giftList
|
||||
};
|
||||
var s = sign();
|
||||
if (!s.days) s.days = [];
|
||||
@@ -409,6 +389,102 @@
|
||||
});
|
||||
}
|
||||
|
||||
function renderGiftRows(dayLayero, giftList) {
|
||||
var $tbody = dayLayero.find('#giftTbody');
|
||||
$tbody.empty();
|
||||
if (!giftList.length) {
|
||||
$tbody.append('<tr><td colspan="4" style="color:#999;padding:10px;">暂无奖励,点击“新增奖励”添加</td></tr>');
|
||||
} else {
|
||||
giftList.forEach(function (g, i) {
|
||||
var t = g.type || 1;
|
||||
var itemName = (t === 3) ? getPropName(g.otherId || '') : '-';
|
||||
$tbody.append(
|
||||
'<tr>' +
|
||||
'<td>' + (typeMap[t] || '金币') + '</td>' +
|
||||
'<td>' + itemName + '</td>' +
|
||||
'<td>' + (g.count || 0) + '</td>' +
|
||||
'<td>' +
|
||||
'<button type="button" class="layui-btn layui-btn-xs gr-edit" data-i="' + i + '">编辑</button>' +
|
||||
'<button type="button" class="layui-btn layui-btn-xs layui-btn-danger gr-del" data-i="' + i + '">删除</button>' +
|
||||
'</td>' +
|
||||
'</tr>');
|
||||
});
|
||||
}
|
||||
|
||||
dayLayero.find('#btn-add-gift').off('click').on('click', function () {
|
||||
showGiftEdit(dayLayero, giftList, -1, true);
|
||||
});
|
||||
dayLayero.find('.gr-edit').off('click').on('click', function () {
|
||||
showGiftEdit(dayLayero, giftList, parseInt($(this).data('i')), false);
|
||||
});
|
||||
dayLayero.find('.gr-del').off('click').on('click', function () {
|
||||
giftList.splice(parseInt($(this).data('i')), 1);
|
||||
renderGiftRows(dayLayero, giftList);
|
||||
});
|
||||
}
|
||||
|
||||
function showGiftEdit(dayLayero, giftList, index, isAdd) {
|
||||
var g = isAdd ? { type: 1, count: 0, otherId: '' } : giftList[index];
|
||||
var propOpts = '<option value="">请选择道具</option>';
|
||||
propList.forEach(function (p) {
|
||||
propOpts += '<option value="' + p.number + '">' + p.number + ' - ' + p.name + '</option>';
|
||||
});
|
||||
|
||||
var html = '<div style="padding:15px;">' +
|
||||
'<form class="layui-form">' +
|
||||
'<div class="layui-form-item">' +
|
||||
'<label class="layui-form-label">类型</label>' +
|
||||
'<div class="layui-input-block">' +
|
||||
'<select id="giftType"><option value="1">金币</option><option value="2">钻石</option><option value="3">道具</option></select>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="layui-form-item gift-prop-item">' +
|
||||
'<label class="layui-form-label">道具</label>' +
|
||||
'<div class="layui-input-block">' +
|
||||
'<select id="giftProp" lay-search>' + propOpts + '</select>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="layui-form-item">' +
|
||||
'<label class="layui-form-label">数量</label>' +
|
||||
'<div class="layui-input-block">' +
|
||||
'<input type="number" id="giftCount" class="layui-input" value="' + (g.count || 0) + '">' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'</div>';
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: isAdd ? '新增奖励' : '编辑奖励',
|
||||
area: ['460px', '360px'],
|
||||
content: html,
|
||||
btn: ['确定', '取消'],
|
||||
shadeClose: true,
|
||||
success: function (l) {
|
||||
l.find('#giftType').val(g.type || 1);
|
||||
l.find('#giftProp').val(g.otherId || '');
|
||||
form.render('select');
|
||||
toggleGiftProp(l);
|
||||
l.find('#giftType').on('change', function () { toggleGiftProp(l); });
|
||||
},
|
||||
yes: function (idx, l) {
|
||||
var t = parseInt(l.find('#giftType').val()) || 1;
|
||||
var c = parseInt(l.find('#giftCount').val()) || 0;
|
||||
var oid = t === 3 ? (l.find('#giftProp').val() || '') : '';
|
||||
if (t === 3 && !oid) { layer.msg('请选择道具'); return; }
|
||||
var item = { type: t, count: c, otherId: oid };
|
||||
if (isAdd) giftList.push(item); else giftList[index] = item;
|
||||
layer.close(idx);
|
||||
renderGiftRows(dayLayero, giftList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleGiftProp(l) {
|
||||
var isProp = (parseInt(l.find('#giftType').val()) || 1) === 3;
|
||||
l.find('.gift-prop-item').toggle(isProp);
|
||||
}
|
||||
|
||||
window.saveAct = function (n) { layui.admin.req({ method: 'get', url: (layui.setter.baseurl || '/') + 'adminapi/ActivityConfig/SaveSection/' + n, done: function (r) { layui.layer.msg(r.info || (r.code === 0 ? '保存成功' : '保存失败')) } }) }
|
||||
|
||||
loadConfig();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<script>
|
||||
layui.config({
|
||||
base: './dist/' //指定 layuiAdmin 项目路径
|
||||
, version: '2.11.7'
|
||||
, version: '2.11.8'
|
||||
}).use('index', function () {
|
||||
var layer = layui.layer, admin = layui.admin;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user