日常更新

This commit is contained in:
2019-09-29 21:19:30 +08:00
parent c29b8358be
commit 07faf60918
196 changed files with 1367 additions and 524 deletions

View File

@@ -249,14 +249,14 @@ function get_nav_url($url) {
*/
function get_cover($cover_id, $field = null) {
if (empty($cover_id)) {
return BASE_PATH . '/static/images/default.png';
return '/static/common/images/default.png';
}
$picture = db('Picture')->where(array('status' => 1, 'id' => $cover_id))->find();
$picture = \think\facade\Db::name('Picture')->where(array('status' => 1, 'id' => $cover_id))->find();
if ($field == 'path') {
if (!empty($picture['url'])) {
$picture['path'] = $picture['url'] ? BASE_PATH . $picture['url'] : BASE_PATH . '/static/images/default.png';
$picture['path'] = $picture['url'] ? $picture['url'] : '/static/common/images/default.png';
} else {
$picture['path'] = $picture['path'] ? BASE_PATH . $picture['path'] : BASE_PATH . '/static/images/default.png';
$picture['path'] = $picture['path'] ? $picture['path'] : '/static/common/images/default.png';
}
}
return empty($field) ? $picture : $picture[$field];

View File

@@ -22,7 +22,8 @@ class Ad extends Admin{
$res = $adp->paginate(25, false, array(
'query' => $this->request->param()
));
$data = $res->toArray();
$data = $res->append(['show_type_text', 'status_text'])->toArray();
$this->data['data'] = $data;
return $this->data;
}
@@ -44,6 +45,7 @@ class Ad extends Admin{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'show_type' => $adp->show_type,
'info' => $info
);
@@ -71,6 +73,7 @@ class Ad extends Admin{
$info = $adp->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'show_type' => $adp->show_type,
'info' => $info
);
return $this->data;
@@ -104,7 +107,7 @@ class Ad extends Admin{
$res = $ad->paginate(25, false, array(
'query' => $this->request->param()
));
$data = $res->toArray();
$data = $res->append(['cover','status_text'])->toArray();
$this->data['data'] = $data;
return $this->data;
}

View File

@@ -9,13 +9,97 @@
namespace app\controller\admin;
use app\controller\Admin;
use app\Model\Category as CategoryModel;
class Category extends Admin{
/**
* @title 系统首页
* @title 栏目列表
*/
public function index(){
public function index(CategoryModel $category){
if($this->request->isAjax()){
$tree = $this->request->param('tree', 0);
$map = array();
$res = $category->where($map)->order('sort asc, id asc')->select();
$list = $res->toArray();
if($tree){
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
}
$this->data['data'] = $list;
return $this->data;
}
}
/**
* @title 添加栏目
*/
public function add(CategoryModel $category){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $category->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/category/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑栏目
*/
public function edit(CategoryModel $category){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $category->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/category/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $category->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除栏目
*/
public function del(CategoryModel $category){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $category->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -9,16 +9,101 @@
namespace app\controller\admin;
use app\controller\Admin;
use app\Model\Channel as ChannelModel;
class Channel extends Admin{
/**
* @title 频道列表
*/
public function index(ChannelModel $channel){
if($this->request->isAjax()){
$tree = $this->request->param('tree', 0);
$map = array();
$res = $channel->where($map)->order('sort asc, id asc')->select();
$list = $res->toArray();
if($tree){
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
}
$this->data['data'] = $list;
return $this->data;
}else{
$this->data['data'] = array(
'type' => $this->request->param('type', 0),
);
return $this->data;
}
}
/**
* @title 系统首页
* @title 添加频道
*/
public function index(){
$this->data['data'] = array(
'tree' => array()
);
return $this->data;
public function add(ChannelModel $channel){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $channel->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/channel/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑频道
*/
public function edit(ChannelModel $channel){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $channel->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/channel/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $channel->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除频道
*/
public function del(ChannelModel $channel){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $channel->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -10,12 +10,89 @@ namespace app\controller\admin;
use app\controller\Admin;
use app\model\Form as FormModel;
class Form extends Admin{
/**
* @title 系统首页
*/
public function index(){
public function index(FormModel $form){
if ($this->request->isAjax()) {
$res = $form->paginate(25, false, array(
'query' => $this->request->param()
));
$data = $res->toArray();
$this->data['data'] = $data;
return $this->data;
}
}
/**
* @title 添加客户端
*/
public function add(FormModel $form){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $form->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/form/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑客户端
*/
public function edit(FormModel $form){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $form->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/form/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $form->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除客户端
*/
public function del(FormModel $form){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $form->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -20,7 +20,8 @@ class Index extends Admin{
/**
* @title 系统首页
*/
public function index(){
public function index(Menu $menu){
$this->data['data'] = array('menu' => $menu->getMenu($this->request));
return $this->data;
}

View File

@@ -32,7 +32,11 @@ class Admin {
}
return json($this->data);
} else {
return $response->data($this->fetch());
if(\is_string($this->data) && $this->data != ''){
return $response;
}else{
return $response->data($this->fetch());
}
}
}

View File

@@ -8,7 +8,6 @@
// +----------------------------------------------------------------------
namespace app\http\middleware;
use think\facade\Cache;
use think\facade\Session;
use think\facade\View;
@@ -17,8 +16,6 @@ use think\facade\View;
*/
class AdminAuth {
protected $data = ['menu' => [], 'meta_title' => ''];
public function handle($request, \Closure $next) {
$user = Session::get('user');
@@ -28,39 +25,12 @@ class AdminAuth {
$request->isAdmin = true;
}
$this->getMenu($request); //设置菜单
$current_url = '/' . str_replace('.', '/', strtolower($request->controller())) . '/' . strtolower($request->action());
$meta_title = $current_url;
View::assign('meta_title', $meta_title);
return $next($request);
} else {
return redirect(url('admin.index/login'))->remember();
}
}
/**
* @title 显示菜单
*/
protected function getMenu($request) {
$list = [];
$current_controller = '/' . str_replace('.', '/', strtolower($request->controller()));
$current_url = $current_controller . '/' . strtolower($request->action());
$menu = Cache::get('menu');
if (!$menu) {
$res = (new \app\model\Menu())->where('is_menu', 1)->select();
foreach ($res as $key => $item) {
$menu[$item['id']] = $item->toArray();
}
Cache::set('menu', $menu);
}
foreach ($menu as $key => $value) {
if($current_url == $value['url']){
$this->data['meta_title'] = $value['title'];
}
if ($request->isAdmin || in_array($value['id'], array())) {
$list[$value['id']] = $value;
}
}
$menuList = list_to_tree($list);
$this->data['menu'] = $menuList;
View::assign($this->data);
}
}

View File

@@ -3,7 +3,18 @@ namespace app\model;
use think\Model;
class Ad extends Model
{
class Ad extends Model {
public $status = array(
1 => '开启',
0 => '关闭'
);
public function getCoverAttr($value, $data){
return get_cover($data['cover_id'], 'path');
}
public function getStatusTextAttr($value, $data){
return isset($this->status[$data['status']]) ? $this->status[$data['status']] : '未知';
}
}

View File

@@ -3,7 +3,31 @@ namespace app\model;
use think\Model;
class AdPlace extends Model
{
class AdPlace extends Model {
protected $type = array(
'start_time' => 'timestamp',
'end_time' => 'timestamp'
);
public $show_type = array(
1 => '幻灯片',
2 => '对联',
3 => '图片列表',
4 => '图文列表',
5 => '文字列表',
6 => '代码广告'
);
public $status = array(
1 => '开启',
0 => '关闭'
);
public function getShowTypeTextAttr($value, $data){
return isset($this->show_type[$data['show_type']]) ? $this->show_type[$data['show_type']] : '未知';
}
public function getStatusTextAttr($value, $data){
return isset($this->status[$data['status']]) ? $this->status[$data['status']] : '未知';
}
}

19
app/model/Category.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model;
use think\Model;
/**
* @title: À¸Ä¿Ä£ÐÍ
*/
class Category extends Model {
}

17
app/model/Form.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace app\model;
use think\Model;
class Form extends Model {
public $status = array(
1 => '开启',
0 => '关闭'
);
public function getStatusTextAttr($value, $data){
return isset($this->status[$data['status']]) ? $this->status[$data['status']] : '未知';
}
}

View File

@@ -10,12 +10,40 @@
namespace app\model;
use think\Model;
use think\Request;
use think\facade\Cache;
/**
* @title: 菜单模型
* @title: ²Ëµ¥Ä£ÐÍ
*/
class Menu extends Model {
/**
* @title ÏÔʾ²Ëµ¥
*/
public function getMenu(Request $request) {
$list = [];
$current_controller = '/' . str_replace('.', '/', strtolower($request->controller()));
$current_url = $current_controller . '/' . strtolower($request->action());
$menu = Cache::get('menu');
if (!$menu) {
$res = (new \app\model\Menu())->where('is_menu', 1)->order('sort asc, id asc')->select();
foreach ($res as $key => $item) {
$menu[$item['id']] = $item->toArray();
}
Cache::set('menu', $menu);
}
foreach ($menu as $key => $value) {
if ($request->isAdmin || in_array($value['id'], array())) {
$list[$value['id']] = $value;
}
}
$menuList = list_to_tree($list);
return $menuList;
}
public function getAuthMenuList(){
$list = $this->select();
$data = list_to_tree($list->toArray(), 'id', 'pid');

View File

@@ -318,7 +318,8 @@
}
.select2-container .select2-selection--single .select2-selection__rendered {
padding-right: 10px
padding-right: 10px;
line-height: 28px;
}
/** 表单验证 样式布局 **/

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@@ -1362,14 +1362,20 @@ $(function() {
if($('select[data-form-type="tree"]').length > 0){
$('select[data-form-type="tree"]').each(function(){
var url = $(this).data('url');
var currentId = $(this).data('value') || 0;
var tree = $(this).data('tree') || 1;
var that = this;
$.ajax({
url: url,
type: 'get',
data: {tree:1},
data: {tree:tree},
success: function(res){
$(res.data).each(function(i, item){
$(that).append('<option value="'+item.id+'">'+item.title_show+'</option>');
if(currentId == item.id){
$(that).append('<option value="'+item.id+'" selected>'+item.title_show+'</option>');
}else{
$(that).append('<option value="'+item.id+'">'+item.title_show+'</option>');
}
})
$(that).select2()
},
@@ -1394,9 +1400,11 @@ $(function() {
var laydate = layui.laydate;
var startDate = laydate.render({
elem: '#startTime',
type: 'datetime',
max: $('#endTime').val(),
theme: 'molv',
trigger: 'click',
format: 'yyyy-MM-dd HH:mm:ss',
done: function(value, date) {
// 结束时间大于开始时间
if (value !== '') {
@@ -1412,8 +1420,10 @@ $(function() {
});
var endDate = laydate.render({
elem: '#endTime',
type: 'datetime',
min: $('#startTime').val(),
theme: 'molv',
format: 'yyyy-MM-dd HH:mm:ss',
trigger: 'click',
done: function(value, date) {
// 开始时间小于结束时间

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
/** layui-v2.5.5 MIT License By https://www.layui.com */
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Some files were not shown because too many files have changed in this diff Show More