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" /} + + +
{$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']} +