dever 5 years ago
parent
commit
57a2962c0d

+ 2 - 2
app/collection/database/function.php

@@ -5,7 +5,7 @@ $type = array
     'cate' 		=> '集合',
     'community' => '社区',
     'shop' 		=> '商城',
-    //'year' 		=> '时光',
+    'times' 		=> '时光',
     //'jump' 		=> '穿越',
     //'befall' 	=> '降临',
     //'music' 	=> '音乐',
@@ -128,7 +128,7 @@ return array
         (
             'type'      => 'varchar-10',
             'name'      => '页面展开方式',
-            'default'   => '',
+            'default'   => 'left',
             'desc'      => '页面展开方式',
             'match'     => 'is_string',
             'update'    => 'radio',

+ 108 - 15
app/collection/database/page.php

@@ -1,5 +1,42 @@
 <?php
 
+$info_id = Dever::input('search_option_info_id');
+$times = function() use ($info_id)
+{
+	$array = array
+	(
+		-1 => array('id' => '-1', 'name' => '不选择'),
+	);
+	$info = Dever::db('collection/times')->mainAll(array('info_id' => $info_id));
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$times_child = function() use ($info_id)
+{
+	$info = Dever::db('collection/times')->childAll(array('info_id' => $info_id));
+
+	return $info;
+};
+
+# 搜索
+$search_times = function() use ($info_id)
+{
+	$array = array
+	(
+		-1 => array('id' => '-1', 'name' => '所有时光'),
+	);
+	$info = Dever::load('collection/lib/times')->all();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
 return array
 (
 	# 表名
@@ -32,22 +69,9 @@ return array
             'desc'      => '合集',
             'match'     => 'is_numeric',
             'update'    => 'hidden',
-            'value'     => Dever::input('search_option_info_id')
+            'value'     => $info_id
         ),
 
-        'year'		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> '年份-影响时光板块的内容选择',
-			'default' 	=> '',
-			'desc' 		=> '年份',
-			'match' 	=> 'is_numeric',
-			'update'	=> 'year',
-			'search'	=> 'text',
-			'order'		=> 'desc',
-			'list'		=> true,
-		),
-
 		'name'		=> array
 		(
 			'type' 		=> 'varchar-150',
@@ -61,6 +85,34 @@ return array
 			'edit'		=> true,
 		),
 
+        'times_id_parent'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '父级时光',
+			'default' 	=> '0',
+			'desc' 		=> '请选择父级时光',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option' 	=> $times,
+			# 当值改变时,执行下一步操作
+			'child_name' => 'times_id',
+			'child' => $times_child,
+			'child_value' => '{times_id}',
+		),
+		
+		'times_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '子时光',
+			'default' 	=> '0',
+			'desc' 		=> '请选择子时光',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'group',
+			'option' 	=> $search_times,
+			'list_name'	=> '时光',
+			'list'		=> '{times_id} > 0 ? Dever::load("collection/lib/times.getName", {times_id}, {times_id_parent}) : "无"',
+		),
+
 		'page_id'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -73,6 +125,29 @@ return array
 			'list'		=> '{page_id} > 0 ? Dever::load("collection/page-one#name", {page_id}) : "主章节"',
 		),
 
+		'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图片-章节图片,图片尺寸330*330px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '章节图片',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '330*330',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '描述',
+            'default'   => '',
+            'desc'      => '描述',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+        ),
+
 		'reorder'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -113,6 +188,10 @@ return array
 
 	'manage' => array
 	(
+		'button' => array
+		(
+			'时光配置' => array('location', 'manage/project/database/list&project=collection&oper_table=page&top_table=info&top_project=collection&table=times&search_option_info_id=' . $info_id),
+		),
 		# 列表页的类型
 		'list_type' => 'tree',
 		'list_button' => array
@@ -134,7 +213,7 @@ return array
 				'state' => 1,
 				'page_id' => array(1, '>='),
 				'info_id' => 'yes',
-				'year' => 'yes',
+				'times_id' => 'yes',
 			),
 			'type' => 'all',
 			'order' => array('reorder' => 'asc', 'id' => 'asc'),
@@ -153,5 +232,19 @@ return array
 			'order' => array('reorder' => 'asc', 'id' => 'asc'),
 			'col' => '*',
 		),
+
+		'getOne' => array
+		(
+			'option' => array
+			(
+				'state' => 1,
+				'page_id' => array(1, '>='),
+				'info_id' => 'yes',
+				'times_id' => 'yes',
+			),
+			'type' => 'one',
+			'order' => array('reorder' => 'asc', 'id' => 'asc'),
+			'col' => '*',
+		),
 	)
 );

