dever 4 years ago
parent
commit
ec3c1a8370

+ 8 - 0
app/article/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'shop');
+define('DEVER_APP_LANG', '店铺管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 98);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
+include(DEVER_APP_PATH . '../boot.php');

+ 2 - 0
app/boot.php

@@ -0,0 +1,2 @@
+<?php
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../boot.php');

+ 473 - 0
app/content/database/article.php

@@ -0,0 +1,473 @@
+<?php
+
+$audit = Dever::config('base')->audit;
+
+$status = Dever::config('base')->status;
+
+# 每页的数据量
+$page = 15;
+
+$cate = function()
+{
+	$array = array();
+	$info = Dever::db('content/cate')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$author = function()
+{
+	$array = array();
+	$info = Dever::db('content/author')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$share = array
+(
+	1 => '显示',
+	2 => '不显示',
+);
+
+$template = array
+(
+	1 => '图文',
+	2 => '视频',
+);
+
+# 常用的col
+$col = 'id,cate_id,name,pic_cover,pic_index,num_add_view+num_view as num_view,content,author_id,template,`desc`,video';
+
+return array
+(
+	# 表名
+	'name' => 'article',
+	# 显示给用户看的名称
+	'lang' => '文章管理',
+	'order' => 100,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '标题-文章标题,同时也用于分享标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+			'search'	=> 'fulltext',
+			//增加预览
+			'preview'	=> true,
+		),
+
+		'desc'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '摘要-文章摘要,同时也用于分享内容',
+			'default' 	=> '',
+			'desc' 		=> '摘要',
+			'match' 	=> 'is_string',
+			'update'	=> 'textarea',
+		),
+		
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属栏目',
+			'default' 	=> '1',
+			'desc' 		=> '所属栏目',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $cate,
+			'search'	=> 'select',
+			'list'		=> 'Dever::load("content/cate-one#name", {cate_id})',
+		),
+
+		'author_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '编辑',
+			'default' 	=> '1',
+			'desc' 		=> '编辑',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			//'option'	=> $author,
+			'search'	=> 'select',
+			'update_search'	=> 'content/lib/author.search',
+		),
+
+  		'pic_cover'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '1:1封面图-图片尺寸380*380px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,同时用于分享图片',
+			'default' 	=> '',
+			'desc' 		=> '封面图',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+			//直接上传到云端
+			//'upload'	=> 'qiniu',
+			//上传大数据
+			//'large' 	=> true,
+		),
+
+		'pic_index'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '16:9封面图-一般用于首页,图片尺寸380*214px或等比尺寸,秀场图片尺寸360*540px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,同时用于分享图片',
+			'default' 	=> '',
+			'desc' 		=> '封面图',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+			//直接上传到云端
+			//'upload'	=> 'qiniu',
+			//上传大数据
+			//'large' 	=> true,
+		),
+
+		'template'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '文章模板',
+			'default' 	=> '1',
+			'desc' 		=> '文章模板',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $template,
+			'search'	=> 'select',
+			'control'	=> 'template',
+		),
+
+		'video'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '上传视频-上传视频格式mp4,mov,上传大小不能超过4G,也可以直接填入腾讯视频的地址(如:https://v.qq.com/x/page/p0873p0efbx.html)或者mp4地址',
+			'default' 	=> '',
+			'desc' 		=> '上传视频',
+			'match' 	=> 'is_string',
+			'update'	=> 'upload',
+			'key' 		=> '5',
+			'place'		=> '150',
+			'upload'	=> 'qiniu',
+			'large' 	=> true,
+			//不覆盖原文件,生成新文件
+			'cover'		=> 2,
+			'show'		=> 'template=2',
+		),
+
+		'video_info'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '视频信息',
+			'default' 	=> '',
+			'desc' 		=> '视频信息',
+			'match' 	=> 'is_string',
+			'show'		=> 'template=2',
+		),
+
+		'num_add_view'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '浏览量基数',
+			'default' 	=> '0',
+			'desc' 		=> '浏览量基数',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'num_view'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '浏览量',
+			'default' 	=> '0',
+			'desc' 		=> '请填写浏览量',
+			'match' 	=> 'option',
+			'search'	=> 'order',
+			'list'		=> '{num_view}+{num_add_view}',
+		),
+
+		'pdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> array('is_numeric', time()),
+			'default'	=> '',
+			'desc' 		=> '',
+			'update'	=> 'date',
+			'callback'	=> 'maketime',
+			'insert'	=> true,
+			//'list'		=> 'date("Y-m-d H:i:s", {pdate})',
+			'auth'		=> '"{pdate}" > 0',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'udate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '更新时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+		),
+
+		'content'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '内容',
+			'default' 	=> '',
+			'desc' 		=> '请输入内容',
+			'match' 	=> 'is_string',
+			'update'	=> 'editor',
+			'key'		=> '1',
+			//'media'		=> '5',//下面的音视频已经做到了
+			//直接上传到云端
+			//'upload'	=> 'qiniu',
+			//上传大数据
+			//'large' 	=> true,
+			//自定义编辑器右侧按钮
+			/*
+			'editor'	=> array
+			(
+				'name' => '选择插入模块',
+				'button' => array
+				(
+					array
+					(
+						# 名称
+						'name' => '图片',
+						# 资源库id
+						'key' => 1,
+						# 类型
+						'type' => 'image',
+					),
+					array
+					(
+						'name' => '音频',
+						'key' => 5,
+						'type' => 'media',
+					),
+					array
+					(
+						'name' => '视频',
+						'key' => 'video/lib/core.vod',
+					),
+					array
+					(
+						'name' => '直播',
+						'key' => 'video/lib/core.live',
+					),
+
+					array
+					(
+						'name' => '小程序',
+						'key' => 'content/lib/applet.update',
+						'type' => 'update',
+					),
+				),
+			),
+			*/
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布状态',
+			'default' 	=> '2',
+			'desc' 		=> '发布状态',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'admin_founder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '创建人',
+			'default' 	=> '1',
+			'desc' 		=> '创建人',
+			'match' 	=> 'is_numeric',
+		),
+
+		'admin_editor'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '操作人',
+			'default' 	=> '1',
+			'desc' 		=> '操作人',
+			'match' 	=> 'is_numeric',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		'version' => 1,
+		
+		1 => array
+		(
+			'i1' => 'cate_id,reorder',
+		)
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+		//'insert' => false,
+		# 列表
+		'list_button' => array
+		(
+			'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=1'))),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'search' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'cate_id' => 'yes',
+				'name' => array('yes', 'like'),
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
+			'limit' => '0,1000',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'cate_id' => 'yes',
+				'cate_ids' => array('yes-cate_id', 'in'),
+				'id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','pdate' => 'desc'),
+			'page' => array($page, 'list'),
+			'col' => $col,
+		),
+
+		'getList' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'cate_id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','pdate' => 'desc'),
+			'limit' => '0,10',
+			'col' => $col,
+		),
+
+		'getRelation' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'cate_id' => 'yes',
+				'cate_ids' => array('yes-cate_id', 'in'),
+				'noid' => array('yes-id', '!='),
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','pdate' => 'desc'),
+			'limit' => '0,4',
+			'col' => $col,
+		),
+
+		'getOne' => array
+		(
+			# 匹配的正则或函数 选填项
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'type' => 'one',
+			'col' => $col,
+		),
+		
+		# 更新浏览量
+		'addView' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'num_view' => array('1', '+='),
+			),
+		),
+	),
+);

+ 118 - 0
app/content/database/author.php

@@ -0,0 +1,118 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'author',
+	# 显示给用户看的名称
+	'lang' => '编辑管理',
+	# 后台菜单排序
+	'order' => 8,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '编辑名称-长度不能超过16个字',
+			'default' 	=> '',
+			'desc' 		=> '请输入编辑名称,长度不能超过16个字',
+			'match' 	=> Dever::rule('name', '/u', '1,16'),
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+		
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'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,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 默认值
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"SG精品",1,' . time(),
+		),
+	),
+
+	'manage' => array
+	(
+		'insert' => false,
+		'edit' => false,
+
+		# 自定义快捷新增和编辑
+		'button' => array
+		(
+			'新增' => array('fast'),
+		),
+		# 快捷更新
+		'list_button' => array
+		(
+			'edit' => array('编辑'),
+		),
+	),
+
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'name' => array('yes', 'like'),
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'limit' => '0,1000',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+	),
+);

+ 143 - 0
app/content/database/cate.php

@@ -0,0 +1,143 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'cate',
+	# 显示给用户看的名称
+	'lang' => '栏目设置',
+	# 后台菜单排序
+	'order' => 9,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '栏目名称',
+			'default' 	=> '',
+			'desc' 		=> '请输入名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'ename'      => array
+        (
+            'type'      => 'varchar-180',
+            'name'      => '英文栏目名称',
+            'default'   => '',
+            'desc'      => '英文栏目名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+		
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'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,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 默认值
+	'default' => array
+	(
+		'col' => 'name,ename,reorder,cdate',
+		'value' => array
+		(
+			'"时装","FASHION",10,' . time(),
+			'"美容","BEAUTY",9,' . time(),
+			'"娱乐","RUNWAY",8,' . time(),
+			'"视频","STAR",7,' . time(),
+			'"秀场","VIDEO",6,' . time(),
+		),
+	),
+
+	'manage' => array
+	(
+		'insert' => false,
+		'edit' => false,
+
+		# 自定义快捷新增和编辑
+		'button' => array
+		(
+			'新增' => array('fast'),
+		),
+		# 快捷更新
+		'list_button' => array
+		(
+			'edit' => array('编辑'),
+		),
+	),
+
+	'request' => array
+	(
+		'state' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','id' => 'desc'),
+			'col' => '*',
+		),
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'state' => 1,
+				# 小程序去掉视频栏目
+				'id_no' => array('yes-id', '!='),
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','id' => 'desc'),
+			'col' => '*',
+		),
+	),
+);

+ 126 - 0
app/content/database/page.php

