113 lines
5.3 KiB
HTML
113 lines
5.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>开发者管理 - 应用市场管理</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link href="/assets/layui/css/layui.css" rel="stylesheet">
|
|
<link href="/assets/ywxapp/css/wxapp.css" rel="stylesheet">
|
|
<style>body{background:#f2f3f5;padding:15px;}</style>
|
|
</head>
|
|
<body>
|
|
<form class="layui-form" lay-filter="filterForm">
|
|
<div class="layui-form-item">
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">状态</label>
|
|
<div class="layui-input-inline" style="width:140px;">
|
|
<select name="status">
|
|
<option value="">全部</option>
|
|
<option value="0">待审核</option>
|
|
<option value="1">正常</option>
|
|
<option value="-1">已禁用</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<button class="layui-btn" lay-submit lay-filter="search">搜索</button>
|
|
</div>
|
|
</form>
|
|
|
|
<table id="dataTable" lay-filter="dataTable"></table>
|
|
|
|
<script type="text/html" id="statusTpl">
|
|
{{# if(d.status == 0){ }}<span class="layui-badge layui-bg-orange">待审核</span>
|
|
{{# } else if(d.status == 1){ }}<span class="layui-badge layui-bg-green">正常</span>
|
|
{{# } else { }}<span class="layui-badge">已禁用</span>{{# } }}
|
|
</script>
|
|
|
|
<script type="text/html" id="operateTpl">
|
|
{{# if(d.status == 0){ }}
|
|
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="approve">通过</a>
|
|
{{# } }}
|
|
{{# if(d.status == 1){ }}
|
|
<a class="layui-btn layui-btn-xs" lay-event="resend">重发令牌</a>
|
|
<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="reset">重置令牌</a>
|
|
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="disable">禁用</a>
|
|
{{# } }}
|
|
{{# if(d.status == -1){ }}
|
|
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="approve">启用</a>
|
|
{{# } }}
|
|
</script>
|
|
|
|
<script src="/assets/layui/layui.js"></script>
|
|
<script src="/assets/ywxapp/ywxapp.js" module="{$site.app}"></script>
|
|
<script>
|
|
layui.use(['table', 'form', 'layer', 'jquery', 'http'], function () {
|
|
var table = layui.table, form = layui.form, layer = layui.layer, $ = layui.jquery, http = layui.http;
|
|
|
|
table.render({
|
|
elem: '#dataTable',
|
|
url: 'index',
|
|
page: true,
|
|
limits: [10, 20, 50],
|
|
limit: 10,
|
|
cols: [[
|
|
{ field: 'id', title: 'ID', width: 70 },
|
|
{ field: 'username', title: '开发者', minWidth: 140 },
|
|
{ field: 'email', title: '邮箱', minWidth: 200 },
|
|
{ field: 'token', title: '令牌', minWidth: 320, templet: function (d) { return '<span style="word-break:break-all;">' + d.token + '</span>'; } },
|
|
{ field: 'status', title: '状态', width: 90, templet: '#statusTpl' },
|
|
{ field: 'created_at', title: '创建时间', width: 170, templet: function (d) { return d.created_at ? new Date(d.created_at * 1000).toLocaleString() : ''; } },
|
|
{ title: '操作', width: 260, toolbar: '#operateTpl', fixed: 'right' }
|
|
]],
|
|
response: { statusName: 'code', statusCode: 0, msgName: 'message', countName: 'count', dataName: 'data' }
|
|
});
|
|
|
|
form.on('submit(search)', function (data) {
|
|
table.reload('dataTable', { where: data.field, page: { curr: 1 } });
|
|
return false;
|
|
});
|
|
|
|
table.on('tool(dataTable)', function (elem) {
|
|
var d = elem.data, id = d.id;
|
|
if (elem.event === 'approve') {
|
|
layer.confirm('确认' + (d.status == 0 ? '通过该开发者并邮件下发令牌?' : '启用该开发者?'), function () {
|
|
http.post('approve', { id: id }).then(function (r) {
|
|
if (r.code === 0) { layer.msg('操作成功', { icon: 1 }); table.reload('dataTable'); }
|
|
else { layer.msg(r.message || '操作失败', { icon: 2 }); }
|
|
}).catch(function () { layer.msg('请求失败', { icon: 2 }); });
|
|
});
|
|
} else if (elem.event === 'disable') {
|
|
layer.confirm('确认禁用该开发者?其令牌将立即失效。', function () {
|
|
http.post('disable', { id: id }).then(function (r) {
|
|
if (r.code === 0) { layer.msg('已禁用', { icon: 1 }); table.reload('dataTable'); }
|
|
else { layer.msg(r.message || '操作失败', { icon: 2 }); }
|
|
}).catch(function () { layer.msg('请求失败', { icon: 2 }); });
|
|
});
|
|
} else if (elem.event === 'resend') {
|
|
http.post('resend', { id: id }).then(function (r) {
|
|
layer.msg(r.message || (r.code === 0 ? '已重发' : '失败'), { icon: r.code === 0 ? 1 : 2 });
|
|
}).catch(function () { layer.msg('请求失败', { icon: 2 }); });
|
|
} else if (elem.event === 'reset') {
|
|
layer.confirm('确认重置令牌?旧令牌将失效。', function () {
|
|
http.post('reset', { id: id }).then(function (r) {
|
|
if (r.code === 0) { layer.msg('已重置' + (r.data && r.data.token ? ',新令牌:' + r.data.token : ''), { icon: 1, time: 4000 }); table.reload('dataTable'); }
|
|
else { layer.msg(r.message || '操作失败', { icon: 2 }); }
|
|
}).catch(function () { layer.msg('请求失败', { icon: 2 }); });
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|