+ 250 - 0
app/collection/database/times.php

@@ -0,0 +1,250 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'times',
+	# 显示给用户看的名称
+	'lang' => '时光管理',
+	# 是否显示在后台菜单
+	'order' => 1,
+	'menu'	=> false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'asc',
+			'list'		=> true,
+		),
+
+		'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集',
+            'default'   => '',
+            'desc'      => '合集',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '时光名称',
+			'default' 	=> '',
+			'desc' 		=> '时光名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'year'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '年份-影响当前时光下所有发布内容的时间',
+			'default' 	=> '',
+			'desc' 		=> '年份',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'year',
+			'search'	=> 'text',
+			'order'		=> 'desc',
+			'list'		=> true,
+		),
+
+		'times_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '上级时光',
+			'default' 	=> '-1',
+			'desc' 		=> '请选择上级时光',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('option_times_id', -1),
+			'list'		=> '{times_id} > 0 ? Dever::load("collection/times-one#name", {times_id}) : "主时间线"',
+		),
+
+		'icon'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '时光图标-图片尺寸80*80px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '时光图标',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '80*80',
+        ),
+
+        'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图片-图片尺寸330*330px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '图片',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '330*330',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '描述',
+            'default'   => '',
+            'desc'      => '描述',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+        ),
+
+        'color'      => array
+        (
+            'type'      => 'varchar-10',
+            'name'      => '文字颜色-默认为白色',
+            'default'   => '#ffffff',
+            'desc'      => '文字颜色',
+            'match'     => 'is_string',
+            'update'    => 'color',
+        ),
+
+        'bgcolor'      => array
+        (
+            'type'      => 'varchar-10',
+            'name'      => '背景颜色-默认为灰色',
+            'default'   => '#cccccc',
+            'desc'      => '背景颜色',
+            'match'     => 'is_string',
+            'update'    => 'color',
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越小越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'asc',
+			'edit'		=> true,
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'order'		=> 'asc',
+			//'search'	=> 'date',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		# 列表页的类型
+		'list_type' => 'tree',
+		'list_button' => array
+		(
+			'update' => '编辑',
+			'add' => array('新增时间线', '"{times_id}" == -1 ? "times&option_times_id={id}" : "times&option_times_id={times_id},{id}"', '{times_id} == -1'),
+			'delete' => '删除',
+		),
+	),
+
+	'request' => array
+	(
+		'child' => array
+		(
+			'option' => array
+			(
+				'state' => 1,
+				'times_id' => 'yes',
+				'info_id' => 'yes',
+			),
+			'type' => 'all',
+			'order' => array('year' => 'asc', 'reorder' => 'asc', 'id' => 'asc'),
+			'col' => '*',
+		),
+		
+		'main' => array
+		(
+			'option' => array
+			(
+				'state' => 1,
+				'times_id' => -1,
+				'info_id' => 'yes',
+			),
+			'type' => 'all',
+			'order' => array('year' => 'asc', 'reorder' => 'asc', 'id' => 'asc'),
+			'col' => '*',
+		),
+
+		'mainAll' => array
+		(
+			'option' => array
+			(
+				'state' => 1,
+				'times_id' => -1,
+				'info_id' => 'yes',
+			),
+			'type' => 'all',
+			'order' => array('year' => 'asc', 'reorder' => 'asc', 'id' => 'asc'),
+			'col' => '*|id',
+		),
+
+		# 取所有下级
+		'childAll' => array
+		(
+			'option' => array
+			(
+				'times_id' => array(1, '>='),
+				'info_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('year' => 'asc', 'reorder' => 'asc', 'id' => 'asc'),
+			'col' => '*|times_id|id|',
+		),
+
+		'getNew' => array
+		(
+			'option' => array
+			(
+				'state' => 1,
+				'times_id' => array(1, '>='),
+				'year' => 'yes',
+				'info_id' => 'yes',
+			),
+			'type' => 'one',
+			'order' => array('year' => 'asc', 'reorder' => 'asc', 'id' => 'asc'),
+			'col' => '*',
+		),
+	)
+);

+ 125 - 0
app/collection/database/user_record.php