@@ -0,0 +1,126 @@
+<?php
+
+
+$config = array
+(
+    # 表名
+    'name' => 'page',
+    # 显示给用户看的名称
+    'lang' => '单页管理',
+    # 后台菜单排序
+    'order' => 2,
+    'check' => 'key',
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'    => 'order',
+            //'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-180',
+            'name'      => '标题',
+            'default'   => '',
+            'desc'      => '标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'ename'      => array
+        (
+            'type'      => 'varchar-180',
+            'name'      => '英文标题',
+            'default'   => '',
+            'desc'      => '英文标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'key'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '标识',
+            'default'   => '',
+            'desc'      => '标识',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'content'      => array
+        (
+            'type'      => 'text-255',
+            'name'      => '内容',
+            'default'   => '',
+            'desc'      => '内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'list_name'		=> '链接',
+            'list'      => 'Dever::load("content/lib/page.link", {id})',
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    )
+);
+# 获取小刊分类权限
+$auth = Dever::tops();
+
+if ($auth && $auth != 1) {
+    $config['request']['list'] = array
+    (
+        # 匹配的正则或函数 选填项
+        'option' => array
+        (
+            'name' => array('yes', 'like'),
+            'key' => array('_' . $auth, 'like'),
+        ),
+        'type' => 'all',
+        'order' => array('id' => 'desc'),
+        'page' => array(20, 'list'),
+        'col' => '*|id',
+    );
+}
+
+return $config;

+ 8 - 0
app/content/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'content');
+define('DEVER_APP_LANG', '内容管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 200);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-tabs');
+include(DEVER_APP_PATH . '../boot.php');

+ 223 - 0
app/content/lib/Article.php

@@ -0,0 +1,223 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Article
+{
+    # 根据文章id 获取文章信息
+    public function get($data, $uid = false)
+    {
+        if (!is_array($data)) {
+            $data = Dever::db('content/article')->getOne($data);
+        }
+        
+        if (!$data) {
+            Dever::alert('错误的文章信息');
+        }
+    
+        $data = $this->getContent($data, $uid);
+
+        return $data;
+    }
+
+    public function getContent($data, $uid = false)
+    {
+        //embed
+        $data['content_array'] = array();
+
+        $data['content'] = Dever::filter($data['content']);
+
+        $content = $data['content'];
+        $replace = array();
+
+        # embed已废弃
+        if (strstr($data['content'], 'embed')) {
+            # 音频
+            preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $content, $matches);
+            if (isset($matches[1])) {
+                foreach ($matches[1] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+
+                    if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
+                        $replace[] = array('type' => 6, 'content' => $v);
+                    } else {
+                        $replace[] = array('type' => 5, 'content' => $v);
+                    }
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'data-applet')) {
+            # 小程序
+            preg_match_all('/<img(.*?)data-applet="(.*?)" \/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $temp = explode('||', $v);
+                    $pic = $temp[0];
+                    $appid = $temp[1];
+                    $path = $temp[2];
+
+                    if ($appid) {
+                        $appinfo = Dever::db('content/applet')->one(array('appid' => $appid));
+                    } else {
+                        $appinfo['name'] = '';
+                        $appinfo['link'] = '';
+                    }
+                    
+                    if (isset($temp[3]) && $temp[3]) {
+                        $appinfo['link'] = $temp[3];
+                    }
+
+                    $replace[] = array('type' => 7, 'pic_cover' => $pic, 'appid' => $appid, 'path' => $path, 'name' => $appinfo['name'], 'link' => $appinfo['link']);
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'gif')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.gif" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 8, 'pic' => $pic . '.gif');
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'data-file')) {
+            # 音频
+            preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
+
+            if (!isset($matches[1][0])) {
+                preg_match_all('/<img style="(.*?)" src="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
+                $temp = array();
+                if (isset($matches[2][0])) {
+                    $temp = $matches;
+                    $matches[1] = $temp[2];
+                    unset($temp);
+                }
+            }
+
+            if (isset($matches[1])) {
+                foreach ($matches[1] as $k => $v) {
+                    if (isset($matches[3][$k])) {
+                        $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+
+                        $file = $matches[3][$k];
+                        $temp = explode('||', $file);
+                        $file = $temp[0];
+                        if (isset($temp[1])) {
+                            $name = $temp[1];
+                        } else {
+                            $name = '';
+                        }
+                        
+                        $cover = $v;
+
+                        if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
+                            $replace[] = array('type' => 6, 'content' => $file, 'cover' => $cover, 'name' => $name);
+                        } else {
+                            $replace[] = array('type' => 5, 'content' => $file, 'cover' => $cover, 'name' => $name);
+                        }
+                    }
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'data-id')) {
+            # 视频+直播
+            preg_match_all('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $content, $matches);
+            
+            
+            if (!isset($matches[2][0])) {
+                preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $content, $matches);
+                $temp = array();
+                if (isset($matches[2][0]) && isset($matches[3][0])) {
+                    $temp = $matches;
+                    $matches[2] = $temp[3];
+                    $matches[3] = $temp[2];
+                    unset($temp);
+                }
+            }
+            
+            if (isset($matches[2][0]) && isset($matches[3][0])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    if ($matches[3][$k] == 'video/lib/core.vod') {
+                        $method = 'video/lib/vod';
+                        $type = 2;
+                    } else {
+                        $type = 3;
+                        $method = 'video/lib/live';
+                    }
+
+                    $info = Dever::load($method)->get($v);
+                    if (isset($info['content'])) {
+                        unset($info['content']);
+                    }
+
+                    if ($type == 3) {
+                        # 查看是否有预约
+                        if ($uid > 0) {
+                            $info['user_act']['note'] = Dever::load('act/lib/note')->get($uid, $v, $type);
+                        } else {
+                            $info['user_act']['note'] = 2;
+                        }
+                    }
+                    $replace[] = array('id' => $v, 'type' => $type, 'content' => $info);
+                }
+            }
+        }
+
+        //$data['content'] = preg_replace('/<div class="dever-drop">([\s\S]*?)<\/div>/i', '', $data['content']);
+
+        $content = explode('{replace}', $content);
+        $data['content_array'] = array();
+        //print_r($content);die;
+        foreach ($content as $k => $v) {
+            $v = trim($v);
+            if (is_numeric($v) && $v >= 0 && isset($replace[$v])) {
+                $data['content_array'][] = $replace[$v];
+            } elseif ($v) {
+                $data['content_array'][] = array
+                (
+                    'type' => 1,
+                    'content' => $v,
+                );
+            }
+        }
+
+        if (!$data['content_array']) {
+            $data['content_array'][] = array
+            (
+                'type' => 1,
+                'content' => $data['content'],
+            );
+        }
+
+        unset($data['content']);
+
+        return $data;
+    }
+
+    # 获取相关推荐
+    public function getRelation($info)
+    {
+        $where['noid'] = $info['id'];
+        $where['cate_id'] = $info['cate_id'];
+        return Dever::db('content/article')->getRelation($where);
+    }
+
+    # 增加浏览量
+    public function addView($id)
+    {
+        Dever::db('content/article')->addView($id);
+    }
+}

+ 76 - 0
app/content/lib/Author.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Author
+{
+    # 更新数据
+    public function data($id, $name, $data)
+    {
+        $source_table = Dever::input('source_table');
+
+        $author = Dever::param('author_id', $data);
+
+        if ($author && $id > 0 && $source_table) {
+            $info = Dever::db('content/author')->one($author);
+            if (!$info) {
+                $insert['name'] = $author;
+                $author = Dever::db('content/author')->insert($insert);
+            }
+
+            Dever::db($source_table)->update(array('where_id' => $id, 'author_id' => $author));
+        }
+    }
+
+    # 搜索
+    public function search_api()
+    {
+        $keyword = Dever::input('keyword');
+
+        $yes = Dever::input('yes');
+
+        $where = array();
+
+        if ($yes) {
+            $yes = Dever::db('content/author')->getAll(array('ids' => $yes));
+        }
+        if (!$keyword) {
+            $where['limit'] = '0,50';
+            $data = Dever::db('content/author')->getAll($where);
+        } else {
+            $where['name'] = $keyword;
+            $data = Dever::db('content/author')->getAll($where);
+        }
+
+        $insert = array();
+        if (!$data && $keyword) {
+            $insert[0]['name'] = $keyword . '[新增]';
+            $insert[0]['value'] = $keyword;
+        }
+
+        $result = array();
+        if ($yes) {
+            foreach ($yes as $k => $v) {
+                if (isset($data[$k])) {
+                    unset($data[$k]);
+                }
+                $yes[$k]['selected'] = 'selected';
+            }
+            $data = $insert + $yes + $data;
+
+            $data = array_merge($data, array());
+        } else {
+            $data = $insert + $data;
+
+            $data = array_merge($data, array());
+        }
+
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
+        return $data;
+    }
+}

+ 60 - 0
app/content/lib/Manage.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Manage
+{
+    private function search($table = 'content/article')
+    {
+        $keyword = Dever::input('keyword');
+
+        $yes = Dever::input('yes');
+
+        $where = array();
+
+        $cate = Dever::input('cate');
+        if ($cate) {
+            $where['cate_id'] = $cate;
+        }
+
+        if ($yes) {
+            $yes = Dever::db($table)->search(array('ids' => $yes));
+        }
+        if (!$keyword) {
+            $where['limit'] = '0,50';
+            $data = Dever::db($table)->search($where);
+        } else {
+            $where['name'] = $keyword;
+            $data = Dever::db($table)->search($where);
+        }
+
+        $result = array();
+        if ($yes) {
+            foreach ($yes as $k => $v) {
+                if (isset($data[$k])) {
+                    unset($data[$k]);
+                }
+                $yes[$k]['selected'] = 'selected';
+            }
+            $data = $yes + $data;
+
+            $data = array_merge($data, array());
+        } else {
+            $data = array_merge($data, array());
+        }
+
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
+        return $data;
+    }
+
+    # 搜索文章
+    public function search_article_api()
+    {
+        return $this->search('content/article');
+    }
+}

+ 19 - 0
app/content/lib/Page.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Page
+{
+    # 更新数据
+    public function link($id)
+    {
+    	$info = Dever::db('content/page')->one($id);
+        $url = Dever::url('page?key=' . $info['key'], 'main');
+
+        $html = '<a href="'.$url.'" target="_blank">点此查看</a>';
+
+        return $html;
+    }
+}

