diff --git a/app/controller/Base.php b/app/controller/Base.php index f3e8f63..51c58e4 100755 --- a/app/controller/Base.php +++ b/app/controller/Base.php @@ -125,7 +125,7 @@ class Base extends BaseController return $list; } - // 获取所在一级栏目背景图 + // 获取所在一级栏目banner图 protected function firstBanner($category): array { // 一级栏目的banner @@ -143,4 +143,20 @@ class Base extends BaseController return $bgImg; } + + // 获取所在一级栏目背景图 + protected function firstBg($category) + { + // 一级栏目的banner + $firstCategoryId = Category::firstGradeId($category['path'], $category['id']); + + if ($firstCategoryId == $category['id']) { + $this->data['bg_pc'] = $category['bg']; + $this->data['bg_mobile'] = $category['bg_mobile']; + } else { + $firstCategory = Category::where('id', $firstCategoryId)->field('id,title,bg,bg_mobile')->find(); + $this->data['bg_pc'] = $firstCategory['bg']; + $this->data['bg_mobile'] = $firstCategory['bg_mobile']; + } + } } diff --git a/app/controller/manager/Category.php b/app/controller/manager/Category.php index 5c01916..4d5b358 100755 --- a/app/controller/manager/Category.php +++ b/app/controller/manager/Category.php @@ -162,6 +162,10 @@ class Category extends Base $id = input('post.id'); $img = input('post.img'); $img_mobile = input('post.img_mobile'); + + $bg_img = input('post.img_bg'); + $bg_img_mobile = input('post.img_bg_mobile'); + $icon = input('post.imgicon'); if (count($item) > 0 && (is_numeric($id) === true && $id > 0)) { Db::startTrans(); @@ -169,6 +173,8 @@ class Category extends Base validate(VCategory::class)->scene("edit")->check($item); $item['src'] = empty($img) ? '' : $img; $item['src_mobile'] = empty($img_mobile) ? '' : $img_mobile; + $item['bg'] = empty($bg_img) ? '' : $bg_img; + $item['bg_mobile'] = empty($bg_img_mobile) ? '' : $bg_img_mobile; $item['icon_img'] = empty($icon) ? '' : $icon; // 只允许文章类栏目可以设置汇总查看 @@ -239,13 +245,26 @@ class Category extends Base $item = input('post.item/a'); $img = input('post.img'); $img_mobile = input('post.img_mobile'); + + $bg_img = input('post.img_bg'); + $bg_img_mobile = input('post.img_bg_mobile'); + $icon = input('post.imgicon'); if (is_array($item) === true && count($item) > 0) { if (!empty($img)) { $item['src'] = $img; - }if (!empty($img_mobile)) { + } + if (!empty($img_mobile)) { $item['src_mobile'] = $img_mobile; } + + if (!empty($bg_img)) { + $item['bg'] = $bg_img; + } + if (!empty($bg_img_mobile)) { + $item['bg_mobile'] = $bg_img_mobile; + } + if(!empty($icon)){ $item['icon_img'] = $icon; } diff --git a/app/model/Article.php b/app/model/Article.php index 456b841..62e0ec3 100755 --- a/app/model/Article.php +++ b/app/model/Article.php @@ -165,7 +165,7 @@ class Article extends Base * @param bool $onlyChild 仅获取下级 默认true false=获取所有后代分类 * @return Paginator */ - public static function getList($categoryId, $per = 20, $keyword = '', $param = [], $status = -1, $orderList = ['sort' => 'desc'], bool $onlyChild = true) + public static function getList($categoryId, $per = 20, $keyword = '', $param = [], $status = -1, $orderList = ['top' => 'desc','sort' => 'desc'], bool $onlyChild = true) { $whereMap = []; $pageParam = []; diff --git a/app/widget/manager/Upload.php b/app/widget/manager/Upload.php index 75b733b..70583ac 100755 --- a/app/widget/manager/Upload.php +++ b/app/widget/manager/Upload.php @@ -111,6 +111,7 @@ class Upload $this->data['imgSize'] = $imgSize; $this->data['num'] = $num; $this->data['fields'] = $fields; + $this->data['fieldsJson'] = json_encode($fields, JSON_UNESCAPED_UNICODE); return $this->showView('manager/widget/multi'); } diff --git a/view/manager/article/edit.html b/view/manager/article/edit.html index 703d544..9ebb25b 100755 --- a/view/manager/article/edit.html +++ b/view/manager/article/edit.html @@ -145,7 +145,7 @@
- {:widget('manager.upload/multi',['append' => '_resource', 'imgs' => $item.other_text1??'', 'num' => 50, 'imgSize' => '1360*0px', $item['id']??''])} + {:widget('manager.upload/multi',['fields' => false,'append' => '_resource', 'imgs' => $item.other_text1??'', 'num' => 50, 'imgSize' => '1360*0px', $item['id']??''])}
diff --git a/view/manager/category/add.html b/view/manager/category/add.html index f9d1dd9..40454bd 100755 --- a/view/manager/category/add.html +++ b/view/manager/category/add.html @@ -63,15 +63,30 @@ {:widget('manager.upload/image',['append'=>'icon', 'imgSize' => $iconImgSize])} -
- + +
+
- {:widget('manager.upload/image')} + {:widget('manager.upload/image',['append' => '_bg','src' => $item['bg']??'', 'imgSize' => '1920*90'])}
- + +
+ {:widget('manager.upload/image',["append"=>"_bg_mobile",'src' => $item['bg_mobile']??'', "imgSize" => "750*90"])} +
+
+ +
+ +
+ {:widget('manager.upload/image', ["imgSize" => "750*230"])} +
+
+ +
+
{:widget('manager.upload/image',["append"=>"_mobile", "imgSize" => "750*230"])}
diff --git a/view/manager/category/edit.html b/view/manager/category/edit.html index f532d01..389a5a5 100755 --- a/view/manager/category/edit.html +++ b/view/manager/category/edit.html @@ -78,15 +78,29 @@ if(!empty($item['width']) && is_int($item['width']) && $item['width'] > 0 && !em
+
+ +
+ {:widget('manager.upload/image',['append' => '_bg','src' => $item['bg']?:'', 'imgSize' => '1920*90'])} +
+
+ +
+ +
+ {:widget('manager.upload/image',["append"=>"_bg_mobile",'src' => $item['bg_mobile']?:'', "imgSize" => "750*90"])} +
+
+
- +
{:widget('manager.upload/image',['src' => $item['src']??'', 'imgSize' => $imgSize])}
- +
{:widget('manager.upload/image',["append"=>"_mobile",'src' => $item['src_mobile']??'', "imgSize" => "750*230"])}
diff --git a/view/manager/widget/image.html b/view/manager/widget/image.html index b09050b..345a840 100755 --- a/view/manager/widget/image.html +++ b/view/manager/widget/image.html @@ -35,7 +35,7 @@