@@ -0,0 +1,125 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'user_record',
+    # 显示给用户看的名称
+    'lang' => '用户操作记录',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+		),
+
+        'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集',
+            'default'   => '',
+            'desc'      => '合集',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'page_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '章节id',
+            'default'   => '',
+            'desc'      => '章节id',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'times_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '时光id',
+            'default'   => '',
+            'desc'      => '时光id',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'content_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '内容id',
+            'default'   => '',
+            'desc'      => '内容id',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'index'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '内容索引值',
+            'default'   => '',
+            'desc'      => '内容索引值',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '操作时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 2 - 2
app/collection/lib/Core.php

@@ -17,7 +17,7 @@ class Core
         $this->token = Dever::input('token');
         $this->uid = 1;
         $this->user = Dever::load('passport/api')->info($this->uid);
-        # 获取最新的年份-时光专用
-        $this->year = Dever::input('year', date('Y'));
+        # 获取时光id
+        $this->times = Dever::input('times');
     }
 }

+ 38 - 0
app/collection/lib/Times.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace Collection\Lib;
+
+use Dever;
+
+class Times
+{
+    /**
+     * 获取所有数据
+     *
+     * @return mixed
+     */
+    public function all()
+    {
+    	$info_id = Dever::input('search_option_info_id');
+        $data = Dever::db('collection/times')->mainAll(array('info_id' => $info_id));
+
+        if ($data) {
+            $child = Dever::db('collection/times')->childAll(array('info_id' => $info_id));
+            foreach ($data as $k => $v) {
+                if (isset($child[$k])) {
+                    $data[$k]['child'] = $child[$k];
+                }
+            }
+        }
+
+        return $data;
+    }
+
+    public function getName($id, $parent_id)
+    {
+    	$parent = Dever::db('collection/times')->one($parent_id);
+    	$info = Dever::db('collection/times')->one($id);
+
+    	return $parent['name'] . '·' . $info['name'];
+    }
+}

+ 95 - 8
app/collection/src/Api.php

@@ -49,19 +49,51 @@ class Api extends Core
                 $data['button']['bgcolor'] .= $data['button']['color'];
             }
 
-            # 获取最新的章节页id
-            $page_where['info_id'] = $data['info']['id'];
-            $page_where['year'] = $this->year;
-            $data['page'] = Dever::db('collection/page')->child($page_where);
-            $data['page_id'] = 0;
-            if ($data['page']) {
-                $data['page_id'] = $data['page'][0]['id'];
+            # 获取最新的用户记录
+            $where['info_id'] = $this->id;
+            $where['uid'] = $this->uid;
+            $record = Dever::db('collection/user_record')->one($where);
+            if ($record) {
+                $data['page_id'] = $record['page_id'];
+                $data['times'] = $record['times_id'];
+                $data['index'] = $record['index'];
+            } else {
+                # 获取最新的章节页id
+                $page_where['info_id'] = $data['info']['id'];
+                $page_where = $this->getTimes($page_where);
+                $page = Dever::db('collection/page')->child($page_where);
+                $data['page_id'] = 0;
+                if ($page) {
+                    $data['page_id'] = $page[0]['id'];
+                }
+                $data['times'] = 0;
+                if ($this->times) {
+                    $data['times'] = $this->times;
+                }
+                $data['index'] = 0;
             }
         }
 
         return $data;
     }
 