+ 268 - 0
app/push/database/data.php

@@ -0,0 +1,268 @@
+<?php
+
+# 定义几个常用的选项
+$option = array
+(
+    1 => '显示',
+    2 => '不显示',
+);
+
+$type = Dever::config('base')->type;
+$type[10] = '链接';
+
+
+$list = function()
+{
+    return Dever::db('push/info')->state();
+};
+$info = Dever::input('search_option_info_id');
+$type_default = 1;
+if ($info) {
+    $info = Dever::load('push/info-one', $info);
+
+    if (!$info) {
+        echo 'error';die;
+    }
+    $function = explode(',', $info['function']);
+    
+    foreach ($type as $k => $v) {
+        if (!in_array($k, $function)) {
+            unset($type[$k]);
+        } else {
+            $type_default = $k;
+        }
+    }
+    $info['name'] .= '下的推送数据管理';
+    $info['col'] = explode(',', $info['col']);
+    /*
+    $preview = $info['preview'];
+    $preview_height = $info['preview_height'] ? $info['preview_height'] : 500;
+    */
+
+    $name_state = in_array(1, $info['col']);
+    $link_state = in_array(2, $info['col']);
+    $pic_state = in_array(3, $info['col']);
+    $content_state = in_array(4, $info['col']);
+    $share_pic_state = in_array(5, $info['col']);
+
+    /*
+    if ($info['data_type']) {
+        $type = explode("\r\n", $info['data_type']);
+    }
+    */
+} else {
+    $info = array();
+    $info['name'] = '推送数据管理';
+    $info['col_pic'] = '100X100';
+    $info['col_share_pic'] = '100X100';
+    $info['col_content'] = '30';
+    $info['type'] = 1;
+    $name_state = true;
+    $link_state = false;
+    $pic_state = false;
+    $share_pic_state = false;
+    $content_state = false;
+    $preview = '';
+    $preview_height = 0;
+}
+
+
+return array
+(
+    # 表名
+    'name' => 'data',
+    # 显示给用户看的名称
+    'lang' => $info['name'],
+    'order' => 20,
+    //'menu' => false,
+
+    //'desc' => '预览地址:<br /><iframe id="preview" height="'.$preview_height.'" width="100%"  frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" src="'.$preview.'" ></iframe>',
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            //'list'        => true,
+        ),
+
+        'info_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '选择推送位',
+            'default'   => Dever::input('search_option_info_id', '1'),
+            'desc'      => '推送位',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'update'    => 'hidden',
+            'option'    => $list,
+            'list'      => true,
+            'value'     => Dever::input('search_option_info_id', '1'),
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '类型',
+            'default'   => ''.$type_default.'',
+            'desc'      => '请选择类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'search'    => 'select',
+            'option'    => $type,
+            'control'   => 'type',
+        ),
+
+        'article_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联文章-如不选择,则点击进入文章列表',
+            'default'   => '',
+            'desc'      => '关联文章',
+            'match'     => 'option',
+            'update'    => 'select',
+            'show'      => 'type=1',
+            'update_search' => 'content/lib/manage.search_article',
+        ),
+
+        'olink'      => array
+        (
+            'type'      => 'varchar-400',
+            'name'      => '链接',
+            'default'   => '',
+            'desc'      => '请输入链接',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'      => 'type=10',
+            //'search'    => 'fulltext',
+            //'list'        => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '标题-手动干扰项,如想修改当前推送位的标题请在此修改',
+            'default'   => '',
+            'desc'      => '请输入标题',
+            'match'     => $name_state ? 'option' : 'option',
+            'update'    => $name_state ? 'text' : 'hidden',
+            'search'    => $name_state ? 'fulltext' : '',
+            'list'      => $name_state ? 'Dever::load("push/lib/manage.name", {id})' : false,
+            'edit'      => $name_state ? true : false,
+        ),
+
+        'link'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '链接-手动干扰项,如想修改当前推送位的链接请在此修改',
+            'default'   => '',
+            'desc'      => '请输入链接',
+            'match'     => $link_state ? 'option' : 'option',
+            //'update'    => $link_state ? 'text' : 'hidden',
+            //'search'    => $link_state ? 'fulltext' : '',
+            //'list'        => $link_state ? true : false,
+            //'edit'      => $link_state ? true : false,
+        ),
+
+        'pic'       => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '图片或图标-手动干扰项,请上传' . $info['col_pic'] . '大小的图片',
+            'default'   => '',
+            'desc'      => '请选择图片',
+            'match'     => $pic_state ? 'option' : 'option',
+            'update'    => $pic_state ? 'image' : 'hidden',
+            'search'    => $pic_state ? 'fulltext' : '',
+            //'list'        => $pic_state ? true : false,
+            'key'       => 1
+        ),
+
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '描述-手动干扰项,字数请不要超过' . $info['col_content'] . '个汉字,前台展示时会自动过滤',
+            'default'   => '',
+            'desc'      => '请输入描述',
+            'match'     => $content_state ? 'option' : 'option',
+            //'update'    => $content_state ? 'editor' : 'hidden',
+        ),
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        # 获取列表页
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'type_no' => array('yes-type', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,10',
+            'col' => 'name,pic,olink as link,type,article_id,cdate',
+        ),
+
+        # 获取列表页 带有分页的
+        'getAllPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'type_no' => array('yes-type', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => 'name,pic,olink as link,type,article_id,cdate',
+        ),
+    ),
+);

+ 302 - 0
app/push/database/info.php

@@ -0,0 +1,302 @@
+<?php
+
+$type = array
+(
+    1 => '手动输入',
+);
+
+$function = Dever::config('base')->type;
+$function[10] = '链接';
+
+$col = array
+(
+    1 => '标题',
+    //2 => '链接',
+    3 => '图片',
+    //4 => '描述',
+);
+
+return array
+(
+    # 表名
+    'name' => 'info',
+    # 显示给用户看的名称
+    'lang' => '推送位管理',
+    'order' => 10,
+    'check' => 'key',
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '推送位ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            //'list'        => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '推送位标题',
+            'default'   => '',
+            'desc'      => '请输入推送位标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'key'       => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '推送位标识',
+            'default'   => '',
+            'desc'      => '推送位标识',
+            'match'     => 'is_string',
+            'update'    => Dever::input('where_id') ? 'hidden' : 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            //'auth'      => '!{key}'
+        ),
+
+        'num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '数据显示条数-为空或小于0则取默认值20,只对前台有效,当有分页时,则为每页显示的条数',
+            'default'   => '20',
+            'desc'      => '数据显示条数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '推送位类型',
+            'default'   => '1',
+            'desc'      => '请选择推送位类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'radio',
+            'search'    => 'select',
+            //'list'        => true,
+            'control'       => 'type',
+        ),
+
+        /*
+        'data_type'     => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '数据类型定义-多个用换行隔开,必须有一个值,主要用于该推送位有多种不同类型的值',
+            'default'   => '默认类型',
+            'desc'      => '请选择推送位类型',
+            'match'     => 'is_string',
+            //'update'  => 'textarea',
+            //'show'        => array('type_1'),
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '自定义内容',
+            'default'   => '',
+            'desc'      => '请输入自定义内容',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+            'show'      => 'type=4,5,6',
+        ),
+
+        'sql_method'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '选择sql执行之后的方法',
+            'default'   => '1',
+            'desc'      => '选择sql执行之后的方法',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $sqlMethod,
+            'show'      => 'type=5',
+        ),
+
+        'define'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '选择预定义方法',
+            'default'   => '',
+            'desc'      => '请选择预定义方法',
+            'match'     => 'is_string',
+            'update'    => 'select',
+            'option'    => $define,
+            'show'      => 'type=3'
+        ),
+        */
+
+        'function'       => array
+        (
+            'type'      => 'varchar-30',
+            'name'      => '启用的功能',
+            'default'   => '1,10',
+            'desc'      => '启用的功能',
+            'match'     => 'is_string',
+            'option'    => $function,
+            'update'    => 'checkbox',
+            'show'      => 'type=1',
+        ),
+
+        'col'       => array
+        (
+            'type'      => 'varchar-30',
+            'name'      => '启用的字段',
+            'default'   => '1',
+            'desc'      => '请选择启用的字段',
+            'match'     => 'is_string',
+            'option'    => $col,
+            'update'    => 'checkbox',
+            'show'      => 'type=1',
+            'control'   => 'col',
+        ),
+
+        'col_pic'       => array
+        (
+            'type'      => 'varchar-20',
+            'name'      => '图片尺寸提醒-请直接输入提醒的文字即可,如100X100',
+            'default'   => '100X100',
+            'desc'      => '图片尺寸提醒',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'show'      => 'col=3',
+        ),
+
+        'col_content'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '内容长度限制-必须是数字',
+            'default'   => '30',
+            'desc'      => '内容长度限制',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'show'      => 'col=4',
+        ),
+
+        /*
+        'relate_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '请输入推送位id',
+            'default'   => '',
+            'desc'      => '请输入推送位id',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'show'      => 'type=2',
+        ),
+
+        'preview'       => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '推送位预览地址',
+            'default'   => '',
+            'desc'      => '推送位预览地址',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'preview_height'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '推送位预览的高度',
+            'default'   => '500',
+            'desc'      => '推送位预览的高度',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+        */
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            //'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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    # 权限精细控制 加入到该项目的详细权限中,注意与top的不同
+    /*
+    'auth' => array
+    (
+        # 数据来源
+        'data' => 'all',
+        # 所属项目
+        'project' => 'module',
+        # 项目名称
+        'project_name' => '推送位管理',
+    ),
+    */
+
+    'manage' => array
+    (
+        'delete' => false,
+        //'edit' => false,
+        //'insert' => $curPage ? true : false,
+        'list_button' => array
+        (
+            'add' => array('新增数据', '"data&search_option_info_id={id}&oper_parent=info"', '{type} == 1'),
+
+            'list' => array('数据列表', '"data&search_option_info_id={id}&oper_parent=info"'),
+        ),
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        # 获取列表页
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                //'page_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 8 - 0
app/push/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'push');
+define('DEVER_APP_LANG', '推送管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 199);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-template-1');
+include(DEVER_APP_PATH . '../boot.php');

