diff --git a/app/controller/Article.php b/app/controller/Article.php index 7c9a380..0efe7f4 100755 --- a/app/controller/Article.php +++ b/app/controller/Article.php @@ -31,18 +31,16 @@ class Article extends Base $keywords = $article['seo_keywords'] ?: $this->system['seo_keywords']; $title = $article['seo_title'] ?: $article['title'].' | '.$this->system['seo_title']; - $pathArr = explode(',', $category['path']); - $secondCategoryId = isset($pathArr[3]) && !empty($pathArr[3]) ? $pathArr[3] : $article['category_id']; - $secondCategory = Category::getById($secondCategoryId); - $this->data['images'] = json_decode($article['imgs'], true); + $this->data['images'] = json_decode($this->isMobile ? $article['imgs_mobile'] :$article['imgs'], true); $this->setSeo($title, $keywords, $description); $this->data['firstBg'] = $this->firstBanner($category); $this->data['item'] = MArticle::parseInfo($article); $this->data['category'] = $category; - $this->data['secondInfo'] = $secondCategory; +// $this->data['secondInfo'] = $secondCategory; $this->data['categoryId'] = $category['id']; + $this->data['categoryPath'] = Category::categoryPath($category['path']); $this->data['topCategoryId'] = Category::firstGradeId($category['path'], $category['id']); $this->detailPrevAndNext($article); $this->detailRecommendList($article, $category['recommend_num']); @@ -86,7 +84,6 @@ class Article extends Base } } - $this->data['prev'] = $prev; $this->data['next'] = $next; } @@ -118,11 +115,16 @@ class Article extends Base // 自定义分页驱动 app('think\App')->bind(Paginator::class, DxtcPageA::class); + $this->data['categoryPath'] = Category::categoryPath($category['path']); + $this->data['topCategoryId'] = Category::firstGradeId($category['path'], $categoryId); - $this->data['categoryPath'] = Category::categoryPath($category['path']); - $this->data['topCategoryId'] = Category::firstGradeId($category['path'], $categoryId); - - $this->data['items'] = MArticle::getList($categoryId, $category['number'] ?? 10); + $items = MArticle::getList($categoryId, $category['number'] ?? 10); + foreach ($items as $item) { + $item['uri'] = archiveGetUri($item); + $item['create_date_d'] = date('d', $item['create_time']); + $item['create_date_y_m'] = date('Y.m', $item['create_time']); + } + $this->data['items'] = $items; $this->data['category'] = $category; $this->data['categoryId'] = $categoryId; @@ -179,6 +181,7 @@ class Article extends Base $item['uri'] = archiveGetUri($item); $item['create_date_d'] = date('d', $item['create_time']); $item['create_date_y_m'] = date('Y-m', $item['create_time']); + $item['src'] = $this->isMobile ? $item['src_mobile'] : $item['src']; } return $this->json(0, 'ok', $items); diff --git a/app/controller/manager/Article.php b/app/controller/manager/Article.php index 8117b3d..46926c9 100755 --- a/app/controller/manager/Article.php +++ b/app/controller/manager/Article.php @@ -192,14 +192,24 @@ class Article extends Base public function edit() { if ($this->request->isPost()) { - $item = input('post.item/a'); - $img = input('post.img', ''); - $imgMobile = input('post.img_mobile', ''); - $logo = input('post.img_logo', ''); - $banner = input('post.img_banner', ''); - $video = input('post.video', ''); - $id = input('post.id/d'); - $article = MArticle::getById($id); + $item = input('post.item/a'); + $img = input('post.img', ''); + $imgMobile = input('post.img_mobile', ''); + $imgs = input('post.img_imgs', []); + $imgsMobile = input('post.img_imgs_mobile', []); + + $imgs = json_encode($imgs, true); + $imgsMobile = json_encode($imgsMobile, true); + + $item['imgs'] = $imgs; + $item['imgs_mobile'] = $imgsMobile; +// var_dump($item);exit; + + $logo = input('post.img_logo', ''); + $banner = input('post.img_banner', ''); + $video = input('post.video', ''); + $id = input('post.id/d'); + $article = MArticle::getById($id); if (empty($article)) { return $this->json(1, '该文章不存在!'); } @@ -357,6 +367,8 @@ class Article extends Base } } + $this->getImgSize($categoryId); + $this->data['item'] = $article; $this->data['category'] = $category; $this->data['imgSize'] = $imgSize; @@ -496,6 +508,8 @@ class Article extends Base $imgSize = System::getArticleImageSize(); } + $this->getImgSize($categoryId); + $this->data['category'] = $category; $this->data['imgSize'] = $imgSize; $this->data['attributeList'] = MArticle::getAttributeList([$categoryId]); diff --git a/app/controller/manager/Base.php b/app/controller/manager/Base.php index 6c209af..091b84f 100755 --- a/app/controller/manager/Base.php +++ b/app/controller/manager/Base.php @@ -86,4 +86,27 @@ class Base extends BaseController return $this->redirect(url('manager.error/jump', $result)); } + + // 根据活动 + protected function getImgSize($categoryId) + { + $pcImgSize = '';//组图 + $mobileImgSize = '';//手机组图 + $coverSize = '';//封面图 + $mobileCoverSize = '';//手机封面图 + switch ($categoryId) { + // 品牌活动 + case 39: + $pcImgSize = '1360*680px'; + $mobileImgSize = '365*185px'; + $coverSize = '340*225px'; + $mobileCoverSize = '185*120px'; + break; + } + + $this->data['pcImgSize'] = $pcImgSize; + $this->data['mobileImgSize'] = $mobileImgSize; + $this->data['coverSize'] = $coverSize; + $this->data['mobileCoverSize'] = $mobileCoverSize; + } } diff --git a/app/model/Article.php b/app/model/Article.php index 2f57b27..e87ffb3 100755 --- a/app/model/Article.php +++ b/app/model/Article.php @@ -29,18 +29,18 @@ class Article extends Base public static function getAttributeList(array $categoryIds = []) { - $data = []; + $data = []; $recommendCategoryList = []; - if(count(array_intersect($categoryIds, $recommendCategoryList)) > 0) { + if (count(array_intersect($categoryIds, $recommendCategoryList)) > 0) { $data['recommend'] = '推荐'; } // 新闻动态 $communityCategoryIds = Category::getCategoryWithChildrenIds(Category::CATEGORY_NEWS); - if(count(array_intersect($categoryIds, $communityCategoryIds)) > 0) { - $data['top'] = '置顶'; - $data['hot'] = '热门'; - $data['recommend'] = '推荐'; + if (count(array_intersect($categoryIds, $communityCategoryIds)) > 0) { + $data['top'] = '置顶'; + $data['hot'] = '热门'; + $data['recommend'] = '推荐'; } return $data; } @@ -50,7 +50,6 @@ class Article extends Base *********************************************/ - //获取最高访问的文章列表 public static function getMostVisited($limit = 5) { @@ -497,6 +496,7 @@ class Article extends Base $createTime = is_numeric($item['create_time']) ? $item['create_time'] : strtotime($item['create_time']); $item['create_date'] = date('Y-m-d', $createTime); $item['create_dateTime'] = date('Y-m-d H:i:s', $createTime); + $item['create_y_m_d'] = date('Y.m.d', $createTime); } return $item; } @@ -530,15 +530,15 @@ class Article extends Base public static function getTeam() { $categoryIds = Category::where('parent_id', Category::CATEGORY_INFO)->order('sort', 'asc')->column('title', 'id'); - $list = self::with(["archivesCategory"]) + $list = self::with(["archivesCategory"]) ->whereIn("category_id", array_keys($categoryIds)) - ->order(["sort"=>"desc","id"=>"desc"]) + ->order(["sort" => "desc", "id" => "desc"]) ->select(); - $data = []; + $data = []; foreach ($categoryIds as $categoryId => $title) { if (!isset($data[$categoryId])) { $data[$categoryId]['title'] = $title; - $data[$categoryId]['list'] = []; + $data[$categoryId]['list'] = []; } foreach ($list as $item) { if ($item['category_id'] == $categoryId) { @@ -552,18 +552,18 @@ class Article extends Base public static function getIndexTop($categoryId) { return self::with(["archivesCategory"]) - ->where("category_id",$categoryId) - ->where("top",1) - ->order(["sort"=>"desc"]) + ->where("category_id", $categoryId) + ->where("top", 1) + ->order(["sort" => "desc"]) ->find(); } - public static function getIndexList($categoryId,$num) + public static function getIndexList($categoryId, $num) { return self::with(["archivesCategory"]) - ->where("category_id",$categoryId) - ->where("top","<>",1) - ->order([ 'sort' => 'desc',"id"=>"desc"]) + ->where("category_id", $categoryId) + ->where("top", "<>", 1) + ->order(['sort' => 'desc', "id" => "desc"]) ->limit($num) ->select(); } diff --git a/app/model/Category.php b/app/model/Category.php index fff3459..27939fc 100755 --- a/app/model/Category.php +++ b/app/model/Category.php @@ -11,7 +11,7 @@ class Category extends Base { // 文章类 // 新闻动态 - public const CATEGORY_NEWS = 7; + public const CATEGORY_NEWS = 22; //企业简介 public const CATEGORY_INFO = 3; //团队管理 @@ -496,6 +496,6 @@ class Category extends Base $arr[] = $id; } } - return Category::whereIn('id', $arr)->field('id,title,src,src_mobile,path,route')->select()->toArray(); + return Category::whereIn('id', $arr)->field('id,title,src,src_mobile,path,route,url')->select()->toArray(); } } diff --git a/route/app.php b/route/app.php index 702506a..87ed732 100755 --- a/route/app.php +++ b/route/app.php @@ -19,6 +19,8 @@ Route::get('/', 'index/index'); Route::get('/article/detail/:id', "article/detail")->pattern(['id' => '\d+']); Route::get('article', "article/index"); Route::get('position/:id', "position/detail")->pattern(['id' => '\d+']); +Route::get('/activity/:id', "article/detail")->pattern(['id' => '\d+']); +Route::get('/news/:id', "article/detail")->pattern(['id' => '\d+']); Route::get('/product/detail/:id', "product/detail")->pattern(['id' => '\d+']); Route::rule('articles/ajaxlist', 'article/ajaxList', 'GET|POST'); Route::get('articles/:category_id', "article/index"); diff --git a/view/article/activity_detail.html b/view/article/activity_detail.html new file mode 100755 index 0000000..00745b8 --- /dev/null +++ b/view/article/activity_detail.html @@ -0,0 +1,53 @@ +{layout name="layout" /} +{php} +use app\model\Category; +$childrenMenu = Category::getChildrenByParentId($topCategoryId); +{/php} + +{include file="public/about_second" /} + + +
+
+
+ +
+
+ {if !empty($images)} + {foreach $images as $img} +
+ {$img.title} +
+ {/foreach} + {/if} +
+ +
+
+ +
+
+ +
+

