From cf99120dba0cdd82781cb182ab71b78f381c62be Mon Sep 17 00:00:00 2001 From: yin5th <541304803@qq.com> Date: Fri, 4 Nov 2022 19:06:14 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A4=A7=E4=BA=8B=E8=AE=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/manager/article/add.html | 51 ++++++++++++++------ view/manager/article/edit.html | 54 ++++++++++++++++++---- view/manager/content/article.html | 28 +++++++---- view/manager/widget/multi.html | 20 +++++--- view/page/history.html | 77 ++++++++++++++++++++++--------- view/public/about_second.html | 2 +- 6 files changed, 173 insertions(+), 59 deletions(-) diff --git a/view/manager/article/add.html b/view/manager/article/add.html index 0f42bc6..d559f00 100755 --- a/view/manager/article/add.html +++ b/view/manager/article/add.html @@ -45,14 +45,27 @@ --> {if !(in_array($category['id'],[4,5,7,9,10]))}
- + {php} + $subtitle = '副标题'; + $titleNotice = ''; + $titleValue = ''; + switch ($category['id']) { + case 37: + $subtitle = '月份'; + $titleValue = 1; + $titleNotice = '月份必填 不填则默认为1月'; + break; + } + {/php} +
- + +
{$titleNotice}
{/if} - {if !(in_array($category['id'],[5]))} + {if !(in_array($category['id'],[5,37]))}
@@ -61,7 +74,7 @@
{/if} - {if !(in_array($category['id'],[5,42]))} + {if !(in_array($category['id'],[5,37,42]))}
@@ -78,14 +91,27 @@
- {if in_array($category['id'], [39,9,10,23,24,25])} + {if in_array($category['id'], [39,9,10,23,24,25,37])}
- + {php} + $imgName = 'PC组图'; + $pcImgSize = ''; + + switch ($category['id']) { + case 37: + $imgName = '大事记'; + $pcImgSize = '645*385'; + break; + } + {/php} +
{:widget('manager.upload/multi',['append' => '_imgs','imgs' => $item.imgs??'', 'num' => $item.num??10, 'imgSize' => $pcImgSize, $item['id']??''])}
+ {/if} + {if in_array($category['id'], [39,9,10,23,24,25])}
@@ -94,7 +120,7 @@
{/if} - {if in_array($category['id'], [24])} + {if in_array($category['id'], [9,10,23,24,42])}
@@ -154,20 +180,17 @@ --> {if !isset($allowSummary) || $allowSummary} - {if !(in_array($category['id'],[4,5,9,10,6,35,36,42]))} + {if !(in_array($category['id'],[4,5,9,10,6,35,36,37,42]))}
- {if $category['id'] == 37} - - {elseif $category['id'] == 38} + {if $category['id'] == 38} {else /} {/if}
- -
注:建议200字以内{if $category['id'] == 37} 大事记月份后需使用空格分割 如:1月 - 中正物业正式入驻鑫苑小区、光明A区、巴音孟克商业综合体办公楼。{/if}
+ +
注:建议200字以内
diff --git a/view/manager/article/edit.html b/view/manager/article/edit.html index f943405..703d544 100755 --- a/view/manager/article/edit.html +++ b/view/manager/article/edit.html @@ -5,10 +5,19 @@
- + {php} + $title = '标题'; + $titleNotice = '注:建议60个字符长度以内'; + switch ($category['id']) { + case 37: + $title = '年份'; + break; + } + {/php} +
-
注:建议60个字符长度以内
+
{$titleNotice}
@@ -49,14 +58,27 @@ --> {if !(in_array($category['id'],[4,5,7]))}
- + {php} + $subtitle = '副标题'; + $titleNotice = ''; + $titleValue = $item['sub_title']; + switch ($category['id']) { + case 37: + $subtitle = '月份'; + $titleNotice = '月份必填 不填则默认为1月'; + $titleValue = $item['sub_title'] ?: 1; + break; + } + {/php} +
- + +
{$titleNotice}
{/if} - {if !(in_array($category['id'],[5]))} + {if !(in_array($category['id'],[5,37]))}
@@ -72,7 +94,7 @@
{/if} - {if !(in_array($category['id'],[5,42]))} + {if !(in_array($category['id'],[5,37,42]))}
@@ -89,14 +111,28 @@
- {if in_array($category['id'], [39,9,10,23,24,25])} + {if in_array($category['id'], [39,9,10,23,24,25,37])}
- + {php} + $imgName = 'PC组图'; + $pcImgSize = ''; + + switch ($category['id']) { + case 37: + $imgName = '大事记'; + $pcImgSize = '645*385'; + break; + } + {/php} + +
{:widget('manager.upload/multi',['append' => '_imgs', 'imgs' => $item.imgs??'', 'num' => $item.num??10, 'imgSize' => $pcImgSize, $item['id']??''])}
+ {/if} + {if in_array($category['id'], [39,9,10,23,24,25])}
@@ -105,7 +141,7 @@
{/if} - {if in_array($category['id'], [24])} + {if in_array($category['id'], [9,10,23,24,42])}
diff --git a/view/manager/content/article.html b/view/manager/content/article.html index b8fc973..abff175 100755 --- a/view/manager/content/article.html +++ b/view/manager/content/article.html @@ -56,14 +56,17 @@ use app\model\Category as VCategory; - {if $category.id!=5} + {if !in_array($category.id, [5, 37])} {/if} - {if $category.id!=42} + {if !in_array($category.id, [42, 37])} {/if} + {if in_array($category.id, [37])} + + {/if} {if !empty($attributeList)} @@ -75,13 +78,19 @@ use app\model\Category as VCategory; - {if $category.id!=5} + {if !in_array($category.id, [5, 37])} {/if} - {if $category.id!=42} + {if !in_array($category.id, [42, 37])} {/if} - + {switch $category.id} + {case 37}{/case} + {default /} + {/switch} + {if in_array($category.id, [37])} + + {/if} @@ -97,14 +106,14 @@ use app\model\Category as VCategory; {foreach name="list" item="item"} - {if $category.id!=5} + {if !in_array($category.id, [5, 37])} {/if} - {if $category.id!=42} + {if !in_array($category.id, [42, 37])} {/if} - + {if in_array($category.id, [37])} + + {/if} + {if !empty($attributeList)} diff --git a/view/manager/widget/multi.html b/view/manager/widget/multi.html index e1975a1..a17fec5 100755 --- a/view/manager/widget/multi.html +++ b/view/manager/widget/multi.html @@ -1,7 +1,7 @@ {php} use app\service\Image as WImage; {/php} -
+
{if !empty($imgs)} @@ -26,7 +26,11 @@ use app\service\Image as WImage;
{foreach $fields as $name => $desc} + {if $name == 'desc'} + + {else} + {/if} {/foreach}
@@ -149,7 +153,7 @@ use app\service\Image as WImage; if(data.data.length > 0){ html += '
    ' $.each(data.data,function(i,item){ - html += '
  • ' + html += '
  • ' }) html += '
'; if(data.data.length >= 30){ @@ -187,11 +191,15 @@ use app\service\Image as WImage; }); function imgListUrl(obj, numid){ let append = $(obj).data('append'); - let fields = $(obj).data('fields'); + let fields = {:json_encode($fields, 256)}; let fieldsHtml = ''; - $.each(fields, function (index, item) { - fieldsHtml += ``; - }) + for (let key in fields) { + if (key == 'desc') { + fieldsHtml += ``; + } else { + fieldsHtml += ``; + } + } var imTpl = '
'+ '
'+ '
'+ diff --git a/view/page/history.html b/view/page/history.html index 6ec5180..81da8d9 100755 --- a/view/page/history.html +++ b/view/page/history.html @@ -4,6 +4,27 @@ use app\model\Article; use app\model\Category; $childrenMenu = Category::getChildrenByParentId(Category::CATEGORY_COMPANY); $items = Article::getList(Category::CATEGORY_COMPANY_EVENT, 1000); +$items = $items->toArray(); +$items = $items['data']; +$years = array_unique(array_column($items, 'title')); +rsort($years); + +$yearList = []; +foreach ($items as $item) { + foreach($years as $year) { + if (!isset($yearList[$item['title']])) { + $yearList[$item['title']] = []; + } + + if (!isset($yearList[$item['title']][$item['sub_title']])) { + $yearList[$item['title']][$item['sub_title']] = []; + } + + $yearList[$item['title']][$item['sub_title']] = $item; + } +} + +//dd($yearList[2022]);exit; {/php} {include file="public/about_second" /} @@ -25,25 +46,27 @@ $items = Article::getList(Category::CATEGORY_COMPANY_EVENT, 1000);
- {foreach $items as $item} -
+ {foreach $yearList as $year => $months} +
-

{$item.title ?? ''}

+

{$year ?? ''}

- {php} - $list = nl2br($item['summary']); - $list = explode('
', $list); - {/php} - - {foreach $list as $val} - {php} - $strExplode = explode(' ', $val, 2); - $month = count($strExplode) > 1 ? $strExplode[0] : ''; - $content = count($strExplode) > 1 ? $strExplode[1] : $val; - {/php} -

{$month}{$content}

+ {foreach $months as $month => $info} +

+ {$month ?? ''}月 + + {php} + $eventList = json_decode($info['imgs'], true); + {/php} + {foreach $eventList as $event} + + {$event.title ??''} +
+ {/foreach} +
+

{/foreach}
@@ -57,13 +80,25 @@ $items = Article::getList(Category::CATEGORY_COMPANY_EVENT, 1000);
- {foreach $items as $item} - {if $isMobile} - {$item.title ?? ''} - {else /} - {$item.title ?? ''} + {foreach $yearList as $year => $months} + {foreach $months as $month => $info} + {php} + $eventList = json_decode($info['imgs'], true); + {/php} + {foreach $eventList as $k => $event} + {if ($k == 0) } + {$event.title ?? ''} + {php}break;{/php} {/if} {/foreach} + {/foreach} + {/foreach}
-
\ No newline at end of file +
+ \ No newline at end of file diff --git a/view/public/about_second.html b/view/public/about_second.html index f810e04..1076134 100644 --- a/view/public/about_second.html +++ b/view/public/about_second.html @@ -1,7 +1,7 @@
{$categoryPath[0]['title'] ?? ''}
-
+
From ab4f24febed54bc70aaf301e6887d2f2566823d8 Mon Sep 17 00:00:00 2001 From: yin5th <541304803@qq.com> Date: Sat, 5 Nov 2022 23:35:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Base.php | 18 +++++++++++++++++- app/controller/manager/Category.php | 21 ++++++++++++++++++++- app/model/Article.php | 2 +- app/widget/manager/Upload.php | 1 + view/manager/article/edit.html | 2 +- view/manager/category/add.html | 23 +++++++++++++++++++---- view/manager/category/edit.html | 18 ++++++++++++++++-- view/manager/widget/image.html | 12 ++++++------ view/manager/widget/multi.html | 2 +- view/public/menu.html | 24 +++++++++++++++++++++--- 10 files changed, 103 insertions(+), 20 deletions(-) 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 @@
封面手机封面标题年份标题月份 创建日期 排序
{if !empty($item['src']) && file_exists('.' . $item['src'])} {/if} {if !empty($item['src_mobile']) && file_exists('.' . $item['src_mobile'])} @@ -112,7 +121,10 @@ use app\model\Category as VCategory; {$item.title}{$item.sub_title} {$item.create_time|date='Y-m-d'} {$item.sort}