+ 144 - 0
app/push/lib/Data.php

@@ -0,0 +1,144 @@
+<?php
+
+namespace Push\Lib;
+
+use Dever;
+
+class Data
+{
+    public function get($key, $name, $total = 10, $page = false, $limit = false)
+    {
+        $info = $this->getInfo($key, $name, $total);
+
+        $data = array();
+        if ($info) {
+            if (!$info['num']) {
+                $info['num'] = 20;
+            }
+            if ($limit > 0) {
+                $info['num'] = $limit;
+            }
+
+            $where = array();
+            $where['info_id'] = $info['id'];
+
+            if ($page) {
+                $where['page'] = array($info['num'], 'list');
+                $data = Dever::db('push/data')->getAllPage($where);
+            } else {
+                $where['limit'] = '0,' . $info['num'];
+                $data = Dever::db('push/data')->getAll($where);
+            }
+
+            if ($data) {
+                foreach ($data as $k => $v) {
+                    $data[$k] = $this->getData($v);
+                }
+            }
+        }
+
+        return $data;
+    }
+
+    public function getOne($key, $name, $total = 10, $data_name)
+    {
+        $info = $this->getInfo($key, $name, $total);
+        $data = array();
+        if ($info) {
+            $where = array();
+            $where['info_id'] = $info['id'];
+            $where['name'] = $data_name;
+            $data = Dever::db('push/data')->one($where);
+            if ($data) {
+                $data = $this->getData($data);
+            } else {
+                $where['type'] = 10;
+                Dever::db('push/data')->insert($where);
+            }
+        }
+
+        return $data;
+    }
+
+    private function getInfo($key, $name, $total)
+    {
+        $info = Dever::db('push/info')->one(array('key' => $key));
+
+        if (!$info) {
+            $insert['key'] = $key;
+            $insert['name'] = $name;
+            $insert['num'] = $total;
+            $insert['col'] = '1,3';
+            $info['id'] = Dever::db('push/info')->insert($insert);
+            $info['num'] = $insert['num'];
+        }
+
+        return $info;
+    }
+
+    private function getData($info)
+    {
+        $info['id'] = 0;
+        if ($info['type'] < 10 || $info['type'] == 13) {
+            $table = Dever::config('base')->type_table[$info['type']];
+            $method = 'one';
+            if ($info['type'] == 1) {
+                $id = $info['article_id'];
+            }
+
+            unset($info['article_id']);
+            if ($id > 0) {
+                $info['id'] = $id;
+                $data = Dever::db($table)->$method($id);
+                if (isset($data) && $data) {
+                    if (isset($data['name']) && $data['name'] && !$info['name']) {
+                        $info['name'] = $data['name'];
+                    }
+
+                    if (isset($data['pic_cover']) && $data['pic_cover'] && !$info['pic']) {
+                        $info['pic'] = $data['pic_cover'];
+                    }
+
+                    if (isset($data['pdate']) && $data['pdate']) {
+                        $info['cdate'] = $data['pdate'];
+                    }
+
+                    if (isset($data['cate_id']) && $data['cate_id']) {
+                        $cate = Dever::db('content/cate')->one($data['cate_id']);
+                        $info['cate_name'] = $cate['name'];
+                    }
+
+                    if (isset($data['author_id']) && $data['author_id']) {
+                        $author = Dever::db('content/author')->one($data['author_id']);
+                        $info['author_name'] = $author['name'];
+                    }
+
+                    $info['link'] = Dever::load('main/content')->link($data);
+
+                    if (isset($data['template']) && $data['template'] == 2) {
+                        $info['name'] = '<i class="ico-video"></i>' . $info['name'];
+                    }
+                }
+            }
+        } else {
+            unset($info['article_id']);
+            if (isset($info['olink']) && $info['olink']) {
+                $info['link'] = $info['olink'];
+            }
+        }
+
+        if ($info['link']) {
+            if (!strstr($info['link'], 'http')) {
+                $info['link'] = 'http://' . $info['link'];
+            }
+        }
+
+        $info['cdate'] = date('Y-m-d', $info['cdate']);
+
+        if (isset($info['name']) && $info['name']) {
+            $info['name'] = Dever::cut($info['name'], 20, '...');
+        }
+
+        return $info;
+    }
+}

+ 52 - 0
app/push/lib/Manage.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace Push\Lib;
+
+use Dever;
+
+class Manage
+{
+    //{source_id} > 0 ? ("{name}" ? "{name}" : Dever::load("sad/supply-one#name", {source_id})) : "{name}"
+    public function name($id)
+    {
+        $info = Dever::db('push/data')->one($id);
+
+        if ($info['name']) {
+            return $info['name'];
+        }
+
+        if ($info['type'] < 10) {
+            $table = Dever::config('base')->type_table[$info['type']];
+            $audit = array
+            (
+                //'audit' => 2,
+                //'status' => 2,
+                'state' => 1,
+            );
+            if ($info['type'] == 1) {
+                $audit['id'] = $info['article_id'];
+                $data = Dever::db($table)->one($audit);
+            } elseif ($info['type'] == 2) {
+                $audit['id'] = $info['vod_id'];
+                $data = Dever::db($table)->one($audit);
+            } elseif ($info['type'] == 3) {
+                $audit['id'] = $info['live_id'];
+                $data = Dever::db($table)->one($audit);
+            } elseif ($info['type'] == 4) {
+                $audit['id'] = $info['journal_id'];
+                $data = Dever::db($table)->one($audit);
+            } elseif ($info['type'] == 6) {
+                $audit['id'] = $info['feature_id'];
+                $data = Dever::db($table)->one($audit);
+            } elseif ($info['type'] == 7) {
+                $data = Dever::db($table)->one(array('state' => 1, 'id' => $info['applet_id']));
+            }
+
+            if (isset($data) && $data && isset($data['name'])) {
+                return $data['name'];
+            }
+        }
+
+        return $info['name'];
+    }
+}

+ 382 - 0
app/res/database/info.php

@@ -0,0 +1,382 @@
+<?php
+
+$audit = Dever::config('base')->audit;
+
+$status = Dever::config('base')->status;
+
+$config = array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '资源列表',
+	'order' => 200,
+	'auto' => 10000000,
+
+	'end' => array
+	(
+		'insert' => 'res/lib/manage.infoUpdate',
+		'update' => 'res/lib/manage.infoUpdate',
+	),
+
+	# 同步更新另外一个或多个表的数据,将数据同步到关联表中
+	'sync' => array
+	(
+		'res/info_category' => array
+		(
+			# 更新另外一个表的字段 => 本表的字段
+			'where' => array('info_id', 'id'),
+			# 要更新的数据
+			'update' => array('category_id' => 'category'),
+			# 同步更新的类型,delete为先删再插入,update为直接更新
+			'type' => 'delete',
+		)
+	),
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'textarea',
+			'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'category'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '分类',
+			'default' 	=> '',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_string',
+			'search'	=> 'linkage',
+			'update'	=> 'linkage',
+			'option'	=> Dever::url('api.get', 'category'),
+			//'list'		=> 'Dever::load("category/api.string", "{category}")',
+		),
+
+		# 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
+		'top_category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '顶级分类ID-顶级分类,用于分类查询',
+			'default' 	=> '-1',
+			'desc' 		=> '顶级分类ID',
+			'match' 	=> 'is_numeric',
+		),
+
+		'second_category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '二级分类ID-二级分类,用于分类查询',
+			'default' 	=> '-1',
+			'desc' 		=> '二级分类ID',
+			'match' 	=> 'is_numeric',
+		),
+
+		'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '子分类ID-最后一个级别的分类,用于分类查询',
+			'default' 	=> '-1',
+			'desc' 		=> '子分类ID',
+			'match' 	=> 'is_numeric',
+		),
+
+		'pic_cover'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '封面图-图片尺寸300*300px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,用户上传图片之后会自动进行居中裁剪',
+			'default' 	=> '',
+			'desc' 		=> '封面图',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+			'list_name'	=> '资源详情',
+			'list'		=> 'Dever::load("res/lib/manage.info", "{id}")',
+		),
+
+		'pic'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '多张图片-图片尺寸随意,一般为用户上传,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '多张图片',
+			'match' 	=> 'option',
+			'update'	=> 'images',
+			'key' 		=> '1',
+		),
+
+		'num_view'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '阅读数',
+			'default' 	=> '0',
+			'desc' 		=> '请填写阅读数',
+			'match' 	=> 'option',
+			'search'	=> 'order',
+			'list'		=> '{num_view}+{num_add_view}',
+		),
+
+		'num_add_view'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '阅读数基数',
+			'default' 	=> '0',
+			'desc' 		=> '阅读数基数',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '创建人',
+			'default' 	=> '-1',
+			'desc' 		=> '创建人',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'search'	=> array
+			(
+				'api' => 'passport/user-all',
+				'col' => 'username',
+				'result' => 'id',
+			),
+		),
+
+		'audit'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '审核',
+			'default' 	=> '2',
+			'desc' 		=> '审核',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $audit,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '状态',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'admin_editor'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '后台操作人',
+			'default' 	=> '1',
+			'desc' 		=> '后台操作人',
+			'match' 	=> 'is_numeric',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越大越靠前,相当于置顶',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'udate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '更新时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+		),
+
+		'content'		=> array
+		(
+			'type' 		=> 'text-800',
+			'name' 		=> '内容',
+			'default' 	=> '',
+			'desc' 		=> '内容',
+			'match' 	=> 'is_string',
+			//'update'	=> 'editor',
+			'key'		=> '1',
+		),
+
+		'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})',
+		),
+	),
+
+# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'uid,category,top_category_id,second_category_id,category_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+		// 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
+		'res' => array
+		(
+			//'css' => 'demo',
+		),
+		//'insert' => false,
+		//'delete' => false,
+		'mul' => true,
+		# 自定义快捷新增和编辑
+        'button' => array
+        (
+        	//'类别管理' => array('list', 'cate&project=demand&search_option_key=cate&search_option_tablename=类别&oper_parent=info&oper_project=demand'),
+        ),
+
+		# 列表里的按钮
+		'list_button' => array
+		(
+			'add' => array('属性设置', '"info_attr
+				&project=res
+				&search_option_info_id={id}
+				&search_option_category={category}
+				&oper_parent=info&oper_project=res
+				&oper_save_jump=info
+				&where_id={id}"'),
+			'br1' => array('<br />'),
+			'delete' => '删除',
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		# 后台搜索用到
+		'search' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'name' => array('yes', 'like'),
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'limit' => '0,1000',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+
+		# 列表
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'audit' => 2,
+				'category' => array('yes', 'like'),
+				'top_category_id' => 'yes',
+				'second_category_id' => 'yes',
+				'category_id' => 'yes',
+				//'status' => 1,
+				//'poster_pay_type' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'limit' => '0,10',
+			//'page' => array(10, 'list'),
+			'col' => '*',
+		),
+
+		# 分页
+		'getPageAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'name' => array('yes', 'like'),
+				'audit' => 2,
+				'category' => array('yes', 'like'),
+				'top_category_id' => 'yes',
+				'second_category_id' => 'yes',
+				'category_id' => 'yes',
+				//'status' => 1,
+				//'poster_pay_type' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		),
+		
+		# 更新浏览量
+		'addView' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'num_view' => array('1', '+='),
+			),
+		),
+	),
+);
+
+return $config;