{$item.title}

+
{$item.sub_title}
+
+
+ +
+
+ {$item.content|raw} +
+
+ +
+ {if !empty($prev)} +
上一篇:{$prev['title']}
+ {/if} + + {if !empty($next)} +
下一篇:{$next['title']}
+ {/if} +
+
+
\ No newline at end of file diff --git a/view/article/news_detail.html b/view/article/news_detail.html index a170cc7..c845037 100755 --- a/view/article/news_detail.html +++ b/view/article/news_detail.html @@ -1,46 +1,45 @@ -{layout name="layout_two" /} +{layout name="layout" /} {php} use app\model\Category; -$position = Category::getPosition($category["id"]); +use app\model\Block; +$childrenMenu = Category::getChildrenByParentId($category['parent_id']); +$blocks = Block::getByCategoryId(Category::CATEGORY_NEWS); +$blocks = Block::convertValue($blocks); {/php} -
-
{$category['title']}
-
-
-
- -
-
-
-
-
-
{$item['title']??''}
-
-
发布时间:{$item['create_time']|date="Y.m.d"}
-
文章来源:{$item['source']??'中正物业'}
-
浏览:{$item['views']}
-
-
- {$item['content']|raw} -
-
-
- {if !empty($prev)} - 上一篇:{$prev['title']} - {/if} - {if !empty($next)} - 下一篇:{$next['title']} - {/if} -
- -
-
-
- - -
-
+{include file="public/about_second" /} + + +
+
+

