diff --git a/app/index/controller/Category.php b/app/index/controller/Category.php index 57fdaad..079d3f5 100644 --- a/app/index/controller/Category.php +++ b/app/index/controller/Category.php @@ -51,10 +51,10 @@ class Category extends Common // $model_category = ModelCategory::with('posts.post')->find($id); - + $this->assign('category',$model_category); - return $this->fetch('read'.$model_category->tpl_name); + return $this->fetch('read'.$model_category->getData('tpl_name')); } /** diff --git a/app/index/controller/Post.php b/app/index/controller/Post.php new file mode 100644 index 0000000..ce4b7ba --- /dev/null +++ b/app/index/controller/Post.php @@ -0,0 +1,93 @@ +assign('post', $model_post); + + return $this->fetch(); + } + + /** + * 显示编辑资源表单页. + * + * @param int $id + * @return \think\Response + */ + public function edit($id) + { + // + } + + /** + * 保存更新的资源 + * + * @param \think\Request $request + * @param int $id + * @return \think\Response + */ + public function update(Request $request, $id) + { + // + } + + /** + * 删除指定资源 + * + * @param int $id + * @return \think\Response + */ + public function delete($id) + { + // + } +} diff --git a/app/model/Category.php b/app/model/Category.php index e2e4341..4f01d6c 100644 --- a/app/model/Category.php +++ b/app/model/Category.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace app\model; +use think\facade\Config; use think\Model; /** @@ -64,4 +65,40 @@ class Category extends Model return $list_post; } + public function getTplNameAttr($value) + { + return Config::get('view_type.category.'.$value); + } + + public function getModelParentAttr() + { + $pid = $this->getData('pid'); + + if($pid == 0){ + return $this; + } + return Category::where('id',$pid)->find(); + } + + // 返回除自身以外的其他的同级同类的分类 + public function getModelSiblingsAttr() + { + return Category::where('pid',$this->getData('pid')) + ->where('level',$this->getData('level')) + ->where('id','<>',$this->getData('id')) + ->select(); + } + + /** + * 获取同一个父元素的分类,包含自身 + * + * @return void + */ + public function getModelSameParentAttr() + { + return Category::where('pid',$this->getData('pid')) + ->where('level',$this->getData('level')) + ->select(); + } + } diff --git a/app/model/Post.php b/app/model/Post.php index 8499871..c5cb9fb 100644 --- a/app/model/Post.php +++ b/app/model/Post.php @@ -33,6 +33,18 @@ class Post extends Model return $this->hasMany(PostTag::class,'post_id'); } + public function setPublishTimeAttr($value) + { + return strtotime($value); + } + public function getPublishTimeTextAttr() + { + + $value = $this->getData('publish_time'); + return date('Y-m-d',$value); + } + + public function getCategorysListAttr() { $list_post_categorys = $this->getAttr('categorys'); @@ -50,8 +62,6 @@ class Post extends Model $list = array_column($list_post_tags->append(['tag'])->toArray(),'tag'); - $list = array2level($list); - return $list; } @@ -66,6 +76,29 @@ class Post extends Model return $desc; } + public function getDescListAttr() + { + $desc = $this->getData('desc'); + + if(empty($desc)){ + return ''; + } + $list = explode("\n", $desc); + + return $list; + } + + public function getDescHtmlAttr() + { + $desc = $this->getData('desc'); + + if(empty($desc)){ + return ''; + } + + return str_replace("\n",'
',$desc); + } + public function getStatusNameAttr() { return self::$stausNameList[$this->getData('status')]; diff --git a/config/view_type.php b/config/view_type.php index 0712bc9..67996a4 100644 --- a/config/view_type.php +++ b/config/view_type.php @@ -6,7 +6,9 @@ return [ '_product' => '产品:_product', '_case' => '案例:_case', - '_about' => '关于:_about', + '_about_1' => '关于_图块:_about_1', + '_about_2' => '关于_招聘:_about_2', + '_about_3' => '关于_时间轴:_about_3', ], 'post' => [ '' => '普通:', diff --git a/public/static/css/index.easy_blue.css b/public/static/css/index.easy_blue.css index 2cf6450..683bb9e 100644 --- a/public/static/css/index.easy_blue.css +++ b/public/static/css/index.easy_blue.css @@ -93,7 +93,7 @@ body{background: #fff;} .banner .title p{color: #606060; font-size: 36px; text-align: center; line-height: 50px; letter-spacing: 5px;} .banner .title p.en{font-size: 20px; letter-spacing: 3px;} .main-news{padding: 70px 0 80px 0;} -.main-news .content > div{padding-bottom: 40px; border-bottom: 1px dashed #eaeaea; position: relative;} +.main-news .content > div{padding-bottom: 40px; border-bottom: 1px dashed #eaeaea; position: relative;display: flex;} .main-news .content .news-img{display: inline-block; width: 30%; vertical-align: top;} .main-news .content .news-img img{max-width: 90%;} .main-news .content .news-panel{display: inline-block; width: 70%; vertical-align: top; padding-left: 5px; box-sizing: border-box;} diff --git a/view/admin/category/index.html b/view/admin/category/index.html index 62c5531..c4d8d81 100644 --- a/view/admin/category/index.html +++ b/view/admin/category/index.html @@ -41,6 +41,7 @@ ID 名称 + 模板 操作 @@ -50,6 +51,7 @@ {$vo.id} {:str_repeat('|--',$vo.level)} {$vo.title} + {$vo.tpl_name}
查看 diff --git a/view/admin/post/index.html b/view/admin/post/index.html index c237119..09ce5b1 100644 --- a/view/admin/post/index.html +++ b/view/admin/post/index.html @@ -73,6 +73,7 @@
+ 查看 编辑
删除
diff --git a/view/index/category/easy_blue_read.html b/view/index/category/easy_blue_read.html new file mode 100644 index 0000000..eb4e914 --- /dev/null +++ b/view/index/category/easy_blue_read.html @@ -0,0 +1,51 @@ + + + + + + + {:get_system_config('site_name')}-首页 + + {include file='common/_easy_blue_require'/} + + + + {include file='common/_easy_blue_header'/} +
+ + + + +
+
+
+ {volist name='$category.posts_list' id='post'} +
+
+
+
+ {$post.title} +