+ 132 - 0
app/res/database/info_attr.php

@@ -0,0 +1,132 @@
+<?php
+list($category, $attr, $table, $create) = getInfoAttr();
+
+//print_r($attr);die;
+$config = array
+(
+	# 表名
+	'name' => 'info_attr' . $table,
+	# 显示给用户看的名称
+	'lang' => '属性规格',
+	'order' => 100,
+	'menu' => false,
+	'create' => $create,
+	'attr' => $attr,
+	'auto' => 10000000,
+
+	'end' => array
+	(
+		'insert' => 'attr/lib/manage.update',
+		'update' => 'attr/lib/manage.update',
+	),
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            'value'     => Dever::input('where_id')
+            //'list'        => true,
+		),
+
+		'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '资源',
+            'default'   => '',
+            'desc'      => '资源',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'category'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '分类-直接继承主表的分类',
+			'default' 	=> '',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_string',
+			'update'    => 'hidden',
+            'value'     => $category
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'info_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		# 分页
+		'getPageAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'audit' => array('yes-t_2.audit', 2),
+				'category' => array('yes-t_2.category', 'like'),
+				'top_category_id' => array('yes-t_2.top_category_id'),
+				'second_category_id' => array('yes-t_2.second_category_id'),
+				'category_id' => array('yes-t_2.category_id'),
+				//'status' => 1,
+				//'poster_pay_type' => array('yes-t_2.poster_pay_type', 2),
+				'state' => array('yes-t_2.state', 1),
+			),
+			# 联表
+			'join' => array
+			(
+				array
+				(
+					'table' => 'res/info',
+					'type' => 'left join',
+					'on' => array('info_id','id'),
+					'col' => 'info_id',
+				),
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 't_1.id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		),
+	),
+);
+
+
+# 属性完全自定义吧。这种情况用dever就是方便了。其他框架都需要自己实现
+Dever::load('attr/api')->setDatabaseConfig($attr, $config);
+
+return $config;

+ 65 - 0
app/res/database/info_category.php

@@ -0,0 +1,65 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'info_category',
+	# 显示给用户看的名称
+	'lang' => '资源分类关联表',
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+		
+		'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '资源ID',
+			'default' 	=> '',
+			'desc' 		=> '资源ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类ID',
+			'default' 	=> '',
+			'desc' 		=> '分类ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', DEVER_TIME),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+	),
+);

+ 76 - 0
app/res/database/info_price.php

@@ -0,0 +1,76 @@
+<?php
+
+$config = array
+(
+	# 表名
+	'name' => 'info_price',
+	# 显示给用户看的名称
+	'lang' => '资源价格',
+	'order' => 200,
+	'menu' => false,
+	'auto' => 10000000,
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'textarea',
+			'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越大越靠前,相当于置顶',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'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,
+			'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+);
+
+return $config;

+ 8 - 0
app/res/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'res');
+define('DEVER_APP_LANG', '资源管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 98);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
+include(DEVER_APP_PATH . '../boot.php');

+ 352 - 0
app/res/lib/Info.php

@@ -0,0 +1,352 @@
+<?php
+
+# 核心类,数据获取类
+
+namespace Res\Lib;
+
+use Dever;
+
+class Info
+{
+	private $table_info = 'res/info';
+	private $table_attr = 'res/info_attr';
+    /**
+     * instance
+     *
+     * @var string
+     */
+    protected static $instance;
+
+    /**
+     * init
+     *
+     * @return mixed
+     */
+    public static function init($top_category = false)
+    {
+        if (empty(self::$instance[$top_category])) {
+            self::$instance[$top_category] = new self($top_category);
+        }
+
+        return self::$instance[$top_category];
+    }
+
+	public function __construct($top_category = false)
+	{
+		$this->top_category = $top_category;
+
+        # 必有有分类才能进入到需求中
+        if (!$this->top_category) {
+            Dever::alert('错误的分类信息');
+        }
+	}
+
+    private function setAttr($cate, $order = 'list_reorder')
+    {
+        if ($order != 'list_reorder') {
+            Dever::config('base')->attrOrder = $order;
+        }
+        
+        Dever::setInput('search_option_category', $cate);
+        $attr = Dever::db($this->table_attr, array(), $cate);
+        return $attr;
+    }
+
+    public function getAttr($cate)
+    {
+        return Dever::load('attr/api')->getAttrByCate($cate, 'list');
+    }
+
+    # 根据分类获取需求列表数据
+    public function getData($cate = false, $limit = '0,10', $page = false, $attr = true)
+    {
+        if (!$limit) {
+            $limit = '0,10';
+        }
+        $where = $data = array();
+        if (!$cate) {
+            if ($this->top_category > 0) {
+                $where['top_category_id'] = $this->top_category;
+            }
+        } elseif (strstr($cate, ',')) {
+            $where['category'] = $this->top_category . ',' . $cate;
+        } else {
+            $where['second_category_id'] = $cate;
+        }
+        
+        if ($page) {
+            $method = 'getPageAll';
+        } else {
+            $where['limit'] = $limit;
+            $method = 'getAll';
+        }
+        $name = Dever::input('name');
+        if ($name) {
+            $where['name'] = $name;
+        }
+        $data = Dever::db($this->table_info)->$method($where);
+        if ($data && $attr) {
+            foreach ($data as $k => $v) {
+                $data[$k] = $this->info($v, 'list_reorder');
+            }
+        }
+
+        return $data;
+    }
+
+    # 获取某个用户的需求列表
+    public function getDataByUid($uid)
+    {
+        $where['poster_uid'] = $uid;
+        
+        if ($where) {
+            $data = Dever::db($this->table_info)->getPageAll($where);
+            if ($data) {
+                foreach ($data as $k => $v) {
+                    $data[$k] = $this->info($v, 'list_reorder');
+                }
+            }
+        }
+
+        return $data;
+    }
+
+    # 根据属性获取需求列表数据 这里带有检索属性的功能 此处还需优化
+    public function getDataByAttr($cate = false, $where = array())
+    {
+        if (!$cate) {
+            Dever::alert('错误的分类信息');
+        }
+        $where_sql = array();
+        $name = Dever::input('name');
+        if ($name) {
+            //$where['name'] = $name;
+            $where_sql[] = ' t_2.name = "'.$name.'"';
+        }
+
+        $attr = $this->setAttr($this->top_category . ',' . $cate);
+        //print_r($attr->config['attr']);
+
+        $where_sql = Dever::load('attr/api')->getSql($attr->config['attr'], $where, $where_sql);
+        if (!$where_sql) {
+            return array();
+        }
+        # 这里用pdo的数据绑定,字符串字段的区间查询就是有问题。。。只能用sql了
+        //$data = $attr->getPageAll($where);
+
+        $page['template'] = 'list';
+        $page['num'] = 10;
+        $where_sql = implode(' and ', $where_sql);
+
+        $sql = 'SELECT t_2.* FROM `info_res_'.$attr->config['name'].'` as t_1 Left Join `info_res_info` AS t_2 ON t_1.`info_id`=t_2.`id` WHERE '.$where_sql.' order by t_2.`reorder` desc,t_2.`id` desc';
+
+        $data = $attr->fetchAll($sql, array(), $page);
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $data[$k] = $this->info($v, 'list_reorder');
+            }
+        }
+
+        return $data;
+    }
+
+	# 获取列表页的搜索条件
+    public function getSearch($cate = false)
+    {
+    	# 获取搜索条件
+        if (!$cate) {
+            $search_cate = $cate = $this->top_category;
+        } else {
+            $search_cate = $this->top_category . ',' . $cate;
+        }
+        # 1是当前用户所在的城市,暂时写死
+        # 获取搜索条件
+        $search = Dever::load('attr/api')->getSearch($search_cate, true, 1, false, 3);
+        # 下级分类
+        $search['cate'] = Dever::load('category/api')->getList($cate);
+
+        # 上级分类
+        $search['parent_cate'] = Dever::load('category/api')->getList($this->top_category);
+        return $search;
+    }
+
+    public function getPayState($uid, $id, $category)
+    {
+        $pay_where['category'] = $category;
+        $pay = Dever::db('res/pay')->one($pay_where);
+        $pay_state = 0;
+        if ($pay && $pay['num'] > 0) {
+            $pay_state = $pay['num'];
+        } elseif (strstr($category, ',')) {
+            $category = explode(',', $category);
+            $category = array_pop($category);
+            $pay_state = $this->getPayState($uid, $id, $category);
+        }
+
+        //$update['where_id'] = $id;
+        //$update['poster_pay_type'] = $pay_state;
+        //Dever::db($this->table_info)->update($update);
+
+        return $pay_state;
+    }
+
+    # 更新需求
+    public function update($top, $cate, $data, $id, $uid)
+    {
+        if ($cate) {
+            $category = $top . ',' . $cate;
+        } else {
+            $category = $top;
+        }
+        $attr = $this->setAttr($category);
+
+        $attr_update = Dever::preInput('attr_');
+        if ($attr_update) {
+            foreach ($attr_update as $k => $v) {
+                if (strstr($k, '_s')) {
+                    $k = str_replace('_s', '', $k);
+                    $attr_update[$k] = $v;
+                }
+                if (strstr($k, '_e')) {
+                    $k = str_replace('_e', '', $k);
+                    $attr_update[$k] .= ',' . $v;
+                }
+            }
+        }
+
+        $update = array();
+        $update['name'] = $data['name'];
+        $update['category'] = $category;
+        $update['pic'] = $data['pic'];
+        //$update['pic_cover'] = $data['pic'];
+        $update['poster_uid'] = $uid;
+        if (isset($data['view_price']) && $data['view_price']) {
+            $update['view_price'] = $data['view_price'];
+        }
+        if ($uid && $id) {
+            # 此处要判断是用户自己的
+            $info = Dever::db($this->table_info)->one($id);
+
+            /*
+            if ($uid == $info['poster_uid']) {
+                Dever::alert('错误的用户参数');
+            }
+            */
+            $update['where_id'] = $attr_update['where_id'] = $id;
+            Dever::db($this->table_info)->update($update);
+            Dever::db($this->table_attr)->update($attr_update);
+            $pay = 0;
+        } else {
+            $id = Dever::db($this->table_info)->insert($update);
+            $attr_update['category'] = $update['category'];
+            $attr_update['info_id'] = $id;
+            $attr_update['id'] = $id;
+            Dever::db($this->table_attr)->insert($attr_update);
+
+            # 验证是否需要支付,根据category判断
+            $pay = false;
+            //$pay = $this->getPayState($uid, $id, $category);
+
+            $info = Dever::db($this->table_info)->one($id);
+            $info = $this->getInfoLink($info);
+        }
+        return array('id' => $id, 'pay' => $pay, 'cate' => $category, 'top' => $top, 'info' => $info);
+    }
+
+    # 获取需求基本信息
+    public function getInfo($id, $attr = true, $order = 'view_reorder')
+    {
+        $info = Dever::db($this->table_info)->one($id);
+
+        if ($info && $attr) {
+            $info = $this->info($info, $order);
+        }
+
+        if ($info['poster_uid'] < 0) {
+            $info['poster_uid'] = 1;
+        }
+
+        if ($info['poster_uid'] > 0) {
+            $info['user'] = Dever::db('passport/user')->one($info['poster_uid']);
+            $sex = Dever::db('passport/user')->config['sex'];
+            if ($info['user']['area']) {
+                $info['user']['area'] = str_replace(',', '-', $info['user']['area']);
+                $info['user']['area'] .= '-';
+            }
+            $info['user']['text'] = $info['user']['area'] . $sex[$info['user']['sex']];
+
+            if (!$info['user']['avatar']) {
+                $config = Dever::db('main/config')->one();
+                $info['user']['avatar'] = $config['avatar'];
+            }
+        }
+
+        $info['num_view_text'] = $info['num_view'] + $info['num_add_view'];
+
+        $info['num_view_text'] .= '人浏览';
+
+        if ($info['pic']) {
+            $info['pic'] = explode(',', $info['pic']);
+        }
+        
+
+        return $info;
+    }
+
+    # 获取需求基本信息
+    public function info($info, $key = 'list_reorder')
+    {
+        $attr = $this->setAttr($info['category'], $key);
+        $attr_data = $attr->one($info['id']);
+        $info['category_array'] = Dever::load('category/api')->string($info['category']);
+
+        $info['attr'] = array();
+
+        if ($attr->config['attr']) {
+            foreach ($attr->config['attr'] as $k => $v) {
+                if (isset($v[$key]) && $v[$key] > 0) {
+                    if (isset($attr_data['attr_' . $v['id']])) {
+                        $v['value'] = $attr_data['attr_' . $v['id']];
+                    } else {
+                        continue;
+                        $v['value'] = '';
+                    }
+
+                    $v['value_string'] = Dever::load('attr/api')->getValue($v);
+                    
+                    if ($v['ename'] == 'price') {
+                        $info['price'] = $v['value_string'];
+                    } else {
+                        $v['bg'] = 'background-image: url('.$v['icon'].')';
+                        $v['pic'] = '<img src="'.$v['icon'].'" width="18" />';
+                        $info['attr'][] = $v;
+                    }
+                }
+            }
+        }
+       
+        if (isset($info['cdate']) && $info['cdate']) {
+            $info['cdate_string'] = Dever::mdate($info['cdate'], 2);
+        }
+
+        $info = $this->getInfoLink($info);
+        
+    	return $info;
+    }
+
+    public function getInfoLink($info)
+    {
+        if (isset($this->view_path)) {
+            $info['view_path'] = $this->view_path . '?top=' . $info['top_category_id'] . '&id=' . $info['id'];
+            $info['view_link'] = Dever::url($info['view_path']);
+        }
+
+        return $info;
+    }
+
+    public function setViewPath($path)
+    {
+        $this->view_path = $path;
+    }
+}

