dever 6 years ago
parent
commit
d4f74f5a73
4 changed files with 54 additions and 43 deletions
  1. 4 4
      config/base.php
  2. 3 3
      content/database/article.php
  3. 22 14
      main/lib/Core.php
  4. 25 22
      main/src/View.php

+ 4 - 4
config/base.php

@@ -1,7 +1,7 @@
 <?php
 $config['base'] = array
 (
-    'name' => '年夜饭',
+    'name' => '晒图',
     'version' => '1.0.0 Beta',
 
     # 功能选择
@@ -43,9 +43,9 @@ $config['base'] = array
 
     'applet' => array
     (
-        'project' => 'passport/system',
-        'appid' => 'wxd0590664d0004f23',
-        'secret' => '009bf48ffd5a3ceecb6a933492d641d2',
+        //'project' => 'passport/system',
+        'appid' => 'wxd03e9b0848beb6a7',
+        'secret' => 'c5295869e033d23a672c6349656eb033',
         'url' => 'https://api.weixin.qq.com/sns/jscode2session',
     ),
 

+ 3 - 3
content/database/article.php

@@ -44,7 +44,7 @@ $wechat = array
 );
 
 # 常用的col
-$col = 'id,cate_id,name,pic_cover,pdate,num_add_view+num_view as num_view,num_up+num_add_up as num_up,num_comment,share_yes,share_title,share_pic,share_content,function,content,author_id';
+$col = 'id,cate_id,name,pic_cover,pdate,num_add_view,num_view,num_up,num_comment,share_yes,share_title,share_pic,share_content,function,author_id';
 
 return array
 (
@@ -133,7 +133,7 @@ return array
   		'pic_cover'		=> array
 		(
 			'type' 		=> 'varchar-150',
-			'name' 		=> '4:3封面图-图片尺寸750*564px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'name' 		=> '封面图-官方发布图片尺寸400*300px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
 			'default' 	=> '',
 			'desc' 		=> '封面图',
 			'match' 	=> 'is_string',
@@ -439,7 +439,7 @@ return array
 				'id' => 'yes',
 			),
 			'type' => 'one',
-			'col' => $col,
+			'col' => $col . ',content',
 		),
 		
 		# 更新浏览量

+ 22 - 14
main/lib/Core.php

@@ -22,7 +22,7 @@ class Core
         //$this->data['uid'] = 1;
 
         # 获取基本配置
-        $this->data['config'] = Dever::db('main/config')->one();
+        $this->data['setting'] = Dever::db('main/config')->one();
         $this->data['system'] = Dever::input('system', 1);
 
         $source_type = Dever::input('source_type');
@@ -89,23 +89,35 @@ class Core
         $info = $this->pic($info);
         $info['type'] = $type;
         $info['data_id'] = $info['id'];
-        if (isset($info['content']) && !$content) {
-            unset($info['content']);
-        }
+
         if (isset($info['pdate']) && $info['pdate'] > 0) {
         } else {
             $info['pdate'] = time();
         }
-        $info['pdate'] = date('Y-m-d', $info['pdate']);
+        $info['pdate_str'] = Dever::mdate($info['pdate'], 2);
+        $info['pdate'] = date('Y-m-d H:i', $info['pdate']);
+
+
+        /*
+        if (isset($info['share_content'])) {
+            $source = Dever::db('source/info')->one(1);
+            $info['share_link'] = $source['code'];
+        }
+        */
 
         if (isset($info['cate_id']) && $info['cate_id']) {
-            $cate = Dever::db('content/cate')->one($info['cate_id']);
-            $info['cate_name'] = $cate['name'];
+            $info['cate'] = Dever::db('content/cate')->one($info['cate_id']);
         }
 
-        if (isset($info['author_id']) && $info['author_id']) {
-            $author = Dever::db('content/author')->one($info['author_id']);
-            $info['author_name'] = $author['name'];
+        if (isset($info['num_view']) && $info['num_view'] > 100000) {
+            $info['num_view'] = '10w+';
+        }
+
+        if (isset($info['author_id']) && $info['author_id'] > 0) {
+            $info['author'] = Dever::db('content/author')->one($info['author_id']);
+        } elseif (isset($info['uid']) && $info['uid'] > 0) {
+            $info['author'] = Dever::db('passport/user')->one($info['uid']);
+            $info['author']['name'] = $info['author']['username'];
         }
 
         if (isset($info['num_add_view']) && isset($info['num_view'])) {
@@ -120,10 +132,6 @@ class Core
             $info['num_user'] = $info['num_add_user'] + $info['num_user'];
             unset($info['num_add_user']);
         }
-        if (isset($info['num_add_user']) && isset($info['num_user'])) {
-            $info['num_user'] = $info['num_add_user'] + $info['num_user'];
-            unset($info['num_add_user']);
-        }
         if (isset($info['num_add_ding']) && isset($info['num_ding'])) {
             $info['num_ding'] = $info['num_add_ding'] + $info['num_ding'];
             unset($info['num_add_ding']);

+ 25 - 22
main/src/View.php

@@ -35,6 +35,7 @@ class View extends Core
 
     private function get($method, $name, $type = 1, $key = '')
     {
+        $this->data['type'] = $type;
         $id = Dever::input('id');
         if (!$id) {
             Dever::alert('错误的'.$name.'ID');
@@ -44,39 +45,20 @@ class View extends Core
             Dever::alert('错误的'.$name.'ID');
         }
 
-        $this->data['info'] = $this->pic($this->data['info']);
-
-        if ($this->data['info']['pdate'] > 0) {
-            $this->data['info']['pdate_time'] = date('Y-m-d H:i:s', $this->data['info']['pdate']);
-        }
-
-        if (isset($this->data['info']['share_content'])) {
-            $source = Dever::db('source/info')->one(1);
-            $this->data['info']['share_link'] = $source['code'];
-        }
-
-        if ($this->data['info']['num_view'] > 100000) {
-            //$this->data['info']['num_view'] = '10w+';
-        }
-
-        if (isset($this->data['info']['cate_id']) && $this->data['info']['cate_id']) {
-            $this->data['info']['cate'] = Dever::db('content/cate')->one($this->data['info']['cate_id']);
-        }
-
-        if (isset($this->data['info']['author_id']) && $this->data['info']['author_id']) {
-            $this->data['info']['author'] = Dever::db('content/author')->one($this->data['info']['author_id']);
-        }
+        $this->data['info'] = $this->getInfo($type, $this->data['info']);
 
         # 获取评论列表
         $this->data['comment'] = Dever::load('act/lib/comment')->get($id, $type, $this->data['uid']);
 
         # 获取相关推荐
+        /*
         $this->data['relation'] = Dever::load($method)->getRelation($this->data['info']);
         if ($this->data['relation']) {
             foreach ($this->data['relation'] as $k => $v) {
                 $this->data['relation'][$k] = $this->getInfo($type, $v);
             }
         }
+        */
 
         # 用户行为数据
         $this->data['user_act'] = array();
@@ -117,6 +99,27 @@ class View extends Core
         return $this->data;
     }
 
+    # 获取详情
+    public function data()
+    {
+        $type = Dever::input('type', 1);
+        switch($type) {
+            case 1:
+                $data = $this->article();
+                break;
+            case 2:
+                $data = $this->vod();
+                break;
+            case 3:
+                $data = $this->live();
+                break;
+            case 6:
+                $data = $this->feature();
+                break;
+        }
+        return $data;
+    }
+
     # 获取图文详情
     public function article()
     {