{$post.desc_short}[详细]

+

阅读 {$post.hits}    发布时间:{$post.publish_time}

+
+
+
+ {/volist} +
+ +
+
+
+ {include file='common/_easy_blue_footer'/} + + + + + \ No newline at end of file diff --git a/view/index/category/easy_blue_read_about_1.html b/view/index/category/easy_blue_read_about_1.html new file mode 100644 index 0000000..5b6c0c1 --- /dev/null +++ b/view/index/category/easy_blue_read_about_1.html @@ -0,0 +1,68 @@ + + + + + + + {:get_system_config('site_name')}-首页 + + {include file='common/_easy_blue_require'/} + + + + {include file='common/_easy_blue_header'/} +
+ + + +
+
+
+
    + {volist name='category.model_same_parent' id='same_parent_category'} +
  • {$same_parent_category.title}
  • + {/volist} +
+
+ {volist name='$category.posts_list' id='post'} + {if $i%2 == 0 } + +
+
+
+

{$post.desc}

+
+
+ {else /} +
+
+

{$post.desc}

+
+
+
+ {/if} + {/volist} + +
+ +
+
+
+
+ {include file='common/_easy_blue_footer'/} + + + + + \ No newline at end of file diff --git a/view/index/category/easy_blue_read_about_2.html b/view/index/category/easy_blue_read_about_2.html new file mode 100644 index 0000000..992f4c8 --- /dev/null +++ b/view/index/category/easy_blue_read_about_2.html @@ -0,0 +1,66 @@ + + + + + + + {:get_system_config('site_name')}-首页 + + {include file='common/_easy_blue_require'/} + + + + {include file='common/_easy_blue_header'/} +
+ + + +
+
+
+
    + {volist name='category.model_same_parent' id='same_parent_category'} +
  • {$same_parent_category.title}
  • + {/volist} +
+
+ {volist name='$category.posts_list' id='post'} + +
+

{$post.title}

+

> 职位描述

+
    + {volist name='$post.desc_list' id='li'} + +
  1. {$li};
  2. + {/volist} + +
+
+ + + {/volist} + +
+ +
+
+
+
+ {include file='common/_easy_blue_footer'/} + + + + + \ No newline at end of file diff --git a/view/index/category/easy_blue_read_about_3.html b/view/index/category/easy_blue_read_about_3.html new file mode 100644 index 0000000..3fe990f --- /dev/null +++ b/view/index/category/easy_blue_read_about_3.html @@ -0,0 +1,81 @@ + + + + + + + {:get_system_config('site_name')}-首页 + + {include file='common/_easy_blue_require'/} + + + + {include file='common/_easy_blue_header'/} +
+ + + +
+
+
+
    + {volist name='category.model_same_parent' id='same_parent_category'} +
  • {$same_parent_category.title}
  • + {/volist} +
+
+ +

我们的蜕变

+
    + {volist name='$category.posts_list' id='post'} + + {if $i%2 == 0 } + +
  • +
    +
    +

    {:date('Y 年 m 月 d 日',$post->publish_time)}

    +

    {$post.title}

    +
    +
  • + {else /} +
  • +
    +
    +

    {:date('Y 年 m 月 d 日',$post->publish_time)}

    +

    {$post.title}

    +
    +
  • + + {/if} + + + + {/volist} + + +
+ +
+ +
+
+
+
+ {include file='common/_easy_blue_footer'/} + + + + + \ No newline at end of file diff --git a/view/index/category/easy_blue_read_case.html b/view/index/category/easy_blue_read_case.html new file mode 100644 index 0000000..91bbeb9 --- /dev/null +++ b/view/index/category/easy_blue_read_case.html @@ -0,0 +1,44 @@ + + + + + + + {:get_system_config('site_name')}-首页 + + {include file='common/_easy_blue_require'/} + + + + {include file='common/_easy_blue_header'/} +
+ + + + +
+
+ {volist name='$category.posts_list' id='post'} +
+
+

{$post.title}

+

{$post.desc}

+
+ + {/volist} + +
+
+
+ {include file='common/_easy_blue_footer'/} + + + + + \ No newline at end of file diff --git a/view/index/post/easy_blue_read.html b/view/index/post/easy_blue_read.html new file mode 100644 index 0000000..17611ec --- /dev/null +++ b/view/index/post/easy_blue_read.html @@ -0,0 +1,40 @@ + + + + + + + {:get_system_config('site_name')}-首页 + + {include file='common/_easy_blue_require'/} + + + + + {include file='common/_easy_blue_header'/} +
+
+
+

实时新闻 > 新闻详情

+

{$post.title}

+

发布时间:{$post.publish_time_text}

+

{$post.desc_html}

+
+ {$post.content_html|raw} +
+

+ +

+
+
+
+ {include file='common/_easy_blue_footer'/} + + + + + \ No newline at end of file