mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-09-21 19:26:39 +08:00
插件中收
This commit is contained in:
parent
3d210481b1
commit
8bdac2b62c
@ -1,85 +1,16 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use think\Request;
|
||||
use app\BaseController;
|
||||
use think\facade\View;
|
||||
|
||||
class PluginController
|
||||
class PluginController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
return View::fetch();
|
||||
}
|
||||
}
|
||||
|
@ -1,85 +1,26 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\controller\api;
|
||||
|
||||
use think\Request;
|
||||
use app\BaseController;
|
||||
use app\model\Platform;
|
||||
|
||||
class PluginController
|
||||
class PluginController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
public function getPluginList()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
$query = $this->request->get();
|
||||
$data = Platform::order('id', 'desc')->paginate(['list_rows' => $query['limit'], 'page' => $query['page']]);
|
||||
if ($data) {
|
||||
return json(['code' => 0, 'msg' => 'OK', 'count' => $data->total(), 'data' => $data->items()]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => '无数据记录', 'count' => 0, 'data' => []]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,21 +52,21 @@ return [
|
||||
'openType' => '_iframe',
|
||||
'href' => '/System/index',
|
||||
],
|
||||
[
|
||||
'id' => 'pay',
|
||||
'title' => '支付管理',
|
||||
'icon' => 'layui-icon layui-icon-console',
|
||||
'type' => 0,
|
||||
'href' => '',
|
||||
'children' => [
|
||||
[
|
||||
'id' => 'pay_qrcode_list',
|
||||
'title' => '收款账户',
|
||||
'icon' => 'layui-icon layui-icon-console',
|
||||
'type' => 1,
|
||||
'openType' => '_iframe',
|
||||
'href' => '/PayQrcode/index',
|
||||
],
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'id' => 'pay',
|
||||
// 'title' => '支付管理',
|
||||
// 'icon' => 'layui-icon layui-icon-console',
|
||||
// 'type' => 0,
|
||||
// 'href' => '',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'id' => 'pay_qrcode_list',
|
||||
// 'title' => '收款账户',
|
||||
// 'icon' => 'layui-icon layui-icon-console',
|
||||
// 'type' => 1,
|
||||
// 'openType' => '_iframe',
|
||||
// 'href' => '/PayQrcode/index',
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
];
|
||||
|
131
view/plugin/index.html
Normal file
131
view/plugin/index.html
Normal file
@ -0,0 +1,131 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>控制台</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/admin/css/other/console1.css" />
|
||||
<style>
|
||||
.header-th div.layui-table-header th div {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.divider-vl {
|
||||
display: inline-block;
|
||||
width: 1px;
|
||||
height: 1em;
|
||||
margin: 0 8px;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
background-color: #dcdfe6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12"></div>
|
||||
<div class="layui-col-xs12">
|
||||
<table id="plugin-table" lay-filter="plugin-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/html" id="plugin-toolbar">
|
||||
<button class="layui-btn layui-btn-primary layui-bg-gray layui-btn-sm" grp-btn lay-event="showAllPlugin">全部</button>
|
||||
<button class="layui-btn layui-btn-primary layui-bg-green layui-btn-sm" grp-btn lay-event="showInstalled">已安装</button>
|
||||
<button class="layui-btn layui-btn-primary layui-bg-gray layui-btn-sm" grp-btn lay-event="showWaitInstall">待安装</button>
|
||||
</script>
|
||||
<script type="text/html" id="plugin-state">
|
||||
<input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="pluginEnable" {{ d.state == 1 ? 'checked' : '' }} />
|
||||
</script>
|
||||
<script type="text/html" id="plugin-action">
|
||||
<a href="javascript:;" class="layui-font-green" lay-event="createConfig">生成配置</a><div class="divider-vl"></div>
|
||||
<a href="javascript:;" class="layui-font-green" lay-event="pluginUpdate">更新</a><div class="divider-vl"></div>
|
||||
<a href="javascript:;" class="layui-font-green" lay-event="pluginUninstall">卸载</a>
|
||||
</script>
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['layer', 'form', 'common', 'layer'], function () {
|
||||
let table = layui.table;
|
||||
let layer = layui.layer;
|
||||
let form = layui.form;
|
||||
let common = layui.common;
|
||||
let util = layui.util;
|
||||
|
||||
const cols = [[
|
||||
{ title: '收款平台名称', field: 'name', align: 'center', maxWidth: 180 },
|
||||
{ title: '官网', field: 'name', align: 'left', maxWidth: 220, templet: `<div><a href="{{= d.website }}" class="layui-font-green" target="_blank">{{= d.website }}</a></div>` },
|
||||
{ title: '说明', field: 'describe', align: 'left' },
|
||||
{ title: '价格', field: 'price', align: 'center', maxWidth: 180, templet: `<div>{{= d.price==0 ? '免费' : d.price }}</div>` },
|
||||
{ title: '状态', field: 'state', align: 'center', maxWidth: 180, templet: `#plugin-state` },
|
||||
{ title: '操作', align: 'right', maxWidth: 180, fixed: 'right', templet: `#plugin-action` },
|
||||
]]
|
||||
|
||||
table.render({
|
||||
id: 'plugin-table',
|
||||
elem: '#plugin-table',
|
||||
url: '/api/Plugin/getPluginList',
|
||||
page: true,
|
||||
skin: 'line',
|
||||
cols: cols,
|
||||
className: 'header-th',
|
||||
toolbar: '#plugin-toolbar',
|
||||
defaultToolbar: [{ title: '刷新', layEvent: 'refresh', icon: 'layui-icon-refresh' }]
|
||||
});
|
||||
// 表头工具事件
|
||||
table.on('toolbar(plugin-table)', function (obj) {
|
||||
if (obj.event === 'showAllPlugin') {
|
||||
plugin.changClass(this);
|
||||
} else if (obj.event === 'showInstalled') {
|
||||
plugin.changClass(this);
|
||||
} else if (obj.event === 'showWaitInstall') {
|
||||
plugin.changClass(this);
|
||||
}
|
||||
|
||||
});
|
||||
// 单元格事件
|
||||
table.on('tool(plugin-table)', function (obj) {
|
||||
const id = obj.data.id;
|
||||
if (obj.event === 'createConfig') {
|
||||
layer.msg(obj.event);
|
||||
} else if (obj.event === 'pluginUpdate') {
|
||||
layer.msg(obj.event);
|
||||
} else if (obj.event === 'pluginUninstall') {
|
||||
layer.msg(obj.event);
|
||||
}
|
||||
});
|
||||
// 启用状态
|
||||
form.on('switch(pluginEnable)', function (obj) {
|
||||
const state = obj.elem.checked == true ? 1 : 0;
|
||||
const id = obj.value;
|
||||
const field = { state: state, id: id };
|
||||
layer.msg(id + ', ' + state);
|
||||
return false;
|
||||
});
|
||||
|
||||
// 处理点击btn切换class
|
||||
let plugin = {};
|
||||
plugin.changClass = (ele) => {
|
||||
const select = 'layui-btn layui-btn-primary layui-bg-green layui-btn-sm';
|
||||
const unselect = 'layui-btn layui-btn-primary layui-bg-gray layui-btn-sm';
|
||||
ele.className = select;
|
||||
const btns = document.querySelectorAll(`button[grp-btn]`);
|
||||
btns.forEach(val => {
|
||||
if (ele != val) {
|
||||
val.className = unselect;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user