+    private function getTimes($where)
+    {
+        # 获取当前年份的最新的时光
+        if (!$this->times) {
+            $where['year'] = date('Y');
+            $times = Dever::db('collection/times')->getNew($where);
+            if ($times) {
+                $this->times = $times['id'];
+            }
+        }
+        if ($this->times) {
+            $where['times_id'] = $this->times;
+        }
+
+        return $where;
+    }
+
     # 获取合集下的购买内容
     public function getBuy()
     {
@@ -154,8 +186,11 @@ class Api extends Core
         $where['info_id'] = $this->id;
         $data['cate'] = Dever::db('collection/page')->main($where);
         if ($data['cate']) {
-            $data['child'] = Dever::db('collection/page')->child($where);
             $content = Dever::db('collection/content')->child($where);
+
+            $where = $this->getTimes($where);
+            $data['child'] = Dever::db('collection/page')->child($where);
+            
             $data['show'] = array();
             foreach ($data['cate'] as $k => $v) {
                 if ($v['id'] == $parent_page_id) {
@@ -175,6 +210,56 @@ class Api extends Core
         return $data;
     }
 
+    # 获取合集下的时光
+    public function times()
+    {
+        $parent_page_id = Dever::input('parent_page_id');
+        $page_id = Dever::input('page_id');
+        $where['info_id'] = $this->id;
+        $data['cur'] = $this->times;
+        $data['times'] = Dever::db('collection/times')->main($where);
+        if ($data['times']) {
+            foreach ($data['times'] as $k => $v) {
+                $where['times_id'] = $v['id'];
+                $data['times'][$k]['child'] = Dever::db('collection/times')->child($where);
+            }
+        }
+
+        return $data;
+    }
+
+    # 根据时光id获取pageid
+    public function getPageId()
+    {
+        $where['info_id'] = $this->id;
+        $where = $this->getTimes($where);
+        $page = Dever::db('collection/page')->getOne($where);
+        if ($page) {
+            return $page;
+        }
+        Dever::alert('error');
+    }
+
+    # 记录用户操作
+    public function record()
+    {
+        $where['info_id'] = $this->id;
+        $where['uid'] = $this->uid;
+        $record = Dever::db('collection/user_record')->one($where);
+        $where['page_id'] = Dever::input('page_id');
+        $where['times_id'] = $this->times;
+        $where['content_id'] = Dever::input('content_id');
+        $where['index'] = Dever::input('index');
+        if ($record) {
+            $where['where_id'] = $record['id'];
+            Dever::db('collection/user_record')->update($where);
+        } else {
+            Dever::db('collection/user_record')->insert($where);
+        }
+
+        return 'yes';
+    }
+
     public function ding($data)
     {
         if (isset($data['num_add_buy']) && isset($data['num_ratio_buy'])) {
@@ -194,6 +279,8 @@ class Api extends Core
                 }
                 */
 
+                $data['num_up'] = 0;
+            } else {
                 $data['num_up'] = 0;
             }
 

+ 11 - 0
app/community/database/comment.php

@@ -63,6 +63,17 @@ return array
 			'update'	=> 'text',
 		),
 
+		'pic'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '图片-图片尺寸不等,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '图片',
+			'match' 	=> 'is_string',
+			'update'	=> 'images',
+			'key' 		=> '1',
+		),
+
 		'content'		=> array
 		(
 			'type' 		=> 'text-255',

+ 16 - 2
app/community/lib/Comment.php

@@ -6,7 +6,7 @@ use Dever;
 
 class Comment
 {
-    public function getData($method = 'getAll', $uid, $type = false, $type_id = false)
+    public function getData($method = 'getAll', $uid, $type = false, $type_id = false, $user = false)
     {
         $where['type'] = $type;
         $where['type_id'] = $type_id;
@@ -17,6 +17,13 @@ class Comment
             foreach ($info as $k => $v) {
             	$data['info'][$k]['uid'] = $v['uid'];
                 $data['info'][$k]['content'] = $v['content'];
+                if ($v['pic']) {
+                    $data['info'][$k]['pic'] = explode(',', $v['pic']);
+                }
+                if ($user) {
+                    $data['info'][$k]['user'] = Dever::load('passport/api')->info($v['uid']);
+                    $data['info'][$k]['cdate_string'] = Dever::mdate($v['cdate'], 2);
+                }
             }
         }
 
@@ -24,12 +31,19 @@ class Comment
     }
 
     # 发表信息
-    public function submit($uid, $id, $type, $content)
+    public function submit($uid, $id, $type, $pic, $content)
     {
+        # 如果是商品,要先验证是否购买
+        if ($type == 'content/product') {
+
+        }
         $where['uid'] = $uid;
         $where['type_id'] = $id;
         $where['type'] = $type;
         $where['content'] = $content;
+        if ($pic) {
+            $where['pic'] = $pic;
+        }
         $table = 'community/comment';
         $info = false;
         if (!$info) {

+ 4 - 2
app/community/src/Api.php

@@ -38,13 +38,15 @@ class Api
     public function comment()
     {
         $id = Dever::input('id');
-        $data = Dever::load('community/lib/comment')->getData('getAll', $this->uid, $this->type, $this->type_id);
+        $user = Dever::input('user', false);
+        $data = Dever::load('community/lib/comment')->getData('getAll', $this->uid, $this->type, $this->type_id, $user);
         return $data;
     }
 
     # 发布弹幕、评论
     public function addComment()
     {
+        $pic = Dever::input('pic');
         $content = Dever::input('content');
         if (!$content) {
             Dever::alert('请填写内容');
@@ -59,7 +61,7 @@ class Api
             Dever::alert('错误的信息');
         }
         
-        Dever::load('community/lib/comment')->submit($this->uid, $type_id, $type, $content);
+        Dever::load('community/lib/comment')->submit($this->uid, $type_id, $type, $pic, $content);
 
         return 'yes';
     }