mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-12-26 01:15:58 +08:00
删除文件 view
This commit is contained in:
@@ -1,108 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>添加账号</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<style>
|
||||
.inputTxt {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form id="add-account" class="layui-form layui-form-pane" action="" lay-filter="add-account">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款平台</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="platform">
|
||||
<option value="">收款平台</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">登陆密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="password" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">监听模式</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="pattern">
|
||||
<option value="请选择"></option>
|
||||
<?php include_once '../view/tpl/pattern.html'; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="add-account">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['form'], function () {
|
||||
let form = layui.form;
|
||||
|
||||
// 渲染插件选项
|
||||
(async () => {
|
||||
const data = await fetch('/api/Plugin/pluginOption').then(res => res.json());
|
||||
let option_str = `<option value="">收款平台</option>`;
|
||||
data.forEach(val => {
|
||||
option_str += `<option value="${val.platform}">${val.name}</option>`;
|
||||
});
|
||||
const select = document.querySelector('select[name="platform"]');
|
||||
select.innerHTML = option_str;
|
||||
form.render('select');
|
||||
})()
|
||||
|
||||
form.on('submit(add-account)', function (obj) {
|
||||
const field = obj.field;
|
||||
(async () => {
|
||||
const url = '/api/PayManage/addAccount';
|
||||
const info = field;
|
||||
const res = await fetch(url, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(info) });
|
||||
if (res.status !== 200) {
|
||||
layer.msg('请求失败,请重试!', { tips: 2, time: 1200 });
|
||||
return false;
|
||||
}
|
||||
const rec_info = await res.json();
|
||||
if (rec_info.code === 0) {
|
||||
layer.msg(rec_info.msg, { icon: 1, time: 1200 }, () => {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页
|
||||
parent.layui.table.reload("account-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(rec_info.msg, { icon: 2, time: 1200 });
|
||||
}
|
||||
})()
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,85 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>添加收款终端</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<style>
|
||||
.inputTxt {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form id="set-channel" class="layui-form layui-form-pane" action="" lay-filter="channel-edit">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">终端编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="channel" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="qrcode" autocomplete="off" lay-affix="upload-drag"
|
||||
lay-filter="scanning" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['form'], function () {
|
||||
let form = layui.form;
|
||||
|
||||
form.on('input-affix(scanning)', function () {
|
||||
window.open('https://cli.im/deqr', '_blank');
|
||||
});
|
||||
|
||||
form.on('submit(save)', function (obj) {
|
||||
let field = obj.field;
|
||||
field.account_id = '<?php echo $aid ?>';
|
||||
(async () => {
|
||||
const url = '/api/PayManage/addChannel';
|
||||
const info = field;
|
||||
const res = await fetch(url, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(info) });
|
||||
if (res.status !== 200) {
|
||||
layer.msg('请求失败,请重试!', { tips: 2, time: 1200 });
|
||||
return false;
|
||||
}
|
||||
const rec_info = await res.json();
|
||||
if (rec_info.code === 0) {
|
||||
layer.msg(rec_info.msg, { icon: 1, time: 1200 }, () => {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页
|
||||
parent.window.location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(rec_info.msg, { icon: 2, time: 1200 });
|
||||
}
|
||||
})()
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,141 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>终端列表</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<style>
|
||||
.edit {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
.layui-card {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#mainbox {
|
||||
padding: 16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="pear-container">
|
||||
<div class="layui-row" id="mainbox">
|
||||
<!-- 通道列表 -->
|
||||
</div>
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script src="/static/js/awesome-qr.min.js"></script>
|
||||
<script>
|
||||
const QR = AwesomeQR.AwesomeQR;
|
||||
layui.use(['form', 'common'], function () {
|
||||
let form = layui.form;
|
||||
let util = layui.util;
|
||||
let common = layui.common;
|
||||
let layer = layui.layer;
|
||||
|
||||
util.on({
|
||||
getQrcode: function () {
|
||||
(async () => {
|
||||
const qrcode_data = this.getAttribute("data-qrcode")
|
||||
const qrcode_img = await getQrcode(qrcode_data, QR);
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['200px', '200px'],
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
shadeClose: true,
|
||||
content: `<img width="100%" src="${qrcode_img}">`
|
||||
});
|
||||
})()
|
||||
},
|
||||
edit: function () {
|
||||
const cid = this.getAttribute("data-cid")
|
||||
layer.open({
|
||||
id: 'iframe-channel-edit',
|
||||
type: 2,
|
||||
title: '添加收款终端',
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? '80%' : '400px', common.isModile() ? '70%' : '300px'],
|
||||
content: `/PayManage/editChannel?cid=${cid}`,
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
const aid = this.getAttribute("data-aid")
|
||||
layer.open({
|
||||
id: 'iframe-channel-add',
|
||||
type: 2,
|
||||
title: '添加收款终端',
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? '80%' : '400px', common.isModile() ? '70%' : '300px'],
|
||||
content: `/PayManage/addChannel?aid=${aid}`,
|
||||
});
|
||||
},
|
||||
});
|
||||
// 工具
|
||||
let channel = {};
|
||||
|
||||
channel.buildEle = function (item) {
|
||||
let card = document.createElement('div');
|
||||
card.className = 'layui-card';
|
||||
const qrcode = item.qrcode.length > 50 ? item.qrcode.slice(0, 50) + '...' : item.qrcode;
|
||||
let htmlstr = `
|
||||
<div class="layui-card-body">
|
||||
<span class="layui-badge layui-bg-cyan">终端编号</span><span class="layui-badge layui-bg-gray">${item.channel}</span><br>
|
||||
<span class="layui-badge layui-bg-cyan">收款地址</span><span class="layui-badge layui-bg-gray">${qrcode}</span>
|
||||
<a href="javascript:;" class="layui-font-blue" lay-on="getQrcode"data-qrcode="${item.qrcode}"><span class="icon pear-icon"></span></a><br>
|
||||
<span class="layui-badge layui-bg-cyan">最后使用</span><span class="layui-badge layui-bg-gray">${item.last_time}</span><br>
|
||||
<span class="layui-badge layui-bg-cyan">启用状态</span><span class="layui-badge layui-bg-${item.state == 1 ? 'green' : 'gray'}">${item.state == 1 ? '启用' : '禁用'}</span><br>
|
||||
<button class="layui-btn layui-btn-primary layui-btn-radius layui-border-green layui-btn-sm edit" lay-on="edit" data-cid="${item.id}"><span class="icon pear-icon"></span>修改</button>
|
||||
</div>`;
|
||||
card.innerHTML = htmlstr;
|
||||
return card;
|
||||
}
|
||||
channel.getChannelLlist = async function (mainbox, aid) {
|
||||
const url = '/api/PayManage/getChannelList';
|
||||
const info = { aid: aid };
|
||||
const res = await fetch(url, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(info) });
|
||||
if (res.status !== 200) {
|
||||
layer.msg('请求失败,请重试!', { tips: 2, time: 1200 });
|
||||
return false;
|
||||
}
|
||||
const rec_info = await res.json();
|
||||
if (rec_info.code === 0) {
|
||||
const lists = rec_info.data;
|
||||
lists.forEach(value => {
|
||||
const card = channel.buildEle(value);
|
||||
mainbox.appendChild(card);
|
||||
});
|
||||
channel.addBtn(mainbox, aid);
|
||||
} else {
|
||||
layer.msg(rec_info.msg, { icon: 2, time: 1200 });
|
||||
}
|
||||
}
|
||||
channel.addBtn = function (mainbox, aid) {
|
||||
let btn = document.createElement('div');
|
||||
btn.className = 'layui-card';
|
||||
btn.innerHTML = `<button type="button" lay-on="add" data-aid="${aid}" class="layui-btn layui-btn-fluid">添加收款终端</button>`;
|
||||
mainbox.appendChild(btn);
|
||||
}
|
||||
// 生成二维码
|
||||
async function getQrcode(text, QR) {
|
||||
const qrcodeUrl = await new Promise((resolve) => {
|
||||
new QR({
|
||||
text: text,
|
||||
size: 500,
|
||||
}).draw().then((dataURL) => { resolve(dataURL); });
|
||||
})
|
||||
return qrcodeUrl;
|
||||
}
|
||||
|
||||
const mainbox = document.getElementById('mainbox');
|
||||
const aid = '<?php echo $id ?>';
|
||||
channel.getChannelLlist(mainbox, aid);
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,131 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>编辑账号</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<style>
|
||||
.inputTxt {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form id="edit-account" class="layui-form layui-form-pane" action="" lay-filter="edit-account">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">账号ID</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid inputTxt">
|
||||
<?php echo $id ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款平台</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="platform">
|
||||
<option value="">收款平台</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">登陆密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="password" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">启用</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="state" class="layui-input" lay-skin="switch" lay-text="启用|禁用">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">监听模式</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="pattern">
|
||||
<option value="请选择"></option>
|
||||
<?php include_once '../view/tpl/pattern.html'; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="save-account">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['form'], function () {
|
||||
let form = layui.form;
|
||||
|
||||
// 渲染插件选项
|
||||
(async () => {
|
||||
const data = await fetch('/api/Plugin/pluginOption').then(res => res.json());
|
||||
let option_str = `<option value="">收款平台</option>`;
|
||||
data.forEach(val => {
|
||||
option_str += `<option value="${val.platform}">${val.name}</option>`;
|
||||
});
|
||||
const select = document.querySelector('select[name="platform"]');
|
||||
select.innerHTML = option_str;
|
||||
form.render('select');
|
||||
// 初始化表单
|
||||
form.val('edit-account', {
|
||||
"platform": "<?php echo $platform ?>",
|
||||
"account": "<?php echo $account ?>",
|
||||
"password": "<?php echo $password ?>",
|
||||
"state": '<?php echo $state ?>' == 1 ? true : false,
|
||||
"pattern": "<?php echo $pattern ?>",
|
||||
});
|
||||
})()
|
||||
form.on('submit(save-account)', function (obj) {
|
||||
let field = obj.field;
|
||||
field.state = 'state' in field ? 1 : 0;
|
||||
field.id = '<?php echo $id ?>';
|
||||
(async () => {
|
||||
const url = '/api/PayManage/editAccount';
|
||||
const info = field;
|
||||
const res = await fetch(url, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(info) });
|
||||
if (res.status !== 200) {
|
||||
layer.msg('请求失败,请重试!', { tips: 2, time: 1200 });
|
||||
return false;
|
||||
}
|
||||
const rec_info = await res.json();
|
||||
if (rec_info.code === 0) {
|
||||
layer.msg(rec_info.msg, { icon: 1, time: 1200 }, () => {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页
|
||||
parent.layui.table.reload("account-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(rec_info.msg, { icon: 2, time: 1200 });
|
||||
}
|
||||
})()
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,124 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>修改收款终端</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<style>
|
||||
.inputTxt {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form id="edit-channel" class="layui-form layui-form-pane" action="" lay-filter="edit-channel">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">平台</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid inputTxt">
|
||||
<?php echo $platform ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid inputTxt">
|
||||
<?php echo $account ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">终端编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="channel" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">付款链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="qrcode" autocomplete="off" lay-affix="upload-drag"
|
||||
lay-filter="scanning" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">最后使用</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid inputTxt">
|
||||
<?php echo $last_time ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">启用</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="state" class="layui-input" lay-skin="switch" lay-text="启用|禁用">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['form'], function () {
|
||||
let form = layui.form;
|
||||
|
||||
form.val('edit-channel', {
|
||||
"channel": "<?php echo $channel ?>",
|
||||
"qrcode": "<?php echo $qrcode ?>",
|
||||
"state": '<?php echo $state ?>' == 1 ? true : false
|
||||
});
|
||||
|
||||
form.on('input-affix(scanning)', function () {
|
||||
window.open('https://cli.im/deqr', '_blank');
|
||||
});
|
||||
|
||||
form.on('submit(save)', function (obj) {
|
||||
let field = obj.field;
|
||||
field.state = 'state' in field ? 1 : 0;
|
||||
field.id = '<?php echo $cid ?>';
|
||||
(async () => {
|
||||
const url = '/api/PayManage/editChannel';
|
||||
const info = field;
|
||||
const res = await fetch(url, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(info) });
|
||||
if (res.status !== 200) {
|
||||
layer.msg('请求失败,请重试!', { tips: 2, time: 1200 });
|
||||
return false;
|
||||
}
|
||||
const rec_info = await res.json();
|
||||
if (rec_info.code === 0) {
|
||||
layer.msg(rec_info.msg, { icon: 1, time: 1200 }, () => {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页
|
||||
parent.window.location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(rec_info.msg, { icon: 2, time: 1200 });
|
||||
}
|
||||
})()
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,257 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>收款管理</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
</head>
|
||||
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form layui-form-pane" action="" id="serch-form">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">收款平台</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="platform">
|
||||
<option value="">收款平台</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">启用</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="state">
|
||||
<option value="">请选择</option>
|
||||
<option value="1">启用</option>
|
||||
<option value="0">禁用</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">监听模式</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="pattern">
|
||||
<option value="">请选择</option>
|
||||
<?php include_once '../view/tpl/pattern.html'; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">收款账号</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="account" autocomplete="off" class="layui-input" placeholder="请输入">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button type="submit" class="pear-btn pear-btn-md pear-btn-primary" lay-submit
|
||||
lay-filter="query">
|
||||
<i class="layui-icon layui-icon-search"></i>
|
||||
查询
|
||||
</button>
|
||||
<button type="button" lay-on="reset" class="pear-btn pear-btn-md">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="account-table" lay-filter="account-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/html" id="account-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="addAccount">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
添加
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="delAccount">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
</script>
|
||||
<script type="text/html" id="account-state">
|
||||
<input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="accountEnable" {{ d.state == 1 ? 'checked' : '' }} />
|
||||
</script>
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['table', 'form', 'common', 'util'], function () {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let common = layui.common;
|
||||
let util = layui.util;
|
||||
|
||||
// 渲染插件选项
|
||||
(async () => {
|
||||
const data = await fetch('/api/Plugin/pluginOption').then(res => res.json());
|
||||
let option_str = `<option value="">收款平台</option>`;
|
||||
data.forEach(val => {
|
||||
option_str += `<option value="${val.platform}">${val.name}</option>`;
|
||||
});
|
||||
const select = document.querySelector('select[name="platform"]');
|
||||
select.innerHTML = option_str;
|
||||
form.render('select');
|
||||
})()
|
||||
|
||||
let cols = [[
|
||||
{ type: 'checkbox' },
|
||||
{ title: '平 台', field: 'platform', align: 'center', templet: '' },
|
||||
{ title: '账 号', field: 'account', align: 'center' },
|
||||
{ title: '密 码', field: 'password', align: 'center' },
|
||||
{ title: '启用状态', field: 'state', align: 'center', templet: '#account-state' },
|
||||
{ title: '监听模式', field: 'pattern', align: 'center' },
|
||||
{ title: '终端数量', field: 'channel', align: 'center', templet: '<div><a href="javascript:;" lay-event="channelList"><span class="layui-badge layui-bg-green">{{= d.channel }}</span></a></div>' },
|
||||
{ title: '操作', align: 'center', fixed: 'right', templet: '<div><a href="javascript:;" class="layui-font-green" lay-event="edit"><strong>编辑</strong></a></div>' }
|
||||
]]
|
||||
|
||||
table.render({
|
||||
id: 'account-table',
|
||||
elem: '#account-table',
|
||||
url: '/api/PayManage/getPayAccount',
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
toolbar: '#account-toolbar',
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
});
|
||||
|
||||
// 事件处理
|
||||
|
||||
// 表格单元格事件
|
||||
table.on('tool(account-table)', function (obj) {
|
||||
const id = obj.data.id;
|
||||
if (obj.event === 'edit') {
|
||||
account.editAccount(id);
|
||||
} else if (obj.event === 'channelList') {
|
||||
account.channelList(id);
|
||||
}
|
||||
});
|
||||
// 表格头部按钮事件
|
||||
table.on('toolbar(account-table)', function (obj) {
|
||||
if (obj.event === 'refresh') {
|
||||
table.reload('account-table');
|
||||
} else if (obj.event === 'addAccount') {
|
||||
account.addAccount();
|
||||
} else if (obj.event === 'delAccount') {
|
||||
layer.confirm('确定删除账户?', { icon: 3, title: '提示' },
|
||||
function (index) {
|
||||
const pagedata = table.checkStatus(obj.config.id)
|
||||
let select_id = [];
|
||||
pagedata.data.forEach(val => {
|
||||
select_id.push(val.id);
|
||||
});
|
||||
httpJSON('/api/PayManage/delAccount', { ids: select_id })
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
});
|
||||
// 表单自定义事件监听
|
||||
form.on('submit(query)', function (obj) {
|
||||
const field = obj.field;
|
||||
let new_field = {};
|
||||
for (const key in field) {
|
||||
if (field.hasOwnProperty.call(field, key)) {
|
||||
const value = field[key];
|
||||
if (value) {
|
||||
new_field[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
table.reload('account-table', { where: new_field });
|
||||
return false;
|
||||
});
|
||||
// 启用状态
|
||||
form.on('switch(accountEnable)', function (obj) {
|
||||
const state = obj.elem.checked == true ? 1 : 0;
|
||||
const id = obj.value;
|
||||
const field = { state: state, id: id };
|
||||
account.accountEnable(obj, field);
|
||||
return false;
|
||||
});
|
||||
// 监听重置按钮
|
||||
util.on({
|
||||
reset: function () {
|
||||
document.querySelector('#serch-form').reset();
|
||||
table.reload('account-table', { where: {} });
|
||||
}
|
||||
});
|
||||
|
||||
// 操作方法
|
||||
let account = {};
|
||||
|
||||
// 编辑
|
||||
account.editAccount = function (id) {
|
||||
layer.open({
|
||||
id: 'iframe-edit-account',
|
||||
type: 2,
|
||||
title: '收款账号编辑',
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? '100%' : '500px', common.isModile() ? '100%' : '600px'],
|
||||
content: `/PayManage/editAccount?id=${id}`,
|
||||
});
|
||||
}
|
||||
// 终端列表
|
||||
account.channelList = function (id) {
|
||||
layer.open({
|
||||
id: 'iframe-channel-list',
|
||||
type: 2,
|
||||
title: '收款终端',
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? '100%' : '500px', common.isModile() ? '100%' : '700px'],
|
||||
content: `/PayManage/channelList?id=${id}`,
|
||||
});
|
||||
}
|
||||
// 添加账号
|
||||
account.addAccount = function () {
|
||||
layer.open({
|
||||
id: 'iframe-add-account',
|
||||
type: 2,
|
||||
title: '添加账号',
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? '100%' : '500px', common.isModile() ? '100%' : '500px'],
|
||||
content: `/PayManage/addAccount`,
|
||||
});
|
||||
}
|
||||
// 账户启用
|
||||
account.accountEnable = async (obj, field) => {
|
||||
const res = await fetch('/api/PayManage/accountEnable', { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(field) });
|
||||
if (res.status !== 200) {
|
||||
layer.msg('请求失败,请重试!', { tips: 2, time: 1200 }, () => { obj.elem.checked = !obj.elem.checked });
|
||||
return false;
|
||||
}
|
||||
const rec_info = await res.json();
|
||||
if (rec_info.code === 0) {
|
||||
layer.tips(rec_info.msg, obj.othis, { tips: 1, time: 1200 });
|
||||
} else {
|
||||
layer.msg(rec_info.msg, { icon: 2, time: 1200 }, () => { obj.elem.checked = !obj.elem.checked });
|
||||
}
|
||||
}
|
||||
// 请求封装
|
||||
async function httpJSON(url, info) {
|
||||
const res = await fetch(url, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(info) });
|
||||
if (res.status !== 200) {
|
||||
layer.msg('请求失败,请重试!', { tips: 2, time: 1200 });
|
||||
return false;
|
||||
}
|
||||
const rec_info = await res.json();
|
||||
if (rec_info.code === 0) {
|
||||
layer.msg(rec_info.msg, { icon: 1, time: 1200 }, () => { table.reload('account-table') });
|
||||
} else {
|
||||
layer.msg(rec_info.msg, { icon: 2, time: 1200 });
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user