+ 152 - 0
app/res/lib/Manage.php

@@ -0,0 +1,152 @@
+<?php
+
+namespace Res\Lib;
+
+use Dever;
+
+class Manage
+{
+    /**
+     * 更新信息
+     *
+     * @return mixed
+     */
+    public function infoUpdate($id, $name, $data)
+    {
+        # 更新分类id
+        $category = Dever::param('category', $data);
+        if ($category) {
+            if (is_array($category)) {
+                $category_id = end($category);
+                $top_category_id = $category[0];
+                if (isset($category[1])) {
+                    $second_category_id = $category[1];
+                } else {
+                    $second_category_id = $category[0];
+                }
+                
+            } else {
+                $category_id = $category;
+                $top_category_id = $category;
+                $second_category_id = $category;
+            }
+            
+
+            $update['top_category_id'] = $top_category_id;
+            $update['second_category_id'] = $second_category_id;
+            $update['category_id'] = $category_id;
+            
+        }
+
+        $pic = Dever::param('pic', $data);
+        $pic_cover = Dever::param('pic_cover', $data);
+        if ($pic && !$pic_cover) {
+            if (is_string($pic)) {
+                $pic = explode(',', $pic);
+            }
+            $update['pic_cover'] = $pic[0];
+        }
+
+        if (isset($update)) {
+            $update['where_id'] = $id;
+            Dever::db('res/info')->update($update);
+        }
+    }
+
+    /**
+     * 更新需求属性信息
+     *
+     * @return mixed
+     */
+    public function attrUpdate($id, $name, $data)
+    {
+        print_r($data);die;
+        foreach ($data as $k => $v) {
+
+        }
+    }
+
+    /**
+     * 显示需求信息
+     *
+     * @return mixed
+     */
+    public function info($id)
+    {
+        $info = Dever::db('res/info')->one($id);
+        if ($info) {
+            $table['编号'] = $info['id'];
+            $table['标题'] = $info['name'];
+            $table['分类'] = Dever::load("category/api.string", $info['category']);
+
+            if ($info['pic_cover']) {
+                $table['封面图'] = '<img src="'.$info['pic_cover'].'" width="150" />';
+            }
+
+            if ($info['uid'] > 0) {
+                $user = Dever::load('passport/user-one', $info['uid']);
+                $table['创建人'] = $user['username'] . '(UID:'.$info['uid'].')';
+                if ($poster_pay_type == 1) {
+                    //$table['支付状态'] = '';
+                }
+            }
+
+            //$table['属性'] = $this->attrInfo($info);
+
+            if ($info['cdate']) {
+                $table['发布时间'] = date("Y-m-d H:i:s", $info['cdate']);
+            }
+        }
+
+        return Dever::table($table);
+    }
+
+    private function attrInfo($info)
+    {
+        $table = array();
+
+        $info = Info::init($info['top_category_id']);
+
+        if ($info) {
+            $info = $info->info($info, 'id');
+            if ($info && isset($info['attr'])) {
+                foreach ($info['attr'] as $k => $v) {
+                    $table[$v['name']] = $v['value_string'];
+                }
+            }
+        }
+        
+        return Dever::table($table);
+    }
+
+    public function area($id, $name, $data)
+    {
+        # 不再执行syncone等后续操作
+        Dever::config('base')->after = 1;
+
+        $type = Dever::input('type');
+
+        $area = Dever::param('area', $data);
+
+        if ($area) {
+
+            if (isset($area[2])) {
+                $update['district_id'] = $area[2];
+            }
+
+            if (isset($area[1])) {
+                $update['city_id'] = $area[1];
+            }
+
+            if (isset($area[0])) {
+                $update['province_id'] = $area[0];
+            }
+
+            if (isset($update)) {
+                $update['where_id'] = $id;
+
+                Dever::db($type . '/info')->update($update);
+            }
+        }
+    }
+}

+ 362 - 0
app/res/src/Data.php

