From dc0fcfd1eb5f19c42b2ec51208d3bca840538c92 Mon Sep 17 00:00:00 2001 From: muzi_ys <1099438829@qq.com> Date: Sun, 10 Jul 2022 21:07:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E5=A4=A7=E6=8A=8Abu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Advert.php | 235 +++++++++---- app/admin/controller/Article.php | 8 +- app/admin/controller/FriendLink.php | 18 +- app/admin/controller/Page.php | 11 +- app/admin/view/advert/index.html | 64 ++-- app/admin/view/advert/info.html | 235 +++++++++++++ app/admin/view/friend_link/index.html | 8 +- app/common/constant/Data.php | 15 +- app/common/model/Advert.php | 2 +- app/common/model/AdvertInfo.php | 45 +++ app/common/model/Document.php | 33 +- app/common/model/DocumentCategory.php | 20 -- app/common/taglib/Ape.php | 114 +++--- app/index/common.php | 50 +-- app/index/controller/Article.php | 66 ++-- app/index/controller/Index.php | 47 +++ app/index/controller/Page.php | 300 +--------------- config/filesystem.php | 4 +- .../pc/article/{article.html => detail.html} | 0 public/template/default/pc/index/about.html | 327 ------------------ public/template/default/pc/index/index.html | 2 +- public/template/default/pc/page/article.html | 56 +-- 22 files changed, 715 insertions(+), 945 deletions(-) create mode 100644 app/admin/view/advert/info.html create mode 100644 app/common/model/AdvertInfo.php rename public/template/default/pc/article/{article.html => detail.html} (100%) delete mode 100644 public/template/default/pc/index/about.html diff --git a/app/admin/controller/Advert.php b/app/admin/controller/Advert.php index a53f9c2..b162be4 100644 --- a/app/admin/controller/Advert.php +++ b/app/admin/controller/Advert.php @@ -6,6 +6,7 @@ use app\admin\extend\FormBuilder as Form; use app\admin\extend\Util as Util; use app\common\constant\Data; use app\common\model\Advert as aModel; +use app\common\model\AdvertInfo as tModel; use app\Request; use Exception; use FormBuilder\Exception\FormBuilderException; @@ -23,40 +24,24 @@ use think\facade\Route as Url; */ class Advert extends AuthController { - /** - * 广告管理 - * @return string - * @throws Exception - * @author 木子的忧伤 - * @date 2021-02-19 11:53 - */ + public function index() { return $this->fetch(); } - public function navList(Request $request) - { - return app("json")->layui(Data::ADVERT_NAV_LIST); - } - /** - * 文章列表 + * 列表 * @param Request $request - * @return mixed - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - * @author 木子的忧伤 - * @date 2021-02-15 23:26 + * @return */ public function lst(Request $request) { $where = Util::postMore([ ['title', ''], + ['status', ''], ['start_time', ''], ['end_time', ''], - ['status', ''], ['page', 1], ['limit', 20], ]); @@ -64,7 +49,7 @@ class Advert extends AuthController } /** - * 添加广告 + * 添加 * @param Request $request * @return string * @throws FormBuilderException @@ -72,47 +57,32 @@ class Advert extends AuthController public function add(Request $request) { $form = array(); - $form[] = Elm::input('title', '广告名称')->col(10); - $form[] = Elm::input('url', '链接地址')->col(10); - $form[] = Elm::frameImage('cover_path', '广告图片', Url::buildUrl('admin/image/index', array('fodder' => 'cover_path', 'limit' => 1)))->icon("ios-image")->width('96%')->height('440px')->col(10); - $form[] = Elm::input('sort', '排序')->col(10); - $form[] = Elm::select('position', '位置')->options(function () { - $options = []; - foreach (Data::ADVERT_NAV_LIST as $k => $v) { - $options[] = Elm::option($k, $v); - } - return $options; - })->col(10); - $form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10); + $form[] = Elm::input('title', '轮播组名称')->col(10); + $form[] = Elm::input('alias', '标识')->col(10); + $form[] = Elm::input('description', '描述')->col(20); + $form[] = Elm::radio('status', '状态', 1)->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(24); $form = Form::make_post_form($form, url('save')->build()); $this->assign(compact('form')); return $this->fetch("public/form-builder"); } /** - * 修改banner + * 修改 + * @param Request $request * @return string * @throws FormBuilderException */ - public function edit($id = "") + public function edit($id = '') { - if (!$id) return app("json")->fail("数据id不能为空"); + if (!$id) return app("json")->fail("项目id不能为空"); $info = aModel::get($id); - if (!$info) return app("json")->fail("没有该数据"); + if (!$info) return app("json")->fail("轮播组不存在"); $form = array(); - $form[] = Elm::input('title', '广告名称', $info['title'])->col(10); - $form[] = Elm::input('url', '链接地址', $info['url'])->col(10); - $form[] = Elm::frameImage('cover_path', '广告图片', Url::buildUrl('admin/image/index', array('fodder' => 'cover_path', 'limit' => 1)), $info['cover_path'])->icon("ios-image")->width('96%')->height('440px')->col(10); - $form[] = Elm::input('sort', '排序', $info['sort'])->col(10); - $form[] = Elm::select('position', '位置', $info['position'])->options(function () { - $options = []; - foreach (Data::ADVERT_NAV_LIST as $k => $v) { - $options[] = Elm::option($k, $v); - } - return $options; - })->col(10); - $form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10); - $form = Form::make_post_form($form, url('save', ['id' => $id])->build()); + $form[] = Elm::input('title', '轮播组名称', $info['title'])->col(10); + $form[] = Elm::input('alias', '标识', $info['alias'])->col(10); + $form[] = Elm::input('description', '描述', $info['description'])->col(20); + $form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(24); + $form = Form::make_post_form($form, url('save', ["id" => $id])->build()); $this->assign(compact('form')); return $this->fetch("public/form-builder"); } @@ -123,13 +93,165 @@ class Advert extends AuthController * @return mixed */ public function save($id = "") + { + $data = Util::postMore([ + ['title', ''], + ['alias', ''], + ['description', ''], + ['status', 1] + ]); + if ($data['title'] == "") return app("json")->fail("轮播名称不能为空"); + if ($data['alias'] == "") return app("json")->fail("标识不能为空"); + if ($id == "") { + //需要验证轮播组标识是否存在 + $info = aModel::where("alias",$data['alias'])->find($id); + if ($info) return app("json")->fail("标识已存在,请修改后重试"); + $data['create_time'] = time(); + $res = aModel::insert($data); + } else { + $data['update_time'] = time(); + $res = aModel::update($data, ['id' => $id]); + } + return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败"); + } + + + /** + * 修改字段 + * @param $id + * @return mixed + * @author 木子的忧伤 + * @date 2021-02-16 23:12 + */ + public function field($id) + { + if (!$id) return app("json")->fail("参数有误,Id为空!"); + $where = Util::postMore([['field', ''], ['value', '']]); + if ($where['field'] == '' || $where['value'] == '') return app("json")->fail("参数有误!"); + return aModel::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败"); + } + + /** + * 重写删除 + * @param Request $request + * @return mixed|void + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + */ + public function del(Request $request) + { + $ids = $request->param("id", 0); + if ($ids == 0) return app("json")->fail("参数有误,Id为空!"); + if (!is_array($ids)) $ids = array_filter(explode(",", $ids)); + if (tModel::where("tab_id", "in", $ids)->count() > 0) return app("json")->fail("该配置项下有配置数据,不能删除!"); + return parent::del($request); + } + + /** + * 广告管理 + * @return string + * @throws Exception + * @author 木子的忧伤 + * @date 2021-02-19 11:53 + */ + public function info() + { + return $this->fetch(); + } + + /** + * 广告列表 + * @param Request $request + * @return mixed + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @author 木子的忧伤 + * @date 2021-02-15 23:26 + */ + public function infoList(Request $request) + { + $where = Util::postMore([ + ['title', ''], + ['start_time', ''], + ['end_time', ''], + ['status', ''], + ['page', 1], + ['limit', 20], + ]); + return app("json")->layui(tModel::systemPage($where)); + } + + /** + * 添加广告 + * @param Request $request + * @return string + * @throws FormBuilderException + */ + public function addAdvert(Request $request) + { + $form = array(); + $form[] = Elm::input('title', '广告名称')->col(10); + $form[] = Elm::input('url', '链接地址')->col(10); + $form[] = Elm::frameImage('cover_path', '广告图片', Url::buildUrl('admin/image/index', array('fodder' => 'cover_path', 'limit' => 1)))->icon("ios-image")->width('96%')->height('440px')->col(10); + $form[] = Elm::number('sort', '排序')->col(10); + $form[] = Elm::select('advert_id', '位置')->options(function () { + $options = []; + $advertList = aModel::where("status",1)->column("title","id"); + foreach ($advertList as $k => $v) { + $options[] = Elm::option($k, $v); + } + return $options; + })->col(10); + $form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10); + $form = Form::make_post_form($form, url('saveAdvert')->build()); + $this->assign(compact('form')); + return $this->fetch("public/form-builder"); + } + + /** + * 修改banner + * @return string + * @throws FormBuilderException + */ + public function editAdvert($id = "") + { + if (!$id) return app("json")->fail("数据id不能为空"); + $info = tModel::get($id); + if (!$info) return app("json")->fail("没有该数据"); + $form = array(); + $form[] = Elm::input('title', '广告名称', $info['title'])->col(10); + $form[] = Elm::input('url', '链接地址', $info['url'])->col(10); + $form[] = Elm::frameImage('cover_path', '广告图片', Url::buildUrl('admin/image/index', array('fodder' => 'cover_path', 'limit' => 1)), $info['cover_path'])->icon("ios-image")->width('96%')->height('440px')->col(10); + $form[] = Elm::number('sort', '排序', $info['sort'])->col(10); + $form[] = Elm::select('advert_id', '位置', $info['advert_id'])->options(function () { + $options = []; + $advertList = aModel::where("status",1)->column("title","id"); + foreach ($advertList as $k => $v) { + $options[] = Elm::option($k, $v); + } + return $options; + })->col(10); + $form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10); + $form = Form::make_post_form($form, url('saveAdvert', ['id' => $id])->build()); + $this->assign(compact('form')); + return $this->fetch("public/form-builder"); + } + + /** + * 保存修改 + * @param string $id + * @return mixed + */ + public function saveAdvert($id = "") { $data = Util::postMore([ ['id', ''], ['title', ''], ['url', ''], ['cover_path', ''], - ['position', 1], + ['advert_id', 1], ['sort', ''], ['status', 1], ]); @@ -139,16 +261,11 @@ class Advert extends AuthController $data['user_id'] = $this->adminId;//默认修改你 if (filter_var($data['url'], FILTER_VALIDATE_URL) === false) return app("json")->fail("链接地址不合法"); if ($id == "") { - //判断下用户是否存在 - $info = aModel::where('url', $data['url'])->find(); - if ($info) { - return app("json")->fail("链接已存在"); - } - $res = aModel::create($data); + $res = tModel::create($data); } else { - $res = aModel::update($data, ['id' => $id]); + $res = tModel::update($data, ['id' => $id]); } - cache(Data::DATA_ADVERT . '_' . $data['position'], null);//清除缓存 + cache(Data::DATA_ADVERT . '_' . $data['advert_id'], null);//清除缓存 return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败"); } } \ No newline at end of file diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index e50b433..d55887b 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -9,6 +9,7 @@ use app\common\model\DocumentCategory as cModel; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; +use app\common\constant\Data; /** * Class Article @@ -57,7 +58,7 @@ class Article extends AuthController ['page', 1], ['limit', 20], ]); - $where['type'] = Document::DOCUMENT_TYPE_ARTICLE; + $where['type'] = Data::DOCUMENT_TYPE_ARTICLE; return app("json")->layui(Document::systemPage($where)); } @@ -84,6 +85,7 @@ class Article extends AuthController ['is_recommend', 0], ['is_top', 0], ['is_hot', 0], + ['theme', 'detail.html'], ['link_str', ''], ['cover_path', ''], ['display', 1], @@ -97,7 +99,7 @@ class Article extends AuthController if ($data['category_id'] == "") return app("json")->fail("栏目分类不能为空"); if ($data['cover_path'] == "") return app("json")->fail("主图不能为空"); $model = new Document(); - $res = $model->updateInfo($data, Document::DOCUMENT_TYPE_ARTICLE); + $res = $model->updateInfo($data, Data::DOCUMENT_TYPE_ARTICLE); return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:" . $model->getError()); } @@ -155,7 +157,7 @@ class Article extends AuthController if ($where['id'] == '') { $this->error('参数错误'); } - $info = (new Document())->getInfo($where["id"], Document::DOCUMENT_TYPE_ARTICLE); + $info = (new Document())->getInfo($where["id"], Data::DOCUMENT_TYPE_ARTICLE); if (empty($info)) { $this->error('数据不存在'); } diff --git a/app/admin/controller/FriendLink.php b/app/admin/controller/FriendLink.php index 789891e..1d009b4 100644 --- a/app/admin/controller/FriendLink.php +++ b/app/admin/controller/FriendLink.php @@ -64,9 +64,9 @@ class FriendLink extends AuthController public function add() { $form = array(); - $form[] = Elm::input('title', '链接名称')->col(10); - $form[] = Elm::input('url', '链接地址')->col(10); - $form[] = Elm::frameImage('image', '网站图标', Url::buildUrl('admin/image/index', array('fodder' => 'image', 'limit' => 1)))->icon("ios-image")->width('96%')->height('440px')->col(10); + $form[] = Elm::input('title', '网站名称')->col(10); + $form[] = Elm::input('url', '网站地址')->col(10); + $form[] = Elm::frameImage('image', '网站Logo', Url::buildUrl('admin/image/index', array('fodder' => 'image', 'limit' => 1)))->icon("ios-image")->width('96%')->height('440px')->col(10); $form[] = Elm::input('sort', '排序')->col(10); $form[] = Elm::textarea('description', '描述')->col(10); $form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10); @@ -86,9 +86,9 @@ class FriendLink extends AuthController $ainfo = aModel::get($id); if (!$ainfo) return app("json")->fail("没有该数据"); $form = array(); - $form[] = Elm::input('title', '链接名称', $ainfo['title'])->col(10); - $form[] = Elm::input('url', '链接地址', $ainfo['url'])->col(10); - $form[] = Elm::frameImage('image', '网站图标', Url::buildUrl('admin/image/index', array('fodder' => 'image', 'limit' => 1)), $ainfo['image'])->icon("ios-image")->width('96%')->height('440px')->col(10); + $form[] = Elm::input('title', '网站名称', $ainfo['title'])->col(10); + $form[] = Elm::input('url', '网站地址', $ainfo['url'])->col(10); + $form[] = Elm::frameImage('image', '网站Logo', Url::buildUrl('admin/image/index', array('fodder' => 'image', 'limit' => 1)), $ainfo['image'])->icon("ios-image")->width('96%')->height('440px')->col(10); $form[] = Elm::input('sort', '排序', $ainfo['sort'])->col(10); $form[] = Elm::textarea('description', '描述', $ainfo['description'])->col(10); $form[] = Elm::radio('status', '状态', $ainfo['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10); @@ -113,14 +113,14 @@ class FriendLink extends AuthController ['sort', ''], ['status', 1], ]); - if ($data['title'] == "") return app("json")->fail("链接名称不能为空"); - if ($data['url'] == "") return app("json")->fail("链接地址不能为空"); + if ($data['title'] == "") return app("json")->fail("网站名称不能为空"); + if ($data['url'] == "") return app("json")->fail("网站地址不能为空"); if (is_array($data['image'])) $data['image'] = $data['avatar'][0]; if ($id == "") { //判断下用户是否存在 $info = aModel::where('url', $data['url'])->find(); if ($info) { - return app("json")->fail("链接已存在"); + return app("json")->fail("网站已存在"); } $data['uid'] = $this->adminId; $res = aModel::create($data); diff --git a/app/admin/controller/Page.php b/app/admin/controller/Page.php index e88be88..53f613c 100644 --- a/app/admin/controller/Page.php +++ b/app/admin/controller/Page.php @@ -8,6 +8,7 @@ use app\common\model\Document; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; +use app\common\constant\Data; /** * Class Page @@ -57,7 +58,7 @@ class Page extends AuthController ['page', 1], ['limit', 20], ]); - $where["type"] = Document::DOCUMENT_TYPE_PAGE; + $where["type"] = Data::DOCUMENT_TYPE_PAGE; return app("json")->layui(Document::systemPage($where)); } @@ -98,7 +99,7 @@ class Page extends AuthController if ($data['theme'] == "") return app("json")->fail("文章模板不能为空"); if ($data['cover_path'] == "") return app("json")->fail("主图不能为空"); $model = new Document(); - $res = $model->updateInfo($data, Document::DOCUMENT_TYPE_PAGE); + $res = $model->updateInfo($data, Data::DOCUMENT_TYPE_PAGE); return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:" . $model->getError()); } @@ -131,7 +132,7 @@ class Page extends AuthController { // 获取页面模板列表 $this->getThemeList(); - $themeList = get_theme_list(Document::DOCUMENT_TYPE_PAGE); + $themeList = get_theme_list(Data::DOCUMENT_TYPE_PAGE); $this->assign("theme_list", $themeList); return $this->fetch(); } @@ -151,12 +152,12 @@ class Page extends AuthController if ($where['id'] == '') { $this->error('数据不存在'); } - $info = (new Document())->getInfo($where["id"], Document::DOCUMENT_TYPE_PAGE); + $info = (new Document())->getInfo($where["id"], Data::DOCUMENT_TYPE_PAGE); if (empty($info)) { $this->error('数据不存在'); } // 获取页面模板列表 - $themeList = get_theme_list(Document::DOCUMENT_TYPE_PAGE); + $themeList = get_theme_list(Data::DOCUMENT_TYPE_PAGE); $this->assign("theme_list", $themeList); $this->assign("info", $info); return $this->fetch(); diff --git a/app/admin/view/advert/index.html b/app/admin/view/advert/index.html index ad3f2e6..e5913f9 100644 --- a/app/admin/view/advert/index.html +++ b/app/admin/view/advert/index.html @@ -13,11 +13,10 @@