优化后台

This commit is contained in:
taoser 2023-03-16 22:42:05 +08:00
parent 9e3a41899f
commit e2096d3c22
26 changed files with 827 additions and 537 deletions

View File

@ -22,7 +22,6 @@ use app\admin\model\Article;
use app\admin\model\Cunsult;
use think\facade\Config;
use taoler\com\Api;
use taoser\SetArr;
use app\common\lib\facade\HttpHelper;
class Index extends AdminController
@ -123,21 +122,22 @@ class Index extends AdminController
}
//版本检测
public function getVersion()
{
$verCheck = Api::urlPost($this->sys['upcheck_url'],['pn'=>$this->pn,'ver'=>$this->sys_version]);
if($verCheck->code !== -1){
return $verCheck->code ? "<span style='color:red'>有{$verCheck->up_num}个版本需更新,当前可更新至{$verCheck->version}</span>" : $verCheck->msg;
} else {
return lang('No new messages');
}
}
// public function getVersion()
// {
// $verCheck = Api::urlPost($this->sys['upcheck_url'],['pn'=>$this->pn,'ver'=>$this->sys_version]);
// if($verCheck->code !== -1){
// return $verCheck->code ? "<span style='color:red'>有{$verCheck->up_num}个版本需更新,当前可更新至{$verCheck->version}</span>" : $verCheck->msg;
// } else {
// return lang('No new messages');
// }
// }
public function checkVersion()
{
$verCheck = Api::urlPost($this->sys['upcheck_url'],['pn'=>$this->pn,'ver'=>$this->sys_version]);
if($verCheck->code !== -1){
return $verCheck->code ? "<span style='color:red'>有{$verCheck->up_num}个版本需更新,当前可更新至{$verCheck->version}</span>" : $verCheck->msg;
$data = ['pn'=>$this->pn,'ver'=>$this->sys_version];
$response = HttpHelper::withHost()->get('/v1/upload/check', $data)->toJson();
if($response->code !== -1){
return $response->code ? "<span style='color:#b2aeae'>有{$response->up_num}个版本需更新,当前可更新至{$response->version}</span>" : $response->msg;
} else {
return lang('No new messages');
}

View File

@ -1,4 +1,13 @@
<?php
/**
* @Program: TaoLer 2023/3/11
* @FilePath: app\admin\controller\login.php
* @Description: 管理后台登录页
* @LastEditTime: 2023-03-11 10:16:42
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller;
use think\facade\View;
@ -8,10 +17,9 @@ use app\admin\validate\Admin;
use think\exception\ValidateException;
use app\common\controller\AdminController;
class Login extends AdminController
{
//登录
// 登录
public function index()
{
if(Request::isAjax()){
@ -37,7 +45,7 @@ class Login extends AdminController
public function reg()
{
if(Session::has('admin_id')){
return redirect('/admin/index/index');
return redirect('index/index');
}
return View::fetch('reg');
@ -47,7 +55,7 @@ class Login extends AdminController
public function forget()
{
if(Session::has('admin_id')){
return redirect('/admin/index/index');
return redirect('index/index');
}
return View::fetch('forget');

View File

@ -19,27 +19,89 @@ use app\common\lib\FileHelper;
class Addons extends AdminController
{
/**
* 浏览插件
*
*/
public function index()
{
if(Request::isAjax()) {
$data = Request::param();
if(!isset($data['type'])) $data['type'] = 'onlineAddons';
if(!isset($data['selector'])) $data['selector'] = 'all';
return $this->getList($data);
}
// if(Request::isAjax()) {
// $data = Request::param();
// if(!isset($data['type'])) $data['type'] = 'onlineAddons';
// if(!isset($data['selector'])) $data['selector'] = 'all';
// return $this->getList($data);
// }
return View::fetch();
}
/**
* 插件动态列表
* @param $data
* @return Json
*/
public function list()
{
$param = Request::param();
$data = ['page' => $param['page'] ?? 1, 'limit' => $param['limit'] ?? 10, 'type' => $param['type'] ?? 'all'];
$res = [];
//本地插件列表
$localAddons = Files::getDirName('../addons/');
if($data['type'] == 'installed') {
$count = count($localAddons); // 安装总数
// 已安装
if ($count) {
$res = ['code' => 0, 'msg' => 'ok', 'count' => $count];
// 数组分组
$arr = array_chunk($localAddons, $data['limit']);
// 选中的页码数组
$arrAddon = $arr[$data['page'] - 1];
// $data数据
foreach ($arrAddon as $k => $v) {
$info_file = '../addons/' . $v . '/info.ini';
$info = parse_ini_file($info_file);
$info['show'] = $info['status'] ? '启用' : '禁用';
$info['install'] = $info['status'] ? '是' : '否';
$res['data'][] = $info;
}
return json($res);
}
return json(['code' => -1, 'msg' => '没有安装任何插件']);
}
// 在线插件
$response = HttpHelper::withHost()->get('/v1/addonlist', $data);
$addons = $response->toJson();
if($response->ok()) {
$res = ['code' => 0, 'msg' => 'ok', 'count' => $addons->count];
// $data数据 与本地文件对比
foreach($addons->data as $v){
if(in_array($v->name, $localAddons)) {
$info = get_addons_info($v->name);
//已安装
$v->isInstall = 1;
//判断是否有新版本
if($v->version > $info['version']) $v->have_newversion = 1;
$v->price = $v->price ? $v->price : '免费';
}
$res['data'][] = $v;
};
return json($res);
}
return json(['code' => -1, 'msg' => '未获取到服务器信息']);
}
/**
* 插件动态列表
* @param $data
* @return Json
*/
public function getList($data)
public function getList()
{
$data = Request::param();
if(!isset($data['type'])) $data['type'] = 'onlineAddons';
if(!isset($data['selector'])) $data['selector'] = 'all';
$res = [];
//本地插件列表
$addonsList = Files::getDirName('../addons/');

View File

@ -1,4 +1,13 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\addon\Template.php
* @Description: Template
* @LastEditTime: 2023-03-14 16:52:56
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\addon;
use app\common\controller\AdminController;
@ -9,7 +18,6 @@ class Template extends AdminController
public function index()
{
//
return View::fetch();
}
}

View File

@ -1,16 +1,26 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\content\Cate.php
* @Description: Cate
* @LastEditTime: 2023-03-14 15:40:53
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\content;
use app\common\controller\AdminController;
use app\common\model\Cate as CateModel;
use app\common\model\Article;
use think\facade\View;
use think\facade\Request;
use think\facade\Db;
use think\facade\Cache;
use taoler\com\Files;
use app\common\lib\Msgres;
use app\common\model\Article;
use app\common\model\Cate as CateModel;
class Cate extends AdminController
{

View File

@ -1,23 +1,29 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\content\Comment.php
* @Description: Comment
* @LastEditTime: 2023-03-14 15:38:55
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\content;
use app\common\controller\AdminController;
use app\common\model\Cate;
use app\common\model\Comment as CommentModel;
use app\common\model\Article;
use think\facade\View;
use think\facade\Request;
use think\facade\Db;
use think\facade\Cache;
use taoler\com\Files;
use app\common\lib\Msgres;
use think\response\Json;
use app\common\model\Comment as CommentModel;
class Comment extends AdminController
{
/**
* 浏览
* @return string
*/
public function index()
{
return View::fetch();
@ -68,7 +74,16 @@ class Comment extends AdminController
foreach($replys as $k => $v){
$url = $this->getRouteUrl($v['cid'],$v['ename'], $v['appname']);
//$res['data'][] = ['id'=>$v['id'],'replyer'=>$v->user->name,'cardid'=>$v->article->title,'avatar'=>$v->user->user_img,'content'=>$v['content'],'replytime'=>$v['create_time']];
$res['data'][] = ['id'=>$v['aid'],'replyer'=>$v['name'],'title'=>htmlspecialchars($v['title']),'avatar'=>$v['user_img'],'content'=>htmlspecialchars($v['content']),'replytime'=>date("Y-m-d",$v['create_time']),'check'=>$v['astatus'],'url'=>$url];
$res['data'][] = [
'id'=>$v['aid'],
'replyer'=>$v['name'],
'title'=>htmlspecialchars($v['title']),
'avatar'=>$v['user_img'],
'content'=>htmlspecialchars($v['content']),
'replytime'=>date("Y-m-d",$v['create_time']),
'check'=>$v['astatus'],
'url'=>$url
];
}
} else {
$res = ['code'=>-1,'msg'=>'没有查询结果!'];

View File

@ -1,10 +1,16 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\content\Forum.php
* @Description: Forum
* @LastEditTime: 2023-03-14 15:42:00
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\content;
use app\common\controller\AdminController;
use app\common\model\Cate;
use app\common\model\Comment;
use app\common\model\Article;
use think\facade\View;
use think\facade\Request;
@ -14,6 +20,7 @@ use taoler\com\Files;
use app\common\lib\Msgres;
use think\response\Json;
class Forum extends AdminController
{
/**
@ -86,7 +93,19 @@ class Forum extends AdminController
$res['count'] = $count;
foreach($forumList as $k=>$v){
$url = $this->getRouteUrl($v['aid'],$v['ename'],$v['appname']);
$res['data'][]= ['id'=>$v['aid'],'poster'=>$v['name'],'avatar'=>$v['user_img'],'title'=>htmlspecialchars($v['title']),'url'=>$url,'content'=>htmlspecialchars($v['content']),'posttime'=>date("Y-m-d",$v['update_time']),'top'=>$v['is_top'],'hot'=>$v['is_hot'],'reply'=>$v['is_reply'],'check'=>$v['status']];
$res['data'][]= [
'id'=>$v['aid'],
'poster'=>$v['name'],
'avatar'=>$v['user_img'],
'title'=>htmlspecialchars($v['title']),
'url' => $url,
'content' => strip_tags($v['content']),
'posttime'=>date("Y-m-d",$v['update_time']),
'top'=>$v['is_top'],
'hot'=>$v['is_hot'],
'reply'=>$v['is_reply'],
'check'=>$v['status']
];
}
} else {
$res = ['code'=>-1,'msg'=>'没有查询结果!'];

View File

@ -165,7 +165,6 @@ class Admin extends AdminController
if(Request::isAjax()){
$user = $this->model->select($ids);
$result = $user->delete();
if($result){
return json(['code'=>0,'msg'=>'删除成功']);
}else{

View File

@ -1,8 +1,16 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\system\AuthGroup.php
* @Description: AuthGroup
* @LastEditTime: 2023-03-14 16:43:59
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\system;
use app\common\controller\AdminController;
use app\admin\model\Admin as adminModel;
use think\facade\View;
use think\facade\Request;
use think\facade\Db;
@ -10,9 +18,11 @@ use think\exception\ValidateException;
use app\admin\model\AuthGroup as AuthGroupModel;
use app\admin\model\AuthGroupAccess;
use app\admin\model\AuthRule as AuthRuleModel;
use app\admin\model\Admin as adminModel;
use LDAP\Result;
use think\Response;
class AuthGroup extends AdminController
{
/**

View File

@ -1,4 +1,13 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\system\AuthRule.php
* @Description: AuthRule
* @LastEditTime: 2023-03-14 16:45:34
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\system;
use app\common\controller\AdminController;

View File

@ -1,4 +1,13 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\system\Menu.php
* @Description: Menu
* @LastEditTime: 2023-03-14 16:46:37
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\system;
use app\common\controller\AdminController;
@ -21,7 +30,7 @@ class Menu extends AdminController
$auth = new Auth();
$menu = [];
$rule = Session::has('ruleTable') ? Session::get('ruleTable') : 'auth_rule';
$auth_rule_list = Db::name($rule)->field('id,pid,title,icon,name,sort,ismenu')->where(['status'=> 1, 'ismenu'=>1, 'delete_time'=> 0])->select();
$auth_rule_list = Db::name($rule)->field('id,pid,title,icon,name,sort,ismenu')->where(['status'=> 1, 'delete_time'=> 0])->select();
foreach ($auth_rule_list as $v) {
if ($auth->check($v['name'], $this->aid) || $this->aid == 1) {
$menu[] = [
@ -30,12 +39,14 @@ class Menu extends AdminController
'icon' => 'layui-icon ' . $v['icon'],
'href' => (string) url($v['name']),
'pid' => $v['pid'],
'sort' => $v['sort']
'sort' => $v['sort'],
'ismenu' => $v['ismenu']
];
}
}
$nav = $this->getTrees($menu);
// 初始化控制台
$nav[] = [
'id' => 500,
@ -106,7 +117,7 @@ class Menu extends AdminController
// //$v['children'][$m]['type'] = 1;
// //$v['children'][$m]['openType'] = '_iframe';
// }
$v['type'] = $v['pid'] == 0 ? 0 : $v['ismenu'];
$v['type'] = $v['ismenu'];
$v['children'] = $child;
} else {
// 没有子菜单type=1

View File

@ -4,10 +4,11 @@
* @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-07-24 11:06:14
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @Description: 设置
* @FilePath: \TaoLer\app\admin\controller\Set.php
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\system;
use app\common\controller\AdminController;

View File

@ -1,5 +1,11 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\system\Upgrade.php
* @Description: Upgrade
* @LastEditTime: 2023-03-14 16:47:27
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
* 升级包规定的目录结构
* xxx_版本号.zip(xxx_1.0.0.zip)
* |
@ -27,6 +33,7 @@ use app\common\lib\SqlFile;
use app\common\lib\Zip;
use taoser\SetArr;
class Upgrade extends AdminController
{
protected $root_dir = "../"; //站点代码的根目录

View File

@ -1,15 +1,23 @@
<?php
/**
* @Program: TaoLer 2023/3/11
* @FilePath: app\admin\controller\user\User.php
* @Description: User用户管理
* @LastEditTime: 2023-03-11 10:20:47
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\user;
use app\common\controller\AdminController;
use app\admin\validate\Admin;
use think\facade\View;
use think\facade\Request;
use think\facade\Db;
use app\common\model\User as UserModel;
use app\common\lib\Uploads;
class User extends AdminController
{
@ -29,7 +37,10 @@ class User extends AdminController
if(Request::isAjax()){
$datas = Request::only(['id','name','email','sex','status']);
$map = array_filter($datas,[$this,'filtrArr']);
$user = Db::name('user')->where(['delete_time'=>0])->where($map)->order('id desc')->paginate(30);
$user = Db::name('user')->where(['delete_time'=>0])->where($map)->order('id desc')->paginate([
'list_rows' => input('limit'),
'page' => input('page')
]);
$count = $user->total();
$res = [];
if($count){

View File

@ -1,4 +1,13 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\controller\user\Vip.php
* @Description: Vip
* @LastEditTime: 2023-03-14 16:48:31
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\controller\user;
use app\common\controller\AdminController;
@ -15,7 +24,7 @@ class Vip extends AdminController
return View::fetch();
}
//显示VIP规则
// VIP列表
public function list()
{
$keys = UserViprule::select();

View File

@ -1,4 +1,12 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\model\Admin.php
* @Description: Admin
* @LastEditTime: 2023-03-14 16:50:41
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\model;

View File

@ -1,4 +1,12 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\model\AuthRule.php
* @Description: AuthRule
* @LastEditTime: 2023-03-14 16:51:30
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\model;

View File

@ -1,11 +1,18 @@
<?php
/**
* @Program: TaoLer 2023/3/14
* @FilePath: app\admin\model\System.php
* @Description: System
* @LastEditTime: 2023-03-14 16:52:00
* @Author: Taoker <317927823@qq.com>
* @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved.
*/
namespace app\admin\model;
use think\Model;
use think\facade\Cache;
class System extends Model
{

View File

@ -1,5 +1,11 @@
{extend name="public/base" /}
{block name="body"}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>新增管理员</title>
<link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
<div class="layui-form" lay-filter="layuiadmin-form-addons" id="layuiadmin-form-addons" style="padding: 20px 30px 0 0;">
{foreach name="formData" item="vo" key="k"}
@ -54,32 +60,30 @@
<input type="button" lay-submit lay-filter="LAY-addons-config-submit" id="LAY-addons-config-submit" value="确认">
</div>
</div>
{/block}
{block name="js"}
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
layui.config({
base: '/static/admin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'upload','notify'], function(){
layui.use(['upload','toast'], function(){
var $ = layui.$,upload = layui.upload,form = layui.form,notify=layui.notify;
//上传头像
upload.render({
elem: '.upload-select'
,url: "{:url('Addons/uploads')}"
,url: "{:url('addon.addons/uploads')}"
,data: {type:'image'}
,accept: 'images'
,method: 'get'
,acceptMime: 'image/*'
,done: function(res){
$(this.item).prevAll("input").val(res.url);
if(res.status == 0){
notify.success(res.msg);
if(res.status === 0){
toast.success({title:"成功",message:res.msg,position: 'topRight'});
} else {
notify.error(res.msg);
toast.error({title:"失败",message:res.msg,position: 'topRight'});
}
}
});
})
</script>
{/block}
</body>
</html>

View File

@ -2,107 +2,202 @@
<html>
<head>
<meta charset="utf-8">
<title>用户管理</title>
<title>插件管理</title>
<link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body class="pear-container">
<div class="layui-fluid">
<body class="pear-container">
<div class="layui-card">
<div class="layui-card-body">
<table id="addons-list" lay-filter="addons-list"></table>
<script type="text/html" id="toolbar">
<div class="layui-btn-group" style="padding-bottom: 10px;">
<a type="button" class="layui-btn layui-btn-sm" lay-event="allAddons" data-url="{:url('addon.addons/index',['type'=>'onlineAddons','selector'=>'all'])}">全部</a>
<a type="button" class="layui-btn layui-btn-sm" lay-event="freeAddons" data-url="{:url('addon.addons/index',['type'=>'onlineAddons','selector'=>'free'])}">免费</a>
<a type="button" class="layui-btn layui-btn-sm" lay-event="payAddons" data-url="{:url('addon.addons/index',['type'=>'onlineAddons','selector'=>'pay'])}">付费</a>
<a type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="installed" data-url="{:url('addon.addons/index',['type'=>'installed','selector'=>''])}">已安装</a>
</div>
<div class="layui-btn-group" style="padding-bottom: 10px;">
<button class="layui-btn layui-btn-danger layui-btn-sm layuiadmin-btn-admin" data-type="add">离线安装</button>
</div>
</script>
<script type="text/html" id="addons-tool">
{{# if(d.have_newversion === 1){ }}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="install" data-url="{:url('addon.addons/upgrade')}" data-userlogin="{:url('addon.addons/userLogin')}" data-ispay="{:url('addon.addons/isPay')}"><i class="layui-icon layui-icon-edit"></i>升级</a>
{{# } else { }}
{{# if(d.isInstall === 1) { }}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="config" data-url="{:url('addon.addons/config')}"><i class="layui-icon layui-icon-set"></i>设置</a>
{{# } else { }}
<a class="layui-btn layui-btn-xs" lay-event="install" data-url="{:url('Addons/install')}" data-userlogin="{:url('addon.addons/userLogin')}" data-ispay="{:url('addon.addons/isPay')}"><i class="layui-icon layui-icon-edit"></i>安装</a>
<select id="vers{{d.name}}" name="sss" class="layui-border" lay-ignore lay-filter="versSelect">
{{# d.vers.forEach(function(item, index){ }}
<option value="{{ item }}">{{ item }}</option>
{{# }); }}
</select>
{{# } }}
{{# } }}
</script>
<script type="text/html" id="buttonStatus">
<input type="checkbox" name="{{d.name}}" lay-skin="switch" lay-filter="addonsStatus" lay-text="启动|禁用" {{# if(d.status == 1){ }} checked {{# } }} data-url="{:url('addon.addons/check')}">
</script>
<script type="text/html" id="addons-installed-tool">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="config" data-url="{:url('addon.addons/config')}"><i class="layui-icon layui-icon-set"></i>设置</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="uninstall" data-url="{:url('addon.addons/uninstall')}"><i class="layui-icon layui-icon-delete"></i>卸载</a>
</script>
</div>
</div>
</div>
{include file="public/user_login" /}
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
var addonList = "{:url('addon.Addons/index')}";
layui.use(['addons','table','form','upload',"notify",'toast'], function(){
var $ = layui.jquery
,table = layui.table
,form = layui.form
,upload = layui.upload;
var notify = layui.notify;
var toast = layui.toast;
form.render('select'); // 渲染所在容器内的 select 元素
//监听版本选择
form.on('select(versSelect)', function(obj){
layer.tips(this.value + ' ' + this.name + ''+ obj.elem.checked, obj.othis);
});
<script type="text/html" id="toolbar">
<div class="layui-btn-group">
<button class="layui-btn layui-btn-sm" lay-event="allAddons">全部</button>
<button class="layui-btn layui-btn-sm" lay-event="freeAddons">免费</button>
<button class="layui-btn layui-btn-sm" lay-event="payAddons">付费</button>
<button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="installed">已安装</button>
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="add">离线安装</button>
</div>
</script>
//事件
var active = {
add: function(){
layer.open({
type: 2
,title: '添加插件'
,content: 'add.html'
,area: ['400px', '300px']
<script type="text/html" id="addons-bar">
{{# if(d.have_newversion === 1){ }}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="install" data-url="{:url('addon.addons/upgrade')}" data-userlogin="{:url('addon.addons/userLogin')}" data-ispay="{:url('addon.addons/isPay')}"><i class="layui-icon layui-icon-edit"></i>升级</a>
{{# } else { }}
{{# if(d.isInstall === 1) { }}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="config" data-url="{:url('addon.addons/config')}"><i class="layui-icon layui-icon-set"></i>设置</a>
{{# } else { }}
<a class="layui-btn layui-btn-xs" lay-event="install" data-url="{:url('addon.addons/install')}" data-userlogin="{:url('addon.addons/userLogin')}" data-ispay="{:url('addon.addons/isPay')}"><i class="layui-icon layui-icon-edit"></i>安装</a>
<select id="vers{{d.name}}" name="sss" class="layui-border" lay-ignore lay-filter="versSelect">
{{# d.vers.forEach(function(item, index){ }}
<option value="{{ item }}">{{ item }}</option>
{{# }); }}
</select>
{{# } }}
{{# } }}
</script>
<script type="text/html" id="buttonStatus">
<input type="checkbox" name="{{d.name}}" lay-skin="switch" lay-filter="addonsStatus" lay-text="启动|禁用" {{# if(d.status == 1){ }} checked {{# } }} data-url="{:url('addon.addons/check')}">
</script>
<script type="text/html" id="addons-installed-tool">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="config" data-url="{:url('addon.addons/config')}"><i class="layui-icon layui-icon-set"></i>设置</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="uninstall" data-url="{:url('addon.addons/uninstall')}"><i class="layui-icon layui-icon-delete"></i>卸载</a>
</script>
{include file="public/user_login" /}
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
var addonList = "{:url('addon.addons/getList')}";
layui.use(['addons','table','form','upload','toast'], function(){
var $ = layui.jquery
,table = layui.table
,form = layui.form
,upload = layui.upload;
var toast = layui.toast;
let LIST_URL = "{:url('addon.addons/list')}";
let cols = [[
{type: 'checkbox'},
{title: '序号', type: 'numbers'},
{field: 'title', title: '插件', width: 200},
{field: 'description', title: '简介', minWidth: 200},
{field: 'author', title: '作者', width: 100},
{field: 'price', title: '价格(元)', width: 85},
{field: 'downloads', title: '下载', width: 70},
{field: 'version', title: '版本', templet: '<div>{{d.version}} {{# if(d.have_newversion == 1){ }}<span class="layui-badge-dot"></span>{{# } }}</div>', width: 75},
{field: 'status', title: '在线', width: 70},
{title: '操作', width: 165, align: 'center', toolbar: '#addons-bar'}
]];
let col = [[
{type: 'numbers'},
{field: 'name', title: '插件', width: 120},
{field: 'title',title: '标题', width: 100},
{field: 'version', title: '版本'},
{field: 'author', title: '作者', width: 80},
{field: 'description', title: '简介', minWidth: 200},
{field: 'install', title: '安装', width: 100},
{field: 'ctime', title: '到期时间', width: 100},
{field: 'status', title: '状态', width: 95, templet: '#buttonStatus'},
{title: '操作', width: 160, 'align': 'center', toolbar: '#addons-installed-tool'}
]];
//渲染表格
var addonTable = table.render({
elem: "#addons-list",
toolbar: "#toolbar",
defaultToolbar: [],
url: LIST_URL,
cols: cols,
page: true,
limit: 10,
text: "对不起,加载出现异常!",
});
}
}
// 启动禁用
form.on('switch(addonsStatus)', function(data){
var data = data.elem;
var url = $(this).data('url');
//执行帖子审核
$.post(url,{ name: data.name },function(res){
if(res.code === 0){
toast.success({title:"成功消息",message:res.msg,position: 'topRight'});
} else {
toast.error({title:"失败消息",message:res.msg,position: 'topRight'});
}
table.reloadData("addons-list",{},'deep');
});
return false;
// table.on('tool(addons-list)',function(obj){
// console.log(obj)
// if (obj.event === 'remove') {
// window.remove(obj);
// } else if (obj.event === 'edit') {
// window.edit(obj);
// }
// })
table.on('toolbar(addons-list)', function(obj){
if(obj.event === 'installed'){
window.installed(obj.event);
} else if(obj.event === 'add'){
//window.add();
} else {
// all,free,pay
window.all(obj.event);
}
});
window.all = function (type) {
$.post(LIST_URL,{type: type}, function (res){
if(res.code === 0) {
// 重新渲染
table.reload('addons-list',{
url: LIST_URL,
where: {
type : type
},
cols: cols,
page: {
curr: 1 //重新从第 1 页开始
}
});
}
})
}
window.installed = function (type) {
$.get(LIST_URL,{type: type}, function (res){
if(res.code === 0) {
// 重新渲染
table.reload('addons-list',{
url: LIST_URL,
where: {
type : type
},
cols: col,
page: {
curr: 1 //重新从第 1 页开始
}
});
}
})
}
window.add = function(){
layer.open({
type: 2
,title: '添加插件'
,content: 'add.html'
,area: ['400px', '300px']
});
}
form.render('select'); // 渲染所在容器内的 select 元素
//监听版本选择
form.on('select(versSelect)', function(obj){
layer.tips(this.value + ' ' + this.name + ''+ obj.elem.checked, obj.othis);
});
// 启动禁用
form.on('switch(addonsStatus)', function(data){
var data = data.elem;
var url = $(this).data('url');
//执行帖子审核
$.post(url,{ name: data.name },function(res){
if(res.code === 0){
toast.success({title:"成功消息",message:res.msg,position: 'topRight'});
} else {
toast.error({title:"失败消息",message:res.msg,position: 'topRight'});
}
table.reloadData("addons-list",{},'deep');
});
return false;
});
});
$('.layui-btn.layuiadmin-btn-admin').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
});
</script>
</body>
</script>
</body>
</html>

View File

@ -1,69 +1,75 @@
{extend name="public/base" /}
{block name="body"}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>支付</title>
<link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<style>
.layui-container{background-color: #F9F9F9}
.auth-type{margin: 10px 0px;}
.order-info{margin:10px 0px; line-height: 30px;}
.pay-type{line-height: 50px;}
.soft-info{margin: 10px;}
.pay-tips{line-height:20px;text-align: center;margin-bottom: 20px;}
.layui-container{background-color: #F9F9F9}
.auth-type{margin: 10px 0px;}
.order-info{margin:10px 0px; line-height: 30px;}
.pay-type{line-height: 50px;}
.soft-info{margin: 10px;}
.pay-tips{line-height:20px;text-align: center;margin-bottom: 20px;}
</style>
<div class="layui-container">
<div class="layui-row">
<div class="auth-type">
授权
</div>
</div>
<div class="layui-row">
<div class="order-info">
<p>订单标题:<em>{$orderData.subject}</em></p>
<p>订单编号:<em>{$orderData.out_trade_no}</em></p>
<p>订单价格:<em class="scanpay-price">¥{$orderData.total_amount}</em></p>
</div>
</div>
<div class="layui-row">
<div class="layui-col-sm6">
<div class="pay-type">
<div style="padding: 5px; text-align: center;"><img src="/static/res/images/alipay.jpg" style="height:80px;"></div>
<body>
<div class="layui-container">
<div class="layui-row">
<div class="auth-type">
授权
</div>
</div>
<div class="soft-info">
<div>不支持退款</div>
<br />
<div>软件协议:本软件为原作者拥有版权权限,购买软件可以商用,禁止第三方出售行为。</div>
<div class="layui-row">
<div class="order-info">
<p>订单标题:<em>{$orderData.subject}</em></p>
<p>订单编号:<em>{$orderData.out_trade_no}</em></p>
<p>订单价格:<em class="scanpay-price">¥{$orderData.total_amount}</em></p>
</div>
</div>
<div class="layui-row">
<div class="layui-col-sm6">
<div class="pay-type">
<div style="padding: 5px; text-align: center;"><img src="/static/res/images/alipay.jpg" style="height:80px;"></div>
</div>
<div class="soft-info">
<div>不支持退款</div>
<br />
<div>软件协议:本软件为原作者拥有版权权限,购买软件可以商用,禁止出售第三方行为。</div>
</div>
</div>
<div class="layui-col-sm6">
<div class="qrcode" data-text="支付宝当面付" style="padding: 5px; text-align: center;">
<img src="{$orderData.qr_code_img}">
</div>
<div class="pay-tips">
<p>请使用支付宝扫一扫<br>扫描二维码进行支付</p>
</div>
</div>
</div>
</div>
<div class="layui-col-sm6">
<div class="qrcode" data-text="支付宝当面付" style="padding: 5px; text-align: center;">
<img src="{$orderData.qr_code_img}">
</div>
<div class="pay-tips">
<p>请使用支付宝扫一扫<br>扫描二维码进行支付</p>
</div>
</div>
</div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
var $ = layui.jquery;
var out_trade_no = "{$orderData.out_trade_no}";
var interval = setInterval(function(){
var url = 'https://www.aieok.com/pay/checkstatus.html?out_trade_no=' + out_trade_no;
$.ajax({
type: "get",
url: url,
data: {out_trade_no:out_trade_no},
dataType:"json",
success: function (res) {
// 等等支付时,一直轮询
if(res.code !== 0) {
clearInterval(interval);
}
}
})
},2500);
</script>
{/block}
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script type="text/javascript">
layui.use(['jquery'], function() {
var $ = layui.jquery;
var out_trade_no = "{$orderData.out_trade_no}";
let URL = 'https://www.aieok.com/pay/checkstatus.html?out_trade_no=' + out_trade_no;
var interval = setInterval(function () {
$.ajax({
type: "get",
url: URL,
data: {out_trade_no: out_trade_no},
dataType: "json",
success: function (res) {
// 等等支付时,一直轮询
if (res.code !== 0) {
clearInterval(interval);
}
}
})
}, 2500);
})
</script>
</body>
</html>

View File

@ -262,7 +262,6 @@
}
window.remove = function(obj) {
layer.confirm('确定要删除该用户', {
icon: 3,
title: '提示'

View File

@ -5,241 +5,241 @@
<title>权限管理</title>
<link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body class="pear-container">
<div class="layui-card">
<div class="layui-card-body">
<table id="power-table" lay-filter="power-table"></table>
</div>
</div>
<body class="pear-container">
<div class="layui-card">
<div class="layui-card-body">
<table id="power-table" lay-filter="power-table"></table>
</div>
</div>
<script type="text/html" id="power-toolbar">
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
<i class="layui-icon layui-icon-add-1"></i>
新增
</button>
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
<i class="layui-icon layui-icon-delete"></i>
删除
</button>
<button class="pear-btn pear-btn-success pear-btn-md" lay-event="expandAll">
<i class="layui-icon layui-icon-spread-left"></i>
展开
</button>
<button class="pear-btn pear-btn-success pear-btn-md" lay-event="foldAll">
<i class="layui-icon layui-icon-shrink-right"></i>
折叠
</button>
</script>
<script type="text/html" id="power-toolbar">
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
<i class="layui-icon layui-icon-add-1"></i>
新增
</button>
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
<i class="layui-icon layui-icon-delete"></i>
删除
</button>
<button class="pear-btn pear-btn-success pear-btn-md" lay-event="expandAll">
<i class="layui-icon layui-icon-spread-left"></i>
展开
</button>
<button class="pear-btn pear-btn-success pear-btn-md" lay-event="foldAll">
<i class="layui-icon layui-icon-shrink-right"></i>
折叠
</button>
</script>
<script type="text/html" id="power-bar">
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
</script>
<script type="text/html" id="power-bar">
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
</script>
<script type="text/html" id="power-type">
{{#if (d.powerType == '0') { }}
<span>目录</span>
{{# }else if(d.powerType == '1'){ }}
<span>菜单</span>
{{# }else if(d.powerType == '2'){ }}
<span>按钮</span>
{{# } }}
</script>
<script type="text/html" id="power-type">
{{#if (d.powerType == '0') { }}
<span>目录</span>
{{# }else if(d.powerType == '1'){ }}
<span>菜单</span>
{{# }else if(d.powerType == '2'){ }}
<span>按钮</span>
{{# } }}
</script>
<script type="text/html" id="power-enable">
<input type="checkbox" name="enable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="rule-enable" {{ d.enable== 1 ? 'checked' : '' }} />
</script>
<script type="text/html" id="power-enable">
<input type="checkbox" name="enable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="rule-enable" {{ d.enable== 1 ? 'checked' : '' }} />
</script>
<script type="text/html" id="icon">
<i class="layui-icon {{d.icon}}"></i>
</script>
<script type="text/html" id="icon">
<i class="layui-icon {{d.icon}}"></i>
</script>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
const RULES = "{:url('system.AuthRule/list')}";
const RULES_DELETE = "{:url('system.AuthRule/delete')}";
const RULES_ENABLE = "{:url('system.AuthRule/check')}";
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
const RULES = "{:url('system.AuthRule/list')}";
const RULES_DELETE = "{:url('system.AuthRule/delete')}";
const RULES_ENABLE = "{:url('system.AuthRule/check')}";
layui.use(['table','form','jquery','treetable'],function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let treetable = layui.treetable;
layui.use(['table','form','jquery','treetable'],function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let treetable = layui.treetable;
let MODULE_PATH = "operate/";
let MODULE_PATH = "operate/";
let cols = [
[
{type: 'checkbox'},
{field: 'powerId', width: 100, title: '权限ID'},
{field: 'powerName', minWidth: 200, title: '权限名称'},
{field: 'icon', title: '图标',templet:'#icon'},
{field: 'powerType', title: '权限类型',templet:'#power-type'},
{field: 'powerUrl', title: '权限地址', minWidth: 150},
{field: 'enable', title: '是否可用',templet:'#power-enable'},
{field: 'sort', title: '排序'},
{title: '操作',templet: '#power-bar', width: 150, align: 'center'}
]
];
let cols = [
[
{type: 'checkbox'},
{field: 'powerId', width: 100, title: '权限ID'},
{field: 'powerName', minWidth: 200, title: '权限名称'},
{field: 'icon', title: '图标',templet:'#icon'},
{field: 'powerType', title: '权限类型',templet:'#power-type'},
{field: 'powerUrl', title: '权限地址', minWidth: 150},
{field: 'enable', title: '是否可用',templet:'#power-enable'},
{field: 'sort', title: '排序'},
{title: '操作',templet: '#power-bar', width: 150, align: 'center'}
]
];
window.render = function(){
treetable.render({
treeColIndex: 1,
treeSpid: 0,
treeIdName: 'powerId',
treePidName: 'parentId',
skin:'line',
treeDefaultClose: true,
toolbar:'#power-toolbar',
elem: '#power-table',
url: RULES,
page: false,
cols: cols
});
}
window.render = function(){
treetable.render({
treeColIndex: 1,
treeSpid: 0,
treeIdName: 'powerId',
treePidName: 'parentId',
skin:'line',
treeDefaultClose: true,
toolbar:'#power-toolbar',
elem: '#power-table',
url: RULES,
page: false,
cols: cols
});
}
render();
render();
table.on('tool(power-table)',function(obj){
if (obj.event === 'remove') {
window.remove(obj);
} else if (obj.event === 'edit') {
window.edit(obj);
}
})
table.on('toolbar(power-table)', function(obj){
if(obj.event === 'add'){
window.add();
} else if(obj.event === 'refresh'){
window.refresh();
} else if(obj.event === 'batchRemove'){
window.batchRemove(obj);
} else if(obj.event === 'expandAll'){
treetable.expandAll("#power-table");
} else if(obj.event === 'foldAll'){
treetable.foldAll("#power-table");
}
});
form.on('switch(rule-enable)', function(obj) {
layer.tips(this.value + ' ' + this.name + '' + obj.elem.checked, obj.othis);
var status = obj.elem.checked ? 1 : -1;
//执行用户审核
$.ajax({
type:'post',
url: RULES_ENABLE,
data:{"id":this.value,"status":status},
dataType:'json',
success:function(res){
if(res.code === 0){
layer.msg(res.msg,{
icon:res.icon,
time:2000
}
//,function(){location.reload();}
);
} else {
layer.open({
title:'审核失败',
content:res.msg,
icon:5,
adim:6
})
}
}
});
return false;
});
window.add = function(){
layer.open({
type: 2,
title: '新增',
shade: 0.1,
area: ['450px', '500px'],
content: 'add.html'
});
}
window.edit = function(obj){
console.log(obj.data.powerId)
layer.open({
type: 2,
title: '修改',
shade: 0.1,
area: ['450px', '500px'],
content: 'edit.html?id=' + obj.data.powerId
});
}
window.remove = function(obj){
layer.confirm('确定要删除该权限', {icon: 3, title:'提示'}, function(index){
layer.close(index);
let loading = layer.load();
$.ajax({
url: RULES_DELETE+"?id="+obj.data['powerId'],
dataType:'json',
type:'delete',
success:function(result){
layer.close(loading);
if(result.code === 0){
layer.msg(result.msg,{icon:1,time:1000},function(){
obj.del();
});
}else{
layer.msg(result.msg,{icon:2,time:1000});
}
table.on('tool(power-table)',function(obj){
if (obj.event === 'remove') {
window.remove(obj);
} else if (obj.event === 'edit') {
window.edit(obj);
}
})
});
}
window.batchRemove = function(obj) {
let data = table.checkStatus(obj.config.id).data;
if (data.length === 0) {
layer.msg("未选中数据", {
icon: 3,
time: 1000
});
return false;
}
let ids = "";
for (let i = 0; i < data.length; i++) {
ids += data[i].powerId + ",";
}
ids = ids.substr(0, ids.length - 1);
layer.confirm('确定要删除这些权限', {
icon: 3,
title: '提示'
}, function(index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: MODULE_PATH + "batchRemove/" + ids,
dataType: 'json',
type: 'delete',
success: function(result) {
layer.close(loading);
if (result.success) {
layer.msg(result.msg, {
icon: 1,
time: 1000
}, function() {
table.reload('user-table');
});
} else {
layer.msg(result.msg, {
icon: 2,
time: 1000
});
}
}
})
});
}
})
</script>
</body>
table.on('toolbar(power-table)', function(obj){
if(obj.event === 'add'){
window.add();
} else if(obj.event === 'refresh'){
window.refresh();
} else if(obj.event === 'batchRemove'){
window.batchRemove(obj);
} else if(obj.event === 'expandAll'){
treetable.expandAll("#power-table");
} else if(obj.event === 'foldAll'){
treetable.foldAll("#power-table");
}
});
form.on('switch(rule-enable)', function(obj) {
layer.tips(this.value + ' ' + this.name + '' + obj.elem.checked, obj.othis);
var status = obj.elem.checked ? 1 : -1;
//执行用户审核
$.ajax({
type:'post',
url: RULES_ENABLE,
data:{"id":this.value,"status":status},
dataType:'json',
success:function(res){
if(res.code === 0){
layer.msg(res.msg,{
icon:res.icon,
time:2000
}
//,function(){location.reload();}
);
} else {
layer.open({
title:'审核失败',
content:res.msg,
icon:5,
adim:6
})
}
}
});
return false;
});
window.add = function(){
layer.open({
type: 2,
title: '新增',
shade: 0.1,
area: ['450px', '500px'],
content: 'add.html'
});
}
window.edit = function(obj){
console.log(obj.data.powerId)
layer.open({
type: 2,
title: '修改',
shade: 0.1,
area: ['450px', '500px'],
content: 'edit.html?id=' + obj.data.powerId
});
}
window.remove = function(obj){
layer.confirm('确定要删除该权限', {icon: 3, title:'提示'}, function(index){
layer.close(index);
let loading = layer.load();
$.ajax({
url: RULES_DELETE+"?id="+obj.data['powerId'],
dataType:'json',
type:'delete',
success:function(result){
layer.close(loading);
if(result.code === 0){
layer.msg(result.msg,{icon:1,time:1000},function(){
obj.del();
});
}else{
layer.msg(result.msg,{icon:2,time:1000});
}
}
})
});
}
window.batchRemove = function(obj) {
let data = table.checkStatus(obj.config.id).data;
if (data.length === 0) {
layer.msg("未选中数据", {
icon: 3,
time: 1000
});
return false;
}
let ids = "";
for (let i = 0; i < data.length; i++) {
ids += data[i].powerId + ",";
}
ids = ids.substr(0, ids.length - 1);
layer.confirm('确定要删除这些权限', {
icon: 3,
title: '提示'
}, function(index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: MODULE_PATH + "batchRemove/" + ids,
dataType: 'json',
type: 'delete',
success: function(result) {
layer.close(loading);
if (result.success) {
layer.msg(result.msg, {
icon: 1,
time: 1000
}, function() {
table.reload('user-table');
});
} else {
layer.msg(result.msg, {
icon: 2,
time: 1000
});
}
}
})
});
}
})
</script>
</body>
</html>

View File

@ -23,7 +23,7 @@
</div>
{else /}
<div class="layui-form-item">
<label class="layui-form-label">升级Key</label>
<label class="layui-form-label">网站KEY</label>
<div class="layui-form-item layui-hide">
<input type="text" name="key" value="{$ver_num.key}" class="layui-input">
</div>

View File

@ -235,7 +235,8 @@
title: '刷新',
layEvent: 'refresh',
icon: 'layui-icon-refresh',
}, 'filter', 'print', 'exports']
}, 'filter', 'print', 'exports'],
limit: 10
});
table.on('tool(user-table)', function(obj) {
@ -303,7 +304,7 @@
data:{"id":data.id,"auth":auth},
dataType:'json',
success:function(data){
if(data.code == 0){
if(data.code === 0){
layer.msg(data.msg,{
icon:6,
time:2000

View File

@ -1,78 +1,73 @@
//网站app版本发布
layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
var $ = layui.jquery,
table = layui.table,
form = layui.form,
upload = layui.upload;
var notify = layui.notify;
var toast = layui.toast;
var layer = layui.layer;
layui.define(["table", "form",'toast','common'], function (exports) {
var $ = layui.jquery, table = layui.table, form = layui.form;
let toast = layui.toast;
let layer = layui.layer;
let common = layui.common;
//渲染表格
table.render({
elem: "#addons-list",
toolbar: "#toolbar",
defaultToolbar: [],
url: addonList,
cols: [[
{type: 'checkbox'},
{title: '序号', type: 'numbers'},
{field: 'title', title: '插件', width: 200},
{field: 'description', title: '简介', minWidth: 200},
{field: 'author', title: '作者', width: 100},
{field: 'price', title: '价格(元)', width: 85},
{field: 'downloads', title: '下载', width: 70},
{field: 'version', title: '版本', templet: '<div>{{d.version}} {{# if(d.have_newversion == 1){ }}<span class="layui-badge-dot"></span>{{# } }}</div>', width: 75},
{field: 'status', title: '在线', width: 70},
{title: '操作', width: 165, align: 'center', toolbar: '#addons-tool'}
]],
page: true,
limit: 15,
height: "full-220",
text: "对不起,加载出现异常!",
});
// 重载数据
var addonReload = function (type,selector) {
$.ajax({
type: "post",
url: addonList,
data: { type: type, selector: selector },
dataType: "json",
success: function (res) {
//渲染表格
table.reload('addons-list',{
url: addonList,
where: {
type: type, selector: selector
},
cols: [res["col"]],
});
},
});
}
//头工具栏事件
table.on("toolbar(addons-list)", function (obj) {
var checkStatus = table.checkStatus(obj.config.id);
var url = $(this).data(url);
switch (obj.event) {
case "installed":
addonReload("installed","all");
break;
case "allAddons":
addonReload("onlineAddons","all");
break;
case "freeAddons":
addonReload("onlineAddons","free");
break;
case "payAddons":
addonReload("onlineAddons","pay");
break;
}
});
// 渲染表格
// table.render({
// elem: "#addons-list",
// toolbar: "#toolbar",
// defaultToolbar: [],
// url: addonList,
// cols: [[
// {type: 'checkbox'},
// {title: '序号', type: 'numbers'},
// {field: 'title', title: '插件', width: 200},
// {field: 'description', title: '简介', minWidth: 200},
// {field: 'author', title: '作者', width: 100},
// {field: 'price', title: '价格(元)', width: 85},
// {field: 'downloads', title: '下载', width: 70},
// {field: 'version', title: '版本', templet: '<div>{{d.version}} {{# if(d.have_newversion == 1){ }}<span class="layui-badge-dot"></span>{{# } }}</div>', width: 75},
// {field: 'status', title: '在线', width: 70},
// {title: '操作', width: 165, align: 'center', toolbar: '#addons-bar'}
// ]],
// page: true,
// limit: 15,
// text: "对不起,加载出现异常!",
// });
//
// // 重载数据
// var addonReload = function (type,selector) {
// $.ajax({
// type: "post",
// url: addonList,
// data: { type: type, selector: selector },
// dataType: "json",
// success: function (res) {
// //渲染表格
// table.reload('addons-list',{
// url: addonList,
// where: {
// type: type, selector: selector
// },
// cols: [res["col"]],
// });
// },
// });
// }
//
// //头工具栏事件
// table.on("toolbar(addons-list)", function (obj) {
// var checkStatus = table.checkStatus(obj.config.id);
//
// switch (obj.event) {
// case "installed":
// addonReload("installed","all");
// break;
// case "allAddons":
// addonReload("onlineAddons","all");
// break;
// case "freeAddons":
// addonReload("onlineAddons","free");
// break;
// case "payAddons":
// addonReload("onlineAddons","pay");
// break;
// }
// });
var api = {
userinfo: {
@ -92,6 +87,7 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
//监听工具条
table.on("tool(addons-list)", function (obj) {
var data = obj.data;
var event = obj.event;
var url = $(this).data('url')
@ -100,15 +96,14 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
var install = function (data,url,userLoginUrl,userIsPayUrl){
var userinfo = api.userinfo.get(); // 检测权限
if(userinfo) {
layer.confirm("确认安装吗?", "vcenter",function(){
var index = layer.load(1);
layer.confirm("确认安装吗?", "vcenter",function(index){
$.post(url, { name: data.name, version: data.version, uid: userinfo.uid, token: userinfo.token }, function (res) {
// 需要支付
if (res.code === -2) {
layer.close(index);
layer.open({
type: 2,
area: ['55%', '75%'],
area: [common.isModile()?'100%':'800px', common.isModile()?'100%':'600px'],
fixed: false, //不固定
maxmin: true,
content: 'pay.html'+ "?id=" + data.id+ "&name=" + data.name + "&version=" + data.version + "&uid=" + userinfo.uid + "&price=" + data.price,
@ -130,13 +125,11 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
if (res.code === 0) {
layer.close(index);
toast.success({title:"安装成功",message:res.msg,position: 'topRight'});
//notify.success(res.msg, "topRight");
}
// 安装失败
if (res.code === -1) {
layer.close(index);
toast.error({title:"安装失败",message:res.msg,position: 'topRight'});
//notify.error(res.msg, "topRight");
}
// 重载
table.reloadData("addons-list",{},'deep');
@ -166,7 +159,6 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
};
if (!data.name || !data.password) {
toast.error({title:"安装失败",message:'Account Or Password Cannot Empty',position: 'topRight'});
//notify.error('Account Or Password Cannot Empty');
return false;
}
$.ajax({
@ -177,16 +169,12 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
toast.success({title:"登录成功",message:res.msg,position: 'topRight'}, function (){
location.reload();
});
// notify.success("登录成功", function (){
// location.reload();
// });
} else {
toast.warning({title:"警告消息",message:res.msg});
//notify.alert(res.msg);
}
}, error: function (res) {
toast.error({title:"登录失败",message:res.msg,position: 'topRight'});
//notify.error(res.msg);
}
})
},
@ -210,19 +198,17 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
// 卸载插件
if (event === "uninstall") {
notify.confirm("确认框", "vcenter",function() {
var index = layer.load(1);
layer.confirm("是否卸载?", "vcenter",function(index) {
$.post(url, { name: data.name }, function (res) {
if (res.code === 0) {
toast.success({title:"卸载成功",message:res.msg,position: 'topRight'});
//notify.success(res.msg, "topRight");
} else {
toast.error({title:"卸载失败",message:res.msg,position: 'topRight'});
//notify.error(res.msg, "topRight");
}
});
table.reload("addons-list");
layer.close(index);
table.reload("addons-list");
});
}
@ -232,7 +218,6 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
// 无配置项拦截
if (res.code === -1) {
toast.warning({title:"警告消息",message:res.msg,position: 'topRight'})
//notify.alert(res.msg);
return false;
}
layer.open({
@ -256,10 +241,8 @@ layui.define(["table", "form", "upload","notify",'toast'], function (exports) {
success: function (res) {
if (res.code === 0) {
toast.success({title:"成功消息",message:res.msg,position: 'topRight'});
//notify.success(res.msg, "topRight");
} else {
toast.error({title:"失败消息",message:res.msg,position: 'topRight'});
//notify.error(res.msg, "topRight");
}
},
});