{$item.title}

+
+ 发布时间:{$item.create_y_m_d} + 文章来源:{$item.source ?: '中正物业'} + 浏览:{$item.views} +
+
+ {$item.content|raw} +
+ +
+ {if !empty($prev)} +
上一篇:{$prev['title']}
+ {/if} + + {if !empty($next)} +
下一篇:{$next['title']}
+ {/if} +
+
+
+ +

{$blocks['news_detail_right_title_en_1']['value']}

+ {:nl2br($blocks['news_detail_right_title_1']['value'])} +
+
+

{:nl2br($blocks['news_detail_right_title_2']['value'])}

+ {$blocks['news_detail_right_title_en_2']['value']} +
+
\ No newline at end of file diff --git a/view/article/news_list.html b/view/article/news_list.html index f606596..019e083 100755 --- a/view/article/news_list.html +++ b/view/article/news_list.html @@ -1,129 +1,110 @@ -{layout name="layout_two"/} +{layout name="layout"/} {php} use app\model\Category; use app\model\Article; use app\model\Block; -$position = Category::getPosition($category["id"]); +$childrenMenu = Category::getChildrenByParentId($topCategoryId); +$childrenCate = Category::getChildrenByParentId(Category::CATEGORY_NEWS); + $topNews = Article::getLastTopList($category["id"],1,[],["top"=>"desc"]); -$topNews = empty($topNews)?[]:$topNews[0]; -$blocks = Block::getByCategoryId(Category::CATEGORY_NEWS_BLOCK); -$blocks = Block::convertValue($blocks); +if (!$topNews->isEmpty()) { + $topNews = empty($topNews)?[]: ($topNews[0] ?? []); + $topNewsYm = date('Y.m', $topNews['create_time']); + $topNewsDay = date('d', $topNews['create_time']); +} {/php} -
-
{$category['title']}
-
-
-
- -
-
-
- {if !empty($topNews)} -
-
-
{$topNews['title']}
-
-
{$topNews['create_time']|date="Y.m.d"}
- -
- {$topNews['title']} -
-
- {$topNews['summary']} -
- 点击详情 + -
-
-
- {/if} -
-
-
- -
- 更多+ +{include file="public/about_second" /} + +{include file="public/news_second" /} + +{if !$topNews->isEmpty()} + + +{/if} + + +
+
+ {foreach $items as $item} + +
{$item.title}
+
+ {$item.create_date_y_m}.{$item.create_date_d} +