@@ -0,0 +1,362 @@
+<?php
+
+# 需求接口类
+
+namespace Res\Src;
+
+use Dever;
+use Res\lib\Info;
+use Main\Lib\Core;
+use Dever\Routing\Uri;
+
+class Data extends Core
+{
+    protected $checkUser = true;
+    # 列表页path
+    private $list_path = 'main/list';//'info/data.getList';//main/list
+    # 详情页path
+    private $view_path = 'main/view';//'info/data.getInfo';//main/view
+
+    private $info = false;
+    public function __construct()
+    {
+        # 当没有top时,就是首页
+        $this->top = Dever::input('top', -1);
+        if ($this->top) {
+            $this->info = Info::init($this->top);
+        }
+
+        # 当没有cate,但有top时就是顶级分类列表页,如果有cate,就是二级分类列表页
+        $this->cate = Dever::input('cate');
+
+        # 当有id时,就是详情页
+        $this->id = Dever::input('id');
+    }
+
+    # 获取顶级分类列表,首页用到
+    public function top()
+    {
+        $top = Dever::load('category/api')->getTop(Dever::config('base')->category);
+
+        $result = array();
+        if ($top) {
+            $cates = array_keys($top);
+
+            $child = Dever::load('category/api')->getChild($cates);
+            $i = 0;
+            $path = $this->list_path;
+            if (Uri::$value == 'submit') {
+                $path = 'submit_next';
+            }
+            foreach ($top as $k => $v) {
+                $result[$i] = $v;
+                $result[$i]['path'] = $path . '?top=' . $v['id'];
+                if (isset($child[$v['id']]) && $child[$v['id']][0]['level'] != -1) {
+                    $result[$i]['child'] = $child[$v['id']];
+                    if (Uri::$value == 'submit') {
+                        $result[$i]['path'] = 'submit_cate?top=' . $v['id'];
+                    } else {
+                        $result[$i]['path'] .= '&cate=' . $child[$v['id']][0]['id'];
+                    }
+                }
+
+                if ($v['status'] == 1) {
+                    $result[$i]['link'] = Dever::url($result[$i]['path']);
+                } else {
+                    $result[$i]['link'] = 'javascript:hui.toast(\'暂未开放\');';
+                }
+                
+                $i++;
+            }
+        }
+
+        return $result;
+    }
+
+    # 获取首页的分类和需求数据
+    # 接口:http://192.168.33.10/info/info/?l=data.getIndex
+    public function getIndex()
+    {
+        $top = Dever::load('res/data.top');
+
+        if ($top) {
+            $this->cate = false;
+            foreach ($top as $k => $v) {
+                $this->info = Info::init($v['id']);
+                # 首页显示多少条需求数据,暂定10条
+                $top[$k]['data'] = $this->getList('0,10', $v);
+            }
+        }
+
+        return $top;
+    }
+
+    # 获取最新需求数据
+    # 接口:http://192.168.33.10/info/demand/?l=data.getNew
+    public function getNew()
+    {
+        $info = Info::init(-1);
+
+        $data = $info->getData($this->cate, '0,10', false, false);
+
+        # 这里需要有用户信息
+        if ($data) {
+            $info->setViewPath($this->view_path);
+            foreach ($data as $k => $v) {
+                if ($v['poster_uid'] < 0) {
+                    $v['poster_uid'] = 1;
+                }
+
+                $data[$k] = $info->getInfoLink($v);
+                $link = $data[$k]['view_link'];
+                $data[$k]['user'] = Dever::db('passport/user')->one($v['poster_uid']);
+                $data[$k]['text'] = '<span class="cuIcon-notifcation"></span><a href="'.$link.'"><span class="text-blue">'.$data[$k]['user']['username'].'刚刚发布:</span>' . Dever::cut($v['name'], 10) . '</a>';
+            }
+        }
+
+        return $data;
+    }
+
+    # 获取搜索条件列表 分类列表页用到
+    # 接口:http://192.168.33.10/info/demand/?l=data.getSearch&top=1&cate=3,7&json=1
+    public function getSearch()
+    {
+        $this->checkInfo();
+        return $this->info->getSearch($this->cate);
+    }
+
+    # 获取搜索条件列表 分类列表页用到 只用到了搜索条件
+    # 接口:http://192.168.33.10/info/demand/?l=data.getSearchList&top=1&cate=3,7&json=1
+    public function getSearchList()
+    {
+        $data = $this->getSearch();
+
+        $result = array();
+        if ($data && $data['cate']) {
+            $result[0]['id'] = -1;
+            $result[0]['name'] = '分类';
+            $result[0]['option'] = $data['cate'];
+
+            $result = array_merge($result, $data['search']);
+        }
+
+        return $result;
+    }
+
+    public function getCateInfo()
+    {
+        $cate = $this->cate ? $this->cate : $this->top;
+        $data = Dever::db('category/info')->one($cate);
+
+        $name = Dever::input('name');
+
+        if ($name) {
+            $data['name'] = urldecode($name);
+        }
+
+        return $data;
+    }
+
+    # 获取分类子信息
+    public function getCateChild()
+    {
+        $data = Dever::load('category/api')->getChild($this->top);
+
+        if ($data) {
+            $data = $data[$this->top];
+            foreach ($data as $k => $v) {
+                $data[$k]['name'] = '我要' . $v['name'];
+                $path = 'submit_next?top=' . $this->top . '&cate=' . $v['id'] . '&name=' . urlencode($data[$k]['name']);
+                $data[$k]['link'] = Dever::url('main/' . $path);
+            }
+        }
+
+        return $data;
+    }
+
+    # 根据顶级分类或者二级分类,获取需求列表 分类列表页用到
+    # 接口:http://192.168.33.10/info/demand/?l=data.getList&top=1&cate=3,7&json=1&&attr_5=1&attr_2=9&attr_4=1
+    public function getList($limit, $cate = array())
+    {
+        $this->checkInfo();
+
+        $page = false;
+
+        if (!$limit) {
+            $page = true;
+        }
+
+        $where = Dever::preInput('attr_');
+
+        $this->info->setViewPath($this->view_path);
+
+        if ($where) {
+            $data = $this->info->getDataByAttr($this->cate, $where);
+        } else {
+            $data = $this->info->getData($this->cate, $limit, $page);
+        }
+
+        if (Dever::input('test') == 1) {
+            return $data;
+        }
+
+        if (!$cate) {
+            $cate = Dever::db('category/info')->one($this->top);
+        }
+
+        $data = array('data' => $data, 'cate' => $cate, 'top' => $this->top);
+        $data['show'] = false;
+        if ($cate && $this->top < 0) {
+            $data['show'] = true;
+        }
+        return Dever::render('render/list', $data, 'main');
+    }
+
+    # 获取当前用户的需求列表
+    # 接口:http://192.168.33.10/info/demand/?l=data.getUserList&top=-1
+    public function getUserList($limit)
+    {
+        $this->checkInfo();
+
+        $data = $this->info->getDataByUid($this->data['uid']);
+
+        return $data;
+    }
+
+    # 获取需求详情
+    # 接口:http://192.168.33.10/info/demand/?l=data.getInfo&top=1&json=1&id=10000000
+    public function getInfo()
+    {
+        if (!$this->id) {
+            Dever::alert('错误的参数,请重试');
+        }
+        $this->checkInfo();
+
+        $data = $this->info->getInfo($this->id);
+
+        $data['like'] = 2;
+        $data['tip'] = 2;
+        # 检查当前用户是否已收藏、已举报
+        if ($this->data['uid'] && $this->data['uid'] > 0) {
+            $data['like'] = Dever::load('service/lib/like')->get($this->data['uid'], $this->id, 1);
+        }
+        
+
+        return $data;
+    }
+
+    # 获取需求详情
+    # 接口:http://192.168.33.10/info/demand/?l=data.getInfo&top=1&json=1&id=10000000
+    public function getInfoPic()
+    {
+        $data = Dever::load('res/data.getInfo');
+
+        if ($data['pic']) {
+            return $data['pic'];
+        }
+        return false;
+    }
+
+    # 获取需求详情
+    # 接口:http://192.168.33.10/info/demand/?l=data.getInfo&top=1&json=1&id=10000000
+    public function getInfoAttr()
+    {
+        $data = Dever::load('res/data.getInfo');
+
+        if ($data['attr']) {
+            return $data['attr'];
+        }
+        return array();
+    }
+
+    # 获取更新需求时的字段
+    public function getUpdate()
+    {
+        $this->checkInfo();
+
+        if ($this->cate) {
+            $cate = $this->cate;
+            $category = $this->top . ',' . $cate;
+        } else {
+            $cate = $this->top;
+            $category = $this->top;
+        }
+        $cate = $this->cate ? $this->cate : $this->top;
+
+        $data = Dever::load('category/api')->getChild($cate);
+
+        if ($data) {
+            $data = $data[$cate];
+        }
+        $data = array('cate' => $data, 'category' => $category);
+
+        # 获取当前分类的属性
+        $attr = $this->info->getAttr($category);
+        $data['attr'] = '';
+        $data['attr_id'] = array();
+        if ($attr) {
+            foreach ($attr as $k => $v) {
+                $data['attr_id'][] = $v['id'];
+            }
+            $data['attr_id'] = implode(',', $data['attr_id']);
+            $data['attr'] = Dever::render('render/submit_attr', array('attr' => $attr), 'main');
+        }
+
+        return Dever::render('render/submit', $data, 'main');
+    }
+
+    # 获取分类下的属性
+    public function getAttr()
+    {
+        $category = Dever::input('category');
+        $attr_id = Dever::input('attr_id');
+
+        $attr = $this->info->getAttr($category);
+
+        if ($attr) {
+            $attr_id = explode(',', $attr_id);
+            foreach ($attr as $k => $v) {
+                if (in_array($v['id'], $attr_id)) {
+                    unset($attr[$k]);
+                }
+            }
+            if ($attr) {
+                return Dever::render('render/submit_attr', array('attr' => $attr), 'main');
+            }
+        }
+
+        echo '';die;
+    }
+
+    # 更新或者新增需求
+    # 接口:http://192.168.33.10/info/demand/?l=data.update&top=1&json=1&id=10000000&name=test&cate=1,3,9&attr_2=1
+    public function update()
+    {
+        $this->checkInfo();
+
+        if ($this->cate) {
+            $cate = $this->top . ',' . $this->cate;
+        } else {
+            $cate = $this->top;
+        }
+        $data['name'] = Dever::input('name');
+        if (!$data['name']) {
+            Dever::alert('请输入标题');
+        }
+        $data['pic'] = Dever::input('pic');
+        $data['view_price'] = Dever::input('view_price');
+        $this->info->setViewPath($this->view_path);
+        $data = $this->info->update($this->top, $this->cate, $data, $this->id, $this->data['uid']);
+
+        # 提交信息之后,验证是否需要支付
+        $url = $data['info']['view_link'];
+        return $url;
+    }
+
+    private function checkInfo()
+    {
+        if (!$this->info) {
+            Dever::alert('错误的参数,请重试');
+        }
+    }
+}

+ 29 - 0
app/res/src/Order.php

@@ -0,0 +1,29 @@
+<?php
+
+# 订单类
+
+namespace Res\Lib;
+
+use Dever;
+use Main\Lib\Core;
+
+class Order extends Core
+{
+	protected $checkUser = true;
+
+	# 获取我的订单
+	public function my()
+	{
+		$where['uid'] = $this->data['uid'];
+		$data = Dever::db('res/order')->state($where);
+
+		if ($data) {
+			$info = Info::init(-1);
+			foreach ($data as $k => $v) {
+				$data[$k]['info'] = $info->getInfo($v['product_id'], true, 'list_reorder');
+			}
+		}
+
+		return $data;
+	}
+}

+ 119 - 0
app/res/src/Pay.php

@@ -0,0 +1,119 @@
+<?php
+
+# 支付类
+
+namespace Res\Lib;
+
+use Dever;
+
+class Pay extends Data
+{
+	# 发需求需要支付
+    public function post_info()
+    {
+    	$this->action(1);
+    }
+
+    # 查看需求也需要支付
+    public function view_info()
+    {
+        $this->action(2);
+    }
+
+    private function action($type = 1)
+    {
+    	$this->checkDemand();
+        if (!$this->data['uid']) {
+            Dever::alert('错误的用户信息');
+        }
+
+        $product = $this->demand->getInfo($id, false);
+
+        $user = Dever::db('passport/user')->one($this->data['uid']);
+        $wechat = Dever::db('passport/wechat')->one(array('uid' => $this->data['uid'], 'type' => 1, 'system_id' => 1));
+
+        if ($this->source_type == 'ios') {
+            $method = 'apple';
+            $account_id = 3;
+            # 使用苹果内购支付
+            $receipt = Dever::input('receipt');
+            if (!$receipt) {
+                Dever::alert('苹果内购支付失败,没有receipt参数');
+            }
+        } elseif ($this->source_type == 'android') {
+            $method = 'app';
+            $account_id = 3;
+        } elseif ($this->source_type == 'applet') {
+            $method = 'applet';
+            $account_id = 1;
+        } else {
+        	# 默认是网页支付
+        	$method = 'page';
+        	$account_id = 2;
+        }
+
+        //$order_id = $this->createOrder('JP');
+        $order_data['category'] = $product['category'];
+        //$order_data['order_id'] = $order_id;
+        $order_data['product_id'] = $product['id'];
+        $order_data['uid'] = $this->data['uid']; 
+        $order_data['type'] = $type;
+
+        # 验证是否已经支付过
+        $one = Dever::db('demand/order')->one($order_data);
+
+        if (!$one) {
+            Dever::alert('您已经支付过了');
+        }
+
+        $order_data['status'] = 1;
+
+        $order_data['name'] = $product['name'];
+
+        if ($type == 1) {
+        	$cash = $this->demand->getPayState($this->data['uid'], $product['id'], $product['category']);
+
+        	$order_data['cash'] = $cash;
+        } else {
+        	$cash = $product['view_price'];
+        }
+
+        $id = Dever::db('demand/order')->insert($order_data);
+
+        if (!$id) {
+            Dever::alert('支付失败');
+        }
+
+        $order_id = $this->createOrderId($order_data, $id);
+
+        //$param参数
+        $param = array
+        (
+            'account_id' => $account_id,
+            'project_id' => 1,
+            'uid' => $this->data['uid'],
+            'username' => $user['username'],
+            'name' => $order_data['name'],
+            'cash' => $order_data['cash'],
+            'cash' => '0.01',
+            'openid' => $wechat['openid'],
+            'product_id' => $product['id'],
+            'order_id' => $order_id,
+        );
+
+        if ($method == 'apple') {
+            $param['other'] = $receipt;
+        }
+
+        $this->data['pay'] = Dever::load('pay/api.' . $method, $param);
+
+        $this->data['order_id'] = $order_id;
+
+        return $this->data;
+    }
+
+    private function createOrderId($data, $id)
+    {
+        
+    }
+}

+ 8 - 0
app/shop/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'shop');
+define('DEVER_APP_LANG', '店铺管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 98);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
+include(DEVER_APP_PATH . '../boot.php');

+ 8 - 0
app/task/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'shop');
+define('DEVER_APP_LANG', '店铺管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 98);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
+include(DEVER_APP_PATH . '../boot.php');

+ 8 - 0
boot.php

@@ -0,0 +1,8 @@
+<?php 
+define('DEVER_PROJECT', 'audio');
+define('DEVER_PROJECT_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+if (defined('DEVER_PACKAGE')) {
+	include('dever_package/'.DEVER_PACKAGE.'/index.php');
+} else {
+	include('dever/boot.php');
+}

+ 0 - 0
common.php


+ 84 - 0
config/base.php

@@ -0,0 +1,84 @@
+<?php
+$config['base'] = array
+(
+	'name' => '音频转换',
+	'version' => '1.0.0 Beta',
+
+    # 设置分类组件中的栏目下的分类为系统使用的主分类
+    'category' => 1,
+
+    # 设置类型
+    'type' => array
+    (
+        1 => '需求',
+    ),
+
+    # 功能类型
+    'type_table' => array
+    (
+        1 => 'demand/info',
+    ),
+
+    # 审核配置
+    'audit' => array
+    (
+        1 => '未审核',
+        2 => '已审核',
+        3 => '审核未通过',
+    ),
+
+    # 需求状态
+    'status' => array
+    (
+        1 => '新发布',
+        2 => '已结束',
+        3 => '已成交',
+        4 => '已取消',
+    ),
+
+    # 小程序配置
+    'applet' => array
+    (
+        'project' => 'passport/system',
+        'url' => 'https://api.weixin.qq.com/sns/jscode2session',
+    ),
+
+    # 站点使用邮箱还是手机作为主账号
+    'account' => 'mobile',
+);
+
+
+# 前台通用配置
+$config['template'] = array
+(
+    # 静态页面目录
+    'assets' => array('pc', 'mobile'),
+
+    # 模板编译器目录
+    'template' => 'pc',
+
+    # 模板html文件的所在目录,默认为html
+    'path' => '',
+
+    'replace' => array
+    (
+        'css' => 'css/',
+        'js' => 'js/',
+        'images' => 'images/',
+        'script' => 'script/',
+        'static' => './static/',
+    ),
+
+    # 编译器与模板对应关系目录,定义之后,代表可以完全不改动前端的代码,可以为空,为空则一一对应,参考manage
+    'relation' => array
+    (
+        # 首页启动屏幕
+        'home' => 'index',
+        'list_text' => 'list1',
+        'page' => 'intro',
+        'view' => 'article',
+        'magazine' => 'magzine',
+    ),
+    
+);
+return $config;

+ 119 - 0
config/env/localhost/default.php

@@ -0,0 +1,119 @@
+<?php
+
+# 验证dc是否存在,一般在share目录下
+$dc = array();
+$dc_file = '/share/dc/config.php';
+if (is_file($dc_file)) {
+    $dc = include($dc_file);
+}
+
+if (isset($dc['data'])) {
+    $config['base']['data'] = $dc['data'];
+}
+
+$create = -1;
+if (isset($dc['mysql']['create'])) {
+    $create = -1;
+}
+$ip = isset($dc['host']) ? $dc['host'] : '192.168.33.10';
+
+$local = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $ip;
+
+# 数据库配置
+$config['database'] = array
+(
+    'create' => $create,
+	# 默认数据库配置
+	'default' => array
+	(
+		'type' => 'pdo',
+		'host' => array
+		(
+			'read' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
+			'update' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
+            'create' => isset($dc['mysql']) ? $dc['mysql']['host_create'] : 'web-mysql:3306',
+		),
+		'database' => 'audio',
+		'username' => isset($dc['mysql']) ? $dc['mysql']['username'] : 'root',
+		'password' => isset($dc['mysql']) ? $dc['mysql']['password'] : '123456',
+		'charset' => 'utf8mb4',
+	),
+);
+
+# 缓存配置
+$config['cache'] = array
+(
+    # 启用mysql数据库缓存,这个缓存是根据表名自动生成,dever::load形式和service的all、one形式均自动支持,无需手动添加
+    'mysql' => 0,
+    # 启用页面缓存 会根据当前的url来生成缓存,相当于页面静态化。
+    'html' => 0,
+    # 启用数据级别缓存 这个缓存是程序员自定义的:Dever::cache('name', 'value', 3600);
+    'data' => 0,
+    # 启用load加载器缓存,一般不加载
+    'load' => 0,
+    # 启用load加载器的远程加载缓存
+    'curl' => 0,
+    # 启用路由缓存
+    'route' => 0,
+
+    # 缓存精细控制,根据uri来控制,0则无需缓存
+    'routeKey' => array
+    (
+        
+    ),
+
+    # 哪些路由中的参数不参与生成缓存的key
+    'routeNoParam' => array
+    (
+        'uid' => array
+        (
+            
+        ),
+    ),
+    
+    # 缓存清理的参数名,请通过shell=clearcache执行
+    'shell' => 'clearcache',
+
+    # 是否启用key失效时间记录,启用之后,将会记录每个key的失效时间
+    'expire' => true,
+
+    # 缓存类型
+    'type' => 'redis',//memcache、redis
+
+    # 缓存保存方式,支持多个数据源、多台缓存服务器
+    'store' => array
+    (
+        array
+        (
+            'host' => 'server-redis',
+            'port' => '6379',
+            'weight' => 100,
+            'password' => 'dm_redis_123',
+        ),
+    ),
+);
+
+$config['debug'] = array
+(
+	'log' => false
+);
+
+/*
+if (DEVER_APP_NAME == 'source') {
+    $config['debug']['log'] = array('type' => 'file'); 
+}
+*/
+
+
+$host = 'http://'.$local . '/';
+
+$upload = $host . 'audio/package/';
+$uploadcdn = $host . 'audio/data/';
+
+$config['host'] = array
+(
+    'upload'=> $upload . 'upload/?save',
+    'uploadRes'     => isset($dc['res']) && $dc['res'] ? $dc['res'] : $uploadcdn . 'upload/',
+);
+
+return $config;

+ 6 - 0
config/route.php

@@ -0,0 +1,6 @@
+<?php
+return array
+(
+	'home' => 'home',
+	'c=v(.*?)_(.*?)' => 'view.get?type=$1&id=$2',
+);