{$item.title}

+
{$item.summary}
+ 查看详情查看详情 +
+
+
+ 日期 + {$item.create_date_d} + {$item.create_date_y_m}.{$item.create_date_d}
+
+ {/foreach} -
- {if !empty($blocks['img_1'])} - - {/if} - {if !empty($blocks['img_2'])} - - {/if} - -
-
+ + +
点击加载更多
- \ No newline at end of file diff --git a/view/manager/article/add.html b/view/manager/article/add.html index 93a015d..5f21b0d 100755 --- a/view/manager/article/add.html +++ b/view/manager/article/add.html @@ -44,7 +44,7 @@
- {:widget('manager.upload/image',['imgSize' => $imgSize])} + {:widget('manager.upload/image',['imgSize' => $imgSize ?: $coverSize])}
{/if} @@ -53,7 +53,7 @@
- {:widget('manager.upload/image',['imgSize' => $imgSize, 'append' => '_mobile'])} + {:widget('manager.upload/image',['imgSize' => $imgSize ?: $mobileCoverSize, 'append' => '_mobile'])}
{/if} @@ -66,11 +66,18 @@
- {if $allowImgs} + {if in_array($category['id'], [39])}
- {:widget('manager.upload/multi',['append' => '_imgs','imgs' => $item.imgs??'', 'num' => $item.num??10, 'imgSize' => '600px*400px', $item['id']??''])} + {:widget('manager.upload/multi',['append' => '_imgs','imgs' => $item.imgs??'', 'num' => $item.num??10, 'imgSize' => $pcImgSize, $item['id']??''])} +
+
+ +
+ +
+ {//:widget('manager.upload/multi',['append' => '_imgs_mobile','imgs' => $item.imgs_mobile??'', 'num' => $item.num??10, 'imgSize' => $mobileImgSize, $item['id']??''])}
{/if} diff --git a/view/manager/article/edit.html b/view/manager/article/edit.html index afe0624..805d0cf 100755 --- a/view/manager/article/edit.html +++ b/view/manager/article/edit.html @@ -55,7 +55,7 @@ break; } {/php} - {:widget('manager.upload/image',['src' => $item.src??'', 'imgSize' => $imgSize])} + {:widget('manager.upload/image',['src' => $item.src??'', 'imgSize' => $imgSize ?: $coverSize])}
{/if} @@ -64,14 +64,7 @@
- {php} - switch ($category['id']) { - case 37: - $imgSize = '365*135'; - break; - } - {/php} - {:widget('manager.upload/image',['src' => $item.src_mobile??'','imgSize' => $imgSize, 'append' => '_mobile'])} + {:widget('manager.upload/image',['src' => $item.src_mobile??'','imgSize' => $imgSize ?: $mobileCoverSize, 'append' => '_mobile'])}
{/if} @@ -84,11 +77,18 @@
- {if $allowImgs} + {if in_array($category['id'], [39])}
- {:widget('manager.upload/multi',['append' => '_imgs', 'imgs' => $item.imgs??'', 'num' => $item.num??10, 'imgSize' => '600px*400px', $item['id']??''])} + {:widget('manager.upload/multi',['append' => '_imgs', 'imgs' => $item.imgs??'', 'num' => $item.num??10, 'imgSize' => $pcImgSize, $item['id']??''])} +
+
+ +
+ +
+ {//:widget('manager.upload/multi',['append' => '_imgs_mobile','imgs' => $item.imgs_mobile??'', 'num' => $item.num??10, 'imgSize' => $mobileImgSize, $item['id']??''])}
{/if} @@ -247,7 +247,6 @@ {/if} - {/if} {/if} {if $allowTag ?? false} diff --git a/view/manager/widget/multi.html b/view/manager/widget/multi.html index be2ee61..add9794 100755 --- a/view/manager/widget/multi.html +++ b/view/manager/widget/multi.html @@ -20,7 +20,7 @@ use app\service\Image as WImage;
- +
@@ -55,7 +55,7 @@ use app\service\Image as WImage;