dever 5 years ago
commit
ea74f12921

+ 204 - 0
applet/database/auditing.php

@@ -0,0 +1,204 @@
+<?php
+/**
+ * tester
+ */
+
+$status = array
+(
+	1 => '审核中',
+	2 => '审核成功',
+	3 => '审核失败',
+);
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/version-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'auditing',
+	# 显示给用户看的名称
+	'lang' => '审核历史',
+	'desc' => '这里会实时请求微信审核接口,访问速度会慢一些。后续放到cron里。',
+	'order' => 2,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'version_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '版本',
+			'default' 	=> '',
+			'desc' 		=> '版本',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'checkbox',
+			'option'	=> $version,
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '版本号',
+			'default' 	=> '',
+			'desc' 		=> '版本号',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("wechat_component_applet/version-one#name", {version_id})',
+		),
+
+		'user_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'select',
+			'option'	=> $user,
+			'list'		=> true,
+		),
+
+		'auditid'		=> array
+		(
+			'type' 		=> 'varchar-40',
+			'name' 		=> '审核id',
+			'default' 	=> '',
+			'desc' 		=> '审核id',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'result'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '微信返回信息',
+			'default' 	=> '',
+			'desc' 		=> '微信返回信息',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '审核状态',
+			'default' 	=> '1',
+			'desc' 		=> '审核状态',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $status,
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'statusDesc'		=> array
+		(
+			'type' 		=> 'varchar-140',
+			'name' 		=> '审核说明',
+			'default' 	=> '',
+			'desc' 		=> '审核说明',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> 'Dever::load("wechat_component_applet/auditing.view", {id})',
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'mdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '审核时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			'default' 	=> '',
+			'order'		=> 'desc',
+			'list'		=> 'date("Y-m-d H:i:s", {mdate})',
+		),
+		
+		'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' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 108 - 0
applet/database/domain.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ * domain
+ */
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'domain',
+	# 显示给用户看的名称
+	'lang' => '设置服务域名',
+	'order' => 99,
+	'end' => array
+	(
+		'insert' => array
+		(
+			'wechat_component_applet/domain.update',
+		),
+		'update' => array
+		(
+			'wechat_component_applet/domain.update',
+		),
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'user'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '用户-不选择则获取所有用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'option',
+			//'search'	=> 'order,fulltext',
+			//'update'	=> 'checkbox',
+			'option'	=> $user,
+			//'list'		=> true,
+		),
+		
+		'value'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '域名',
+			'default' 	=> '',
+			'desc' 		=> '域名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> 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,
+		),
+	),
+
+	'top' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 164 - 0
applet/database/page.php

@@ -0,0 +1,164 @@
+<?php
+/**
+ * tester
+ */
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'page',
+	# 显示给用户看的名称
+	'lang' => '页面列表',
+	'order' => 93,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '页面名',
+			'default' 	=> '',
+			'desc' 		=> '页面名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'template_id'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '小程序模板',
+			'default' 	=> '',
+			'desc' 		=> '小程序模板',
+			'match' 	=> 'is_string',
+			'update'	=> 'checkbox',
+			'search'	=> 'select',
+			'option'	=> $template,
+			'list'		=> true,
+		),
+
+		'pagepath'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '页面路径',
+			'default' 	=> '',
+			'desc' 		=> '页面路径',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'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,
+		),
+	),
+
+	# 更新表结构
+	'alter' => array
+	(
+		2 => array
+		(
+			array('update', 'template_id', 'template_id', 'varchar-500 1 小程序模板'),
+			//array('add', 'config', 'config', 'int-11 1 配置'),
+		),
+		'version' => 2,
+	),
+
+	'top' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'template_id' => array('yes', 'like'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+			'col' => '*',
+		),
+
+		'getOne' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'template_id' => array('yes', 'like'),
+				'state' => 1,
+			),
+			'type' => 'one',
+			'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+		),
+	)
+);

+ 168 - 0
applet/database/publish.php

@@ -0,0 +1,168 @@
+<?php
+/**
+ * tester
+ */
+
+$status = array
+(
+	1 => '发布中',
+	2 => '发布成功',
+	3 => '发布失败',
+);
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/version-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'publish',
+	# 显示给用户看的名称
+	'lang' => '发布历史',
+	'order' => 1,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'version_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '版本',
+			'default' 	=> '',
+			'desc' 		=> '版本',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'checkbox',
+			'option'	=> $version,
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '版本号',
+			'default' 	=> '',
+			'desc' 		=> '版本号',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("wechat_component_applet/version-one#name", {version_id})',
+		),
+
+		'user_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'select',
+			'option'	=> $user,
+			'list'		=> true,
+		),
+
+		'result'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '微信返回信息',
+			'default' 	=> '',
+			'desc' 		=> '微信返回信息',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '发布状态',
+			'default' 	=> '1',
+			'desc' 		=> '发布状态',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $status,
+			'list'		=> 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' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 168 - 0
applet/database/revert.php

@@ -0,0 +1,168 @@
+<?php
+/**
+ * tester
+ */
+
+$status = array
+(
+	1 => '回退中',
+	2 => '回退成功',
+	3 => '回退失败',
+);
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/version-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'revert',
+	# 显示给用户看的名称
+	'lang' => '版本回退历史',
+	'order' => 1,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'version_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '版本',
+			'default' 	=> '',
+			'desc' 		=> '版本',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'checkbox',
+			'option'	=> $version,
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '版本号',
+			'default' 	=> '',
+			'desc' 		=> '版本号',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("wechat_component_applet/version-one#name", {version_id})',
+		),
+
+		'user_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'select',
+			'option'	=> $user,
+			'list'		=> true,
+		),
+
+		'result'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '微信返回信息',
+			'default' 	=> '',
+			'desc' 		=> '微信返回信息',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '回退状态',
+			'default' 	=> '1',
+			'desc' 		=> '回退状态',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $status,
+			'list'		=> 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' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 177 - 0
applet/database/tabbar.php

@@ -0,0 +1,177 @@
+<?php
+/**
+ * tester
+ */
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$page = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/page-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'tabbar',
+	# 显示给用户看的名称
+	'lang' => '底部菜单',
+	'order' => 93,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '菜单名',
+			'default' 	=> '',
+			'desc' 		=> '菜单名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'template_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '小程序模板',
+			'default' 	=> '1',
+			'desc' 		=> '小程序模板',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'search'	=> 'select',
+			'option'	=> $template,
+			'list'		=> true,
+			'edit'		=> true,
+			'control'	=> 'template_id',
+		),
+
+		/*
+		'pagepath'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '菜单路径',
+			'default' 	=> '',
+			'desc' 		=> '菜单路径',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+		*/
+
+		'page_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '菜单页面',
+			'default' 	=> '1',
+			'desc' 		=> '菜单页面',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'search'	=> 'select',
+			'option'	=> $page,
+			'list'		=> true,
+			'edit'		=> true,
+			'show'	=> 'template_id=wechat_component/Core.getPageByTemplate?template=',
+		),
+
+		'iconpath'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '图标路径',
+			'default' 	=> '',
+			'desc' 		=> '图标路径',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'selectediconpath'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '选中图标路径',
+			'default' 	=> '',
+			'desc' 		=> '选中图标路径',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'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,
+		),
+	),
+
+	'top' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 96 - 0
applet/database/template.php

@@ -0,0 +1,96 @@
+<?php
+/**
+ * 小程序模板
+ */
+
+return array
+(
+	# 表名
+	'name' => 'template',
+	# 显示给用户看的名称
+	'lang' => '小程序模板',
+	'order' => 98,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '模板名',
+			'default' 	=> '',
+			'desc' 		=> '模板名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'template'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '模板id-暂时手动填写,小程序模板id+1就是这个模板id',
+			'default' 	=> '',
+			'desc' 		=> '模板id',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'desc'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '描述',
+			'default' 	=> '',
+			'desc' 		=> '描述',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> 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,
+		),
+	),
+
+	'top' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 118 - 0
applet/database/tester.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * tester
+ */
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'tester',
+	# 显示给用户看的名称
+	'lang' => '设置体验者',
+	'order' => 98,
+	'end' => array
+	(
+		'insert' => array
+		(
+			'wechat_component_applet/tester.update',
+		),
+		'update' => array
+		(
+			'wechat_component_applet/tester.update',
+		),
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'user'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '用户-不选择则获取所有用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'option',
+			//'search'	=> 'order,fulltext',
+			//'update'	=> 'checkbox',
+			'option'	=> $user,
+			//'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '微信昵称',
+			'default' 	=> '',
+			'desc' 		=> '微信昵称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'value'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '微信号',
+			'default' 	=> '',
+			'desc' 		=> '域名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> 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,
+		),
+	),
+
+	'top' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 168 - 0
applet/database/unaudit.php

@@ -0,0 +1,168 @@
+<?php
+/**
+ * tester
+ */
+
+$status = array
+(
+	1 => '撤回中',
+	2 => '撤回成功',
+	3 => '撤回失败',
+);
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/version-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'unaudit',
+	# 显示给用户看的名称
+	'lang' => '审核撤回历史',
+	'order' => 1,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'version_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '版本',
+			'default' 	=> '',
+			'desc' 		=> '版本',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'checkbox',
+			'option'	=> $version,
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '版本号',
+			'default' 	=> '',
+			'desc' 		=> '版本号',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("wechat_component_applet/version-one#name", {version_id})',
+		),
+
+		'user_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'select',
+			'option'	=> $user,
+			'list'		=> true,
+		),
+
+		'result'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '微信返回信息',
+			'default' 	=> '',
+			'desc' 		=> '微信返回信息',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '撤回状态',
+			'default' 	=> '1',
+			'desc' 		=> '撤回状态',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $status,
+			'list'		=> 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' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 175 - 0
applet/database/version.php

@@ -0,0 +1,175 @@
+<?php
+/**
+ * tester
+ */
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'version',
+	# 显示给用户看的名称
+	'lang' => '版本管理',
+	'order' => 97,
+	'end' => array
+	(
+		'insert' => array
+		(
+			'wechat_component_applet/version.update',
+		),
+		'update' => array
+		(
+			'wechat_component_applet/version.update',
+		),
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'user'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '用户-不选择则获取所有用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'is_string',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'checkbox',
+			'option'	=> $user,
+			'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '版本号',
+			'default' 	=> '',
+			'desc' 		=> '版本号',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'template_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '小程序模板',
+			'default' 	=> '1',
+			'desc' 		=> '小程序模板',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $template,
+			'list'		=> true,
+		),
+
+		'desc'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '版本描述',
+			'default' 	=> '',
+			'desc' 		=> '版本描述',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			//'list'		=> true,
+		),
+
+		'act_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '活动id',
+			'default' 	=> '0',
+			'desc' 		=> '活动id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'mdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '提交时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			'default' 	=> '',
+			'list'		=> 'date("Y-m-d H:i:s", {mdate})',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'top' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		'delete' => false,
+		'list_button' => array
+		(
+			'list' => array('日志', '"version_log&search_option_version_id={id}&oper_parent=version"'),
+
+			'oper' => array('提审', '"wechat_component_applet/auditing.submit?id={id}"'),
+
+			'oper3' => array('撤回', '"wechat_component_applet/unaudit.submit?id={id}"'),
+
+			'oper1' => array('发布', '"wechat_component_applet/publish.submit?id={id}"'),
+
+			'oper2' => array('回退', '"wechat_component_applet/revert.submit?id={id}"'),
+		),
+	),
+);

+ 160 - 0
applet/database/version_log.php

@@ -0,0 +1,160 @@
+<?php
+/**
+ * tester
+ */
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('wechat_component_applet/version-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'version_log',
+	# 显示给用户看的名称
+	'lang' => '版本提交历史',
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'version_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '版本',
+			'default' 	=> '',
+			'desc' 		=> '版本',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'checkbox',
+			'option'	=> $version,
+			//'list'		=> true,
+		),
+
+		'user_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户',
+			'default' 	=> '',
+			'desc' 		=> '用户',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order,fulltext',
+			'update'	=> 'select',
+			'option'	=> $user,
+			'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '版本号',
+			'default' 	=> '',
+			'desc' 		=> '版本号',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'template_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '小程序模板',
+			'default' 	=> '1',
+			'desc' 		=> '小程序模板',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $template,
+			'list'		=> true,
+		),
+
+		'result'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '微信返回信息',
+			'default' 	=> '',
+			'desc' 		=> '微信返回信息',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> 'Dever::load("wechat_component/user.qrcode", {user_id}, {id})',
+			'modal'		=> '查看详情',
+		),
+		
+		'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' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 8 - 0
applet/index.php

@@ -0,0 +1,8 @@
+<?php
+define('DEVER_APP_NAME', 'wechat_component_applet');
+define('DEVER_APP_LIB', 'wechat_component/applet');
+define('DEVER_APP_LANG', '第三方平台-小程序管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 99);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-magnet layui-icon-unlink');
+include(DEVER_APP_PATH . '../../boot.php');

+ 141 - 0
applet/src/Auditing.php

@@ -0,0 +1,141 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Applet\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+use Wechat_component\Src\Core;
+
+class Auditing extends Core
+{
+	public $table = 'wechat_component_applet/auditing';
+
+	public function submit()
+	{
+		$id = Dever::input('id');
+		$info = Dever::db('wechat_component_applet/version')->one($id);
+		$user = explode(',', $info['user']);
+		foreach ($user as $k => $v) {
+			$param = array();
+			$param['user_id'] = $v;
+			$param['project_id'] = $info['project_id'];
+			$param['version_id'] = $info['id'];
+			$param['name'] = $info['name'];
+			$param['status'] = 1;
+			$param['statusDesc'] = '审核中';
+			$id = Dever::upinto('wechat_component_applet/auditing', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$this->set($v, $id);
+		}
+		Dever::alert('提交成功,请到审核历史中查看审核状态');
+		return;
+	}
+
+	/**
+     * 定期获取审核状态
+     * 
+     * @return mixed
+     */
+    public function cron()
+    {
+        $data = Dever::db('wechat_component_applet/auditing')->state();
+        if ($data) {
+        	$wechat = array();
+        	foreach ($data as $k => $v) {
+        		if ($v['status'] == 1 && $v['auditid']) {
+        			$user = Dever::db('component/user')->one($v['user_id']);
+					$oauth = Dever::db('token/oauth')->one($user['oauth_id']);
+					if (!isset($wechat[$v['project_id']])) {
+						$wechat[$v['project_id']] = new Wechat($v['project_id'], 'component');
+					}
+					
+					$oauth = $wechat[$v['project_id']]->oauth($oauth['id']);
+					$oauth['oauth'] = $oauth['value'];
+					$oauth['auditid'] = $v['auditid'];
+					$result = $wechat[$v['project_id']]->curl('applet_auditstatus', $oauth, false);
+					
+					$update = array();
+					if (isset($result['status'])) {
+						if ($result['status'] == 2) {
+							$html['审核状态'] = '审核中';
+							$update['status'] = 1;
+						} elseif($result['status'] == 1) {
+							$html['审核状态'] = '审核失败';
+							$update['status'] = 3;
+						} else {
+							$html['审核状态'] = '审核成功';
+							$update['status'] = 2;
+						}
+					}
+					if (isset($result['reason'])) {
+						$html['说明'] = $result['reason'];
+						$update['statusDesc'] = $result['reason'];
+					}
+
+					if ($update) {
+						$update['where_id'] = $v['id'];
+						Dever::db('wechat_component_applet/auditing')->update($update);
+					}
+        		}
+        	}
+        }
+    }
+
+	# 查看审核状态
+	public function view($id)
+	{
+		$info = Dever::db('wechat_component_applet/auditing')->one($id);
+		$status = $info['status'];
+		$html = array();
+		if ($status == 2) {
+			$html['审核状态'] = '审核成功';
+		} elseif ($status == 3) {
+			$html['审核状态'] = '审核失败';
+			$html['说明'] = $info['statusDesc'];
+		} elseif ($status == 1) {
+			$html['审核状态'] = '审核中';
+		}
+
+		$html = Dever::table($html);
+		return $html;
+	}
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$oauth['method'] = 'applet_submit';
+		$project = Dever::db('token/project')->one($info['project_id']);
+		$user = Dever::db('component/user')->one($user);
+
+		# 获取类目
+		$result = $wechat->curl('applet_category', $oauth, false);
+
+		$page = 'pages/index/index';
+
+		$version = Dever::db('component/version')->one($info['version_id']);
+
+		if ($version) {
+			$pageInfo = Dever::db('component/page')->getOne(array('option_template_id' => $version['template_id']));
+
+			if ($pageInfo) {
+				$page = $pageInfo['pagepath'];
+			}
+		}
+		
+		$item = array
+		(
+			'address' => $page,
+			'tag' => str_replace(',', ' ', $user['tag']),
+			'title' => $user['name'],
+		);
+
+		if (isset($result['category_list'][0]['first_class'])) {
+			$item += $result['category_list'][0];
+		}
+
+		$oauth['item_list'][] = $item;
+		return $oauth;
+	}
+}

+ 36 - 0
applet/src/Domain.php

@@ -0,0 +1,36 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| domain 服务域名设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Applet\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+use Wechat_component\Src\Core;
+
+class Domain extends Core
+{
+	public $table = 'wechat_component_applet/domain';
+
+	public function value($info)
+	{
+		$list = Dever::db('wechat_component_applet/domain')->state(array('option_project_id' => $info['project_id']));
+		$info['value'] = array();
+		foreach ($list as $k => $v) {
+			if (!in_array($v['value'], $info['value'])) {
+				$info['value'][] = $v['value'];
+			}
+		}
+		return $info['value'];
+	}
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$value = $this->value($info);
+		$oauth['domain'] = $value;
+		$oauth['method'] = 'applet_domain';
+		return $oauth;
+	}
+}

+ 41 - 0
applet/src/Publish.php

@@ -0,0 +1,41 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Applet\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+use Component\Src\Core;
+
+class Publish extends Core
+{
+	public $table = 'wechat_component_applet/publish';
+
+	public function submit()
+	{
+		$id = Dever::input('id');
+		$info = Dever::db('wechat_component_applet/version')->one($id);
+		$user = explode(',', $info['user']);
+		foreach ($user as $k => $v) {
+			$param = array();
+			$param['user_id'] = $v;
+			$param['project_id'] = $info['project_id'];
+			$param['version_id'] = $info['id'];
+			$param['name'] = $info['name'];
+			$param['status'] = 1;
+			$id = Dever::upinto('wechat_component_applet/publish', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$this->set($v, $id);
+		}
+		Dever::alert('提交成功,请到发布历史中查看发布状态');
+		return;
+	}
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$oauth['method'] = 'applet_publish';
+		return $oauth;
+	}
+}

+ 41 - 0
applet/src/Revert.php

@@ -0,0 +1,41 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Applet\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+use Wechat_component\Src\Core;
+
+class Revert extends Core
+{
+	public $table = 'wechat_component_applet/revert';
+
+	public function submit()
+	{
+		$id = Dever::input('id');
+		$info = Dever::db('wechat_component_applet/version')->one($id);
+		$user = explode(',', $info['user']);
+		foreach ($user as $k => $v) {
+			$param = array();
+			$param['user_id'] = $v;
+			$param['project_id'] = $info['project_id'];
+			$param['version_id'] = $info['id'];
+			$param['name'] = $info['name'];
+			$param['status'] = 1;
+			$id = Dever::upinto('wechat_component_applet/revert', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$this->set($v, $id);
+		}
+		Dever::alert('提交成功,请到版本回退历史中查看回退状态');
+		return;
+	}
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$oauth['method'] = 'applet_revert';
+		return $oauth;
+	}
+}

+ 27 - 0
applet/src/Tester.php

@@ -0,0 +1,27 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Applet\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+use Wechat_component\Src\Core;
+
+class Tester extends Core
+{
+	public $table = 'wechat_component_applet/tester';
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$oauth['wechatid'] = $info['value'];
+		if ($delete == true) {
+			$oauth['method'] = 'applet_untester';
+		} else {
+			$oauth['method'] = 'applet_tester';
+		}
+		return $oauth;
+	}
+}

+ 41 - 0
applet/src/Unaudit.php

@@ -0,0 +1,41 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Applet\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+use Wechat_component\Src\Core;
+
+class Unaudit extends Core
+{
+	public $table = 'wechat_component_applet/unaudit';
+
+	public function submit()
+	{
+		$id = Dever::input('id');
+		$info = Dever::db('wechat_component_applet/version')->one($id);
+		$user = explode(',', $info['user']);
+		foreach ($user as $k => $v) {
+			$param = array();
+			$param['user_id'] = $v;
+			$param['project_id'] = $info['project_id'];
+			$param['version_id'] = $info['id'];
+			$param['name'] = $info['name'];
+			$param['status'] = 1;
+			$id = Dever::upinto('wechat_component_applet/unaudit', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$this->set($v, $id);
+		}
+		Dever::alert('提交成功,请到审核撤回历史中查看撤回状态');
+		return;
+	}
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$oauth['method'] = 'applet_unaudit';
+		return $oauth;
+	}
+}

+ 136 - 0
applet/src/Version.php

@@ -0,0 +1,136 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Applet\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+use Component\Src\Core;
+
+class Version extends Core
+{
+	public $table = 'wechat_component_applet/version';
+
+
+	public function getPage($id)
+	{
+		$page = Dever::db('wechat_component/page')->getAll(array('template_id' => $id));
+
+		return $page;
+	}
+	
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$template = Dever::db('wechat_component_applet/template')->one($info['template_id']);
+		$oauth['method'] = 'applet_commit';
+		$oauth['template_id'] = $template['template'] - 1;
+		$oauth['user_version'] = $info['name'];
+		$oauth['user_desc'] = $info['desc'];
+
+		$project = Dever::db('token/project')->one($info['project_id']);
+		$user = Dever::db('wechat_component/user')->one($user);
+
+		$pageInfo = Dever::db('wechat_component/page')->getAll(array('option_template_id' => $template['id']));
+
+		//$pageInfo = Dever::db('wechat_component/page')->state();
+
+		$page = array();
+
+		if ($pageInfo) {
+			$i = 0;
+			foreach ($pageInfo as $k => $v) {
+				$page[$i] = $v['pagepath'];
+				$i++;
+			}
+		}
+
+		$tabbar = Dever::db('wechat_component_applet/tabbar')->state(array('option_template_id' => $template['id']));
+		$tab = array();
+		if ($tabbar) {
+			$i = 0;
+			foreach ($tabbar as $k => $v) {
+				$tab[$i]['pagePath'] = $pageInfo[$v['page_id']]['pagepath'];
+				if ($i == 0) {
+					/*
+					$key = array_search($tab[$i]['pagePath'], $page);
+					if ($key && isset($page[$key])) {
+						unset($page[$key]);
+					}
+					*/
+					array_unshift($page, $tab[$i]['pagePath']);
+				}
+				$tab[$i]['text'] = $v['name'];
+				$tab[$i]['iconPath'] = $v['iconpath'];
+				$tab[$i]['selectedIconPath'] = $v['selectediconpath'];
+
+				$i++;
+			}
+		}
+
+		/*
+		$page = array
+		(
+			"pages/shop/index",
+			"pages/shop-dl/index",
+			"pages/index/index",
+			"pages/thelecture/index",
+			"pages/toAttend/index",
+			"pages/index-dl/index",
+			"pages/toAttend-dl/index",
+			"pages/thelecture-dl/index",
+			"pages/service-2/index",
+			"pages/service-dl/index",
+			"pages/article/index",
+			"pages/cooperation-1/index",
+			"pages/cooperation-2/index",
+			"pages/service-1/index"
+		);
+		*/
+		if (!isset($info['act_id'])) {
+			$info['act_id'] = 0;
+		}
+		if (!$info['act_id']) {
+			$info['act_id'] = 0;
+		}
+		$ext = array
+		(
+			'extEnable' => true,
+			'extAppid' => $oauth['openid'],
+			'directCommit' => false,
+			'ext' => array
+			(
+				'version' => $info['name'],
+				'desc' => $user['desc'],
+				'project' => $project['id'],
+				'act' => $info['act_id'],
+			),
+			'extPages' => array(),
+			'pages' => $page,
+			'window' => array
+			(
+				'navigationBarTitleText' => $user['name'],
+			),
+			'tabBar' => array
+			(
+				'color' => '#666666',
+				'selectedColor' => '#ff8903',
+				'backgroundColor' => '#FAFAFA',
+				'list' => $tab,
+			),
+		);
+
+		if (!$tab) {
+			unset($ext['tabBar']);
+		}
+		if (!$page) {
+			unset($ext['pages']);
+		}
+		$oauth['ext_json'] = json_encode($ext, JSON_UNESCAPED_UNICODE);
+
+		//print_r($oauth);die;
+		return $oauth;
+	}
+}

+ 11 - 0
config/base.php

@@ -0,0 +1,11 @@
+<?php
+
+# 一些基本配置
+$config['base'] = array
+(
+	# 后台头部菜单
+	'top' => 'main/project_id-5',
+);
+
+
+return $config;

+ 244 - 0
config/component/applet.php

@@ -0,0 +1,244 @@
+<?php
+# applet基本接口配置
+
+$domain = '{domain}';
+
+# 登录
+$config['applet_login'] = array
+(
+	'name' => '登录',
+	'method' => 'get',
+	'json' => false,
+	'url' => 'https://api.weixin.qq.com/sns/component/jscode2session?',
+	'param' => array
+	(
+		'appid' => 'appid',
+		'js_code' => 'js_code',
+		'grant_type' => 'authorization_code',
+		'component_appid' => 'component_appid',
+		'component_access_token' => 'token',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+# 设置服务域名
+$config['applet_domain'] = array
+(
+	'name' => '设置服务域名',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/modify_domain?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'action' => 'set',
+		'requestdomain' => 'https://' . $domain,
+		'wsrequestdomain' => 'wss://' . $domain,
+		'uploaddomain' => 'https://' . $domain,
+		'downloaddomain' => 'https://' . $domain,
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+#设置小程序业务域名
+$config['applet_webviewdomain'] = array
+(
+	'name' => '设置小程序业务域名',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/setwebviewdomain?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'action' => 'set',
+		'webviewdomain' => 'https://' . $domain,
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+
+#设置体验者
+$config['applet_tester'] = array
+(
+	'name' => '设置体验者',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/bind_tester?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'wechatid' => 'wechatid',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+#删除体验者
+$config['applet_untester'] = array
+(
+	'name' => '删除体验者',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/unbind_tester?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'wechatid' => 'wechatid',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+#上传小程序代码
+$config['applet_commit'] = array
+(
+	'name' => '上传小程序代码',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/commit?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'template_id' => 'template_id',
+		'ext_json' => 'ext_json',
+		'user_version' => 'user_version',
+		'user_desc' => 'user_desc',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+
+#查看体验版二维码
+$config['applet_qrcode'] = array
+(
+	'name' => '查看体验版二维码',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/get_qrcode?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'path' => 'path',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+$config['applet_submit'] = array
+(
+	'name' => '将第三方提交的代码包提交审核',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/submit_audit?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'item_list' => 'item_list',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+$config['applet_category'] = array
+(
+	'name' => '获取授权小程序帐号的可选类目',
+	'method' => 'get',
+	'json' => false,
+	'url' => 'https://api.weixin.qq.com/wxa/get_category?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+$config['applet_auditstatus'] = array
+(
+	'name' => '查询某个指定版本的审核状态',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/get_auditstatus?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+		'auditid' => 'auditid',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+$config['applet_publish'] = array
+(
+	'name' => '发布已通过审核的小程序',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/wxa/release?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+$config['applet_revert'] = array
+(
+	'name' => '小程序版本回退',
+	'method' => 'get',
+	'json' => false,
+	'url' => 'https://api.weixin.qq.com/wxa/revertcoderelease?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+$config['applet_unaudit'] = array
+(
+	'name' => '小程序审核撤回',
+	'method' => 'get',
+	'json' => false,
+	'url' => 'https://api.weixin.qq.com/wxa/undocodeaudit?',
+	'param' => array
+	(
+		'access_token' => 'oauth',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
+
+return $config;

+ 129 - 0
config/wechat.php

@@ -0,0 +1,129 @@
+<?php
+# wechat基本配置
+$config['type'] = 5;
+
+# 基本的component token
+$config['token'] = array
+(
+	'name' => '获取第三方平台的token',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_component_token?',
+	'param' => array
+	(
+		'component_appid' => 'appid',
+		'component_appsecret' => 'secret',
+		'component_verify_ticket' => 'ticket',
+	),
+	//针对一些返回的名称,做转换
+	'response' => array
+	(
+		'component_access_token' => 'token',
+		//'expires_in' => 'expires_in',
+	),
+);
+
+# oauth token
+$config['oauth'] = array
+(
+	//第一步,请求code
+	'code' => array
+	(
+		'name' => '获取oauth code',
+		'method' => 'post',
+		'json' => true,
+		'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?',
+		'param' => array
+		(
+			'component_access_token' => 'token',
+			'component_appid' => 'appid',
+		),
+		'response' => array
+		(
+			'pre_auth_code' => 'oauth.code',
+		),
+	),
+	
+	//第二步,拼装redirect,进行授权登录
+	'login' => array
+	(
+		'name' => '获取oauth login',
+		'method' => 'get',
+		'json' => false,
+		'url' => 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?',
+		'param' => array
+		(
+			'component_appid' => 'appid',
+			'pre_auth_code' => 'code',
+			'redirect_uri' => 'redirect',
+			'auth_type' => '3',
+		),
+	),
+
+	//第三步,获取到token
+	'oauth' => array
+	(
+		'name' => '获取oauth token',
+		'method' => 'post',
+		'json' => true,
+		'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?',
+		'param' => array
+		(
+			'component_access_token' => 'token',
+			'component_appid' => 'appid',
+			'authorization_code' => 'auth_code',
+		),
+		'response' => array
+		(
+			'authorization_info.authorizer_appid' => 'openid',
+			'authorization_info.authorizer_appid.key' => 'unionid',
+			'authorization_info.authorizer_access_token' => 'oauth.oauth',
+			'authorization_info.authorizer_refresh_token' => 'refresh',
+			'authorization_info.expires_in' => 'expires_in',
+			'authorization_info.func_info' => 'callback.component/auth.saveOauthInfo',//定义回调
+		),
+	),
+
+	//第四步,根据refresh获取到token
+	'refresh' => array
+	(
+		'name' => '根据refresh获取oauth token',
+		'method' => 'post',
+		'json' => true,
+		'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?',
+		'param' => array
+		(
+			'component_access_token' => 'token',
+			'component_appid' => 'appid',
+			'authorizer_appid' => 'openid',
+			'authorizer_refresh_token' => 'refresh',
+		),
+		'response' => array
+		(
+			'authorizer_access_token' => 'oauth.refresh',
+			'authorizer_refresh_token' => 'refresh',
+		),
+	),
+);
+
+# 获取用户信息
+$config['user'] = array
+(
+	'name' => '获取用户信息',
+	'method' => 'post',
+	'json' => true,
+	'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?',
+	'param' => array
+	(
+		'component_access_token' => 'token',
+		'component_appid' => 'appid',
+		'authorizer_appid' => 'openid',
+	),
+);
+
+$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'component' . DIRECTORY_SEPARATOR;
+
+# 载入小程序接口配置
+$config += include($path . 'applet.php');
+
+return $config;

+ 191 - 0
database/user.php

@@ -0,0 +1,191 @@
+<?php
+/**
+ * user
+ */
+$type = array
+(
+	1 => '小程序',
+	2 => '订阅号',
+	3 => '服务号',
+);
+
+return array
+(
+	# 表名
+	'name' => 'user',
+	# 显示给用户看的名称
+	'lang' => '用户管理',
+	'order' => 100,
+	'desc' => '请将wechat_component/auth.cron放到cron中,定时获取access token',
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '项目',
+			'default' 	=> '',
+			'desc' 		=> '请输入项目',
+			'match' 	=> 'is_numeric',
+		),
+
+		'oauth_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'oauth',
+			'default' 	=> '',
+			'desc' 		=> 'oauth',
+			'match' 	=> 'is_numeric',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-120',
+			'name' 		=> '昵称',
+			'default' 	=> '',
+			'desc' 		=> '昵称',
+			'match' 	=> 'is_string',
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'principal_name'		=> array
+		(
+			'type' 		=> 'varchar-120',
+			'name' 		=> '主体信息',
+			'default' 	=> '',
+			'desc' 		=> '主体信息',
+			'match' 	=> 'is_string',
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'pic'		=> array
+		(
+			'type' 		=> 'varchar-250',
+			'name' 		=> '头像',
+			'default' 	=> '',
+			'desc' 		=> '头像',
+			'match' 	=> 'is_string',
+			//'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			'list_name'	=> 'logo及二维码列表',
+			//'list'		=> '"<img src=\"{pic}\" width=\"100\"> <img src=\"{qrcode}\" width=\"100\">"',
+
+			'list'		=> 'Dever::load("component/user.logo", {id})',
+			'modal'		=> '点此查看',
+		),
+
+		'username'		=> array
+		(
+			'type' 		=> 'varchar-120',
+			'name' 		=> '用户名',
+			'default' 	=> '',
+			'desc' 		=> '用户名',
+			'match' 	=> 'is_string',
+			//'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'qrcode'		=> array
+		(
+			'type' 		=> 'varchar-250',
+			'name' 		=> '二维码',
+			'default' 	=> '',
+			'desc' 		=> '二维码',
+			'match' 	=> 'is_string',
+			//'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-11',
+			'name' 		=> '类型',
+			'default' 	=> '1',
+			'desc' 		=> '类型',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $type,
+			//'list'		=> true,
+		),
+
+		'desc'		=> array
+		(
+			'type' 		=> 'varchar-120',
+			'name' 		=> '小程序id',
+			'default' 	=> '',
+			'desc' 		=> '小程序id',
+			'match' 	=> 'is_string',
+			'search'	=> 'fulltext',
+			'update'	=> 'text',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'tag'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '标签',
+			'default' 	=> '',
+			'desc' 		=> '标签',
+			'match' 	=> 'is_string',
+			'search'	=> 'fulltext',
+			'update'	=> 'text',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+		
+		'mdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '更新时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			'list'		=> 'date("Y-m-d H:i:s", {mdate})',
+		),
+		
+		'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,
+		),
+	),
+
+	'top' => Dever::config('base', 'component')->top,
+
+	'manage' => array
+	(
+		//'delete' => false,
+		'insert' => false,
+		'edit' => false,
+	),
+);

+ 7 - 0
index.php

@@ -0,0 +1,7 @@
+<?php
+define('DEVER_APP_NAME', 'wechat_component');
+define('DEVER_APP_LANG', '第三方平台');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 100);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-magnet layui-icon-component');
+include(DEVER_APP_PATH . '../boot.php');

+ 260 - 0
src/Auth.php

@@ -0,0 +1,260 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| auth.php 用于做权限验证
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+
+class Auth
+{
+	/**
+	 * wechat
+	 *
+	 * @var Wechat
+	 */
+	private $wechat;
+	
+	/**
+	 * result
+	 *
+	 * @var array
+	 */
+	private $result;
+	
+	/**
+	 * output
+	 *
+	 * @var string
+	 */
+	private $output;
+	
+	/**
+     * 构造函数 初始化
+     * 
+     * @return mixed
+     */
+	public function __construct()
+	{
+		$this->wechat = new Wechat();
+	}
+
+	/**
+     * 小程序登录login
+     * 
+     * @return mixed
+     */
+	public function applet_login_api()
+	{
+		$project = $this->wechat->project();
+		$param['js_code'] = Dever::input('code');
+		$param['appid'] = Dever::input('appid');
+		$param['component_access_token'] = $this->wechat->token();
+		$param['component_appid'] = $project['appid'];
+		$param['grant_type'] = 'authorization_code';
+
+		$data = $this->wechat->curl('applet_login', $param, false);
+		//$url = 'https://api.weixin.qq.com/sns/wechat_component/jscode2session?' . http_build_query($param);
+		//$data = Dever::curl($url);
+
+		echo $data;die;
+	}
+
+	/**
+     * 获取component token 一般为系统token
+     * 
+     * @return mixed
+     */
+	public function token_api()
+	{
+		return $this->wechat->token(false, false, 2000, true);
+	}
+
+	/**
+     * 获取预授权码 开始用户授权
+     * 
+     * @return mixed
+     */
+	public function test_api()
+	{
+		$link = $this->wechat->login('wechat_component/auth.oauth', false, false);
+		echo '<a href="'.$link.'">第三方平台授权</a>';die;
+	}
+
+	/**
+     * 获取预授权码 开始用户授权
+     * 
+     * @return mixed
+     */
+	public function get_api()
+	{
+		$this->wechat->login('wechat_component/auth.oauth');
+	}
+
+	/**
+     * 定期获取oauth的token 用户token
+     * 
+     * @return mixed
+     */
+    public function cron()
+    {
+        $user = Dever::db('wechat_component/user')->state();
+        if ($user) {
+        	foreach ($user as $k => $v) {
+        		$this->wechat->oauth($v['oauth_id'], 2000, true);
+        	}
+        }
+    }
+
+	/**
+     * 获取oauth的token 用户token
+     * 
+     * @return mixed
+     */
+	public function oauth_api()
+	{
+		$param['auth_code'] = Dever::input('auth_code');
+		$param['expires_in'] = Dever::input('expires_in');
+		if ($param['auth_code']) {
+			$data = $this->wechat->oauth($param);
+		} else {
+			$param = Dever::input('id', 1);
+			$data = $this->wechat->oauth($param, 2000, true);
+		}
+		if ($data && isset($data['openid'])) {
+			$result = $this->wechat->curl('user', $data);
+			if ($result) {
+				# 初始化操作
+				$param = array();
+				$qrcode = Dever::load('upload/save.copy', $result['authorizer_info']['qrcode_url']);
+				$param['project_id'] = $data['project_id'];
+				$param['oauth_id'] = $data['id'];
+				$param['name'] = $result['authorizer_info']['nick_name'];
+				$param['principal_name'] = $result['authorizer_info']['principal_name'];
+				$param['pic'] = $result['authorizer_info']['head_img'];
+				$param['qrcode'] = $qrcode['url'];
+				$param['username'] = $result['authorizer_info']['user_name'];
+				//$param['desc'] = '1';
+				$param['mdate'] = time();
+				
+				if (isset($result['authorizer_info']['MiniProgramInfo'])) {
+					$param['type'] = 1;
+				} else {
+					if ($result['authorizer_info']['service_type_info'] == 2) {
+						$param['type'] = 3;
+					} else {
+						$param['type'] = 2;
+					}
+				}
+				$id = Dever::upinto('wechat_component/user', array('option_oauth_id' => $data['id']), $param);
+				
+				$domain = Dever::db('wechat_component/domain')->one(array('option_project_id' => $param['project_id']));
+				//自动设置域名
+				if ($domain) {
+					$param['id'] = $id;
+					Dever::load('wechat_component/domain.set', $param, $domain['id']);
+				}
+				
+				$tester = Dever::db('wechat_component/tester')->state(array('option_project_id' => $param['project_id']));
+
+				if ($tester) {
+					$param['id'] = $id;
+					foreach ($tester as $k => $v) {
+						//自动设置体验者
+						Dever::load('wechat_component/tester.set', $param, $v['id']);
+					}
+				}
+			}
+		}
+
+		return '绑定成功';
+	}
+
+	/**
+     * wechat回调,直接将数据回写到该方法中
+     * 
+     * @return mixed
+     */
+	public function saveOauthInfo($oauth_id, $data, $project_id)
+	{
+		echo 1;
+		# 这里用于记录权限集func_info,先不记录了
+		return;
+	}
+	
+	/**
+     * 业务推送接口 微信服务器会将所有请求都推送到这里
+     * 
+     * @return mixed
+     */
+	public function main()
+	{
+		$this->output = '';
+		
+		# 获取微信消息
+		$this->request();
+		
+		# 对消息进行验证,并根据类型得到本平台的配置数据
+		//$this->response();
+		
+		# 输出
+		$this->output();
+	}
+	
+	/**
+     * 输出
+     * 
+     * @return mixed
+     */
+	private function output()
+	{
+		if (!$this->output) {
+			$this->output = 'success';
+		}
+		echo $this->output;die;
+	}
+
+    /**
+     * 获取微信发送的内容
+     * 
+     * @return mixed
+     */
+    private function request()
+    {
+		$data = $_GET ? $_GET : $_POST;
+		/*
+		$data = array();
+		$data['signature'] = '9474754223130bc1c820537b8113b590ef3cbf8e';
+		$data['timestamp'] = '1525915492';
+		$data['nonce']	= '1211005377';
+		$data['encrypt_type'] = 'aes';
+		$data['msg_signature'] = 'f17b5c2d2cf1592e07803f190048289ff468ef2b';
+		*/
+
+		$xml = file_get_contents('php://input');
+
+		Dever::log(json_encode($data) . $xml);
+
+		/*
+		$xml = "<xml>
+    <AppId><![CDATA[wxc50846069a0ae2d2]]></AppId>
+    <Encrypt><![CDATA[w19P5s2RRaWRUt+0Af0qSyBbTay3JdxDuYQxexTgm0PGE0U2UYknJKuH05GdaZPlruuTcbETR1MOfUGLmIniNlJ7UJ9GKgQWAnzVU0gezeolmnwA683fcGZpuH9yhSZHiSHoSbJaLpLZAl3ywu3FCMcpq6vhVVN/d/cQOUEgmS+rj06DOU105tBuKweOcD9LEGyoFPDUWRfvG4uGT4vS7C3hiR7UQgKYCGhSxBF56umkYHiGwpo3TNQ0QTFzIN/o6V43KvyFyIOfbvmQn9a3T9heDbijiJgcG+jpj/b9Vsps7jV5yePaJTnBjUWVbM7aW/HHlXWuYu+vagwG+shaMSGQHxCzdgjxiVYu2uR+M4kHYl90EUSdEJrcyQrFtia9BOwtkLkBwziZgogaVFXgLvSlN+krS3L0jHPVedevEgNubAM292jd/BPsU8Pd3o+EBZBG7qOU4IgHE6eVc09AxA==]]></Encrypt>
+</xml>";
+		*/
+
+		if (!empty($xml)) {
+			libxml_disable_entity_loader(true);
+          	$result = (array) simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
+			$result = $this->wechat->decode($data['msg_signature'], $data['timestamp'], $data['nonce'], $result['Encrypt']);
+			if (isset($result['ComponentVerifyTicket'])) {
+				$this->wechat->ticket($result['ComponentVerifyTicket'], 600, 100);
+			}
+			return true;
+		} else {
+			return false;
+		}
+    }
+}

+ 135 - 0
src/Core.php

@@ -0,0 +1,135 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+
+class Core
+{
+	public function getPageByTemplate()
+	{
+		$template = Dever::input('template');
+    	$data = Dever::db('wechat_component_applet/page')->getAll(array('template_id' => $template));
+    	return Dever::load('manage/database')->getAjax($data);
+	}
+
+	public function update($id, $data, $param = array())
+	{
+		$delete = false;
+		if (isset($param['state']) && $param['state'] == 2) {
+			$delete = true;
+		}
+		$info = Dever::db($this->table)->one($id);
+		if (!$info) {
+			return;
+		}
+
+		$user = Dever::param('user', $param);
+		if (!$user) {
+			$user = Dever::db('wechat_component/user')->state(array('option_project_id' => $info['project_id']));
+		}
+
+		if ($user) {
+			foreach ($user as $v) {
+				$this->set($v, $info['id'], $delete);
+			}
+		}
+	}
+
+	public function set($user, $id, $delete = false)
+	{
+		$result = array();
+		if (is_numeric($user) && $user > 0) {
+			$user = Dever::db('wechat_component/user')->one($user);
+		}
+		if ($user && $user['oauth_id']) {
+			$oauth = Dever::db('token/oauth')->one($user['oauth_id']);
+			$send = array();
+			$send['d'] = $delete;
+			$send['i'] = $id;
+			$send['t'] = $this->table;
+			$send['o'] = $oauth['id'];
+			$send['u'] = $user['id'];
+			$result = Dever::daemon($this->url($send), 'component');
+		}
+
+		return $result;
+	}
+
+	public function url($send)
+	{
+		$send = base64_encode(json_encode($send));
+		$url = 'core.call?param=' . $send;
+		return $url;
+	}
+
+	public function call()
+	{
+		$send = json_decode(base64_decode(Dever::input('param')), true);
+		if (isset($send['o']) && $send['o'] > 0 && isset($send['i']) && $send['i'] > 0) {
+			$table = $send['t'];
+			$info = Dever::db($table)->one($send['i']);
+			$wechat = new Wechat($info['project_id'], 'component');
+			$oauth = $wechat->oauth($send['o']);
+			if ($oauth && $oauth['value']) {
+				$oauth['oauth'] = $oauth['value'];
+				$oauth = Dever::load($table)->handle($oauth, $info, $send['d'], $send['u'], $wechat);
+				$result = $wechat->curl($oauth['method'], $oauth, false);
+				$this->log($table, $send['u'], $info, $result, $oauth['method'], $oauth);
+			}
+		}
+		return;
+	}
+
+	public function log($table, $user, $info, $result, $method, $param)
+	{
+		print_r($result);
+		if ($table == 'wechat_component_applet/version') {
+			$insert['user_id'] = $user;
+			$insert['name'] = $info['name'];
+			$insert['template_id'] = $info['template_id'];
+			$insert['project_id'] = $info['project_id'];
+			$insert['version_id'] = $info['id'];
+			$insert['result'] = json_encode($result);
+			Dever::db($table . '_log')->insert($insert);
+		} elseif ($table == 'wechat_component_applet/auditing') {
+			if (isset($result['auditid'])) {
+				$update['auditid'] = $result['auditid'];
+			}
+			
+			$update['result'] = json_encode($result);
+			$update['where_id'] = $info['id'];
+			Dever::db($table)->update($update);
+		} elseif ($table == 'wechat_component_applet/publish' || $table == 'wechat_component_applet/revert' || $table == 'wechat_component_applet/unaudit') {
+			if ($result['errcode'] == 0) {
+				$update['status'] = 2;
+			} else {
+				$update['status'] = 3;
+			}
+			
+			$update['result'] = json_encode($result);
+			$update['where_id'] = $info['id'];
+			Dever::db($table)->update($update);
+
+			if ($table == 'wechat_component_applet/unaudit' && $update['status'] == 2) {
+				$audit = array('option_user_id' => $info['user_id'], 'option_project_id' => $info['project_id'], 'option_version_id' => $info['version_id'], 'option_status' => 1);
+				$audit = Dever::db('wechat_component_applet/auditing')->all($audit);
+				if ($audit) {
+					foreach ($audit as $k => $v) {
+						$update = array();
+						$update['set_status'] = 3;
+						$update['set_statusDesc'] = '撤回';
+						$update['where_id'] = $v['id'];
+						Dever::db('wechat_component_applet/auditing')->update($update);
+					}
+				}
+			}
+		}
+		die;
+	}
+}

+ 449 - 0
src/Receive.php

@@ -0,0 +1,449 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| receive.php 用于接收微信发过来的信息
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+
+class Receive
+{
+	/**
+	 * wechat
+	 *
+	 * @var Wechat
+	 */
+	private $wechat;
+	
+	/**
+	 * result
+	 *
+	 * @var array
+	 */
+	private $result;
+	
+	/**
+	 * output
+	 *
+	 * @var string
+	 */
+	private $output;
+	
+	/**
+     * 构造函数 初始化
+     * 
+     * @return mixed
+     */
+	public function __construct()
+	{
+		$this->wechat = new Wechat();
+	}
+	
+	/**
+     * 业务推送接口 微信服务器会将所有请求都推送到这里
+     * 
+     * @return mixed
+     */
+	public function main()
+	{
+		$this->output = '';
+		
+		# 获取微信消息
+		$this->request();
+		
+		# 对消息进行验证,并根据类型得到本平台的配置数据
+		//$this->response();
+		
+		# 输出
+		$this->output();
+	}
+	
+	/**
+     * 输出
+     * 
+     * @return mixed
+     */
+	private function output()
+	{
+		if (!$this->output) {
+			$this->output = 'success';
+		}
+		echo $this->output;die;
+	}
+	
+	/**
+     * 据类型得到本平台的配置数据
+     * 
+     * @return mixed
+     */
+	private function response()
+	{
+		if ($this->output) {
+			return;
+		}
+		
+		if ($this->result && isset($this->result['add_type'])) {
+			if (isset($this->result['subscribe'])) {
+				if ($this->result['subscribe'] == true) {
+					# 订阅成功 发送消息
+					$this->msg('msg1');
+					# 发送消息之后,往用户表更新信息
+					$this->user();
+					$this->setSubscribe(1);
+				}
+				if ($this->result['subscribe'] == false) {
+					# 取消订阅 不发送消息
+					//$this->msg('msg1');
+					# 改变当前用户的订阅状态
+					$this->setSubscribe(2);
+				}
+			} elseif (isset($this->result['add_content'][0]['Content'])) {
+				$this->match($this->result['add_content'][0]['Content']);
+			} else {
+				# 如果没有匹配到,则直接返回默认回复消息
+				$this->msg('msg2');
+			}
+		}
+	}
+
+    /**
+     * 获取微信发送的内容
+     * 
+     * @return mixed
+     */
+    private function request()
+    {
+		$data = $_GET ? $_GET : $_POST;
+		$xml = file_get_contents('php://input');
+		Dever::log(json_encode($data) . $xml);
+		if (!empty($xml)) {
+			libxml_disable_entity_loader(true);
+          	$result = (array) simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
+          	$result = $this->wechat->decode($data['msg_signature'], $data['timestamp'], $data['nonce'], $result['Encrypt']);
+
+          	//$this->handle($result);
+		} else {
+			return false;
+		}
+    }
+    
+    /**
+     * 对微信的内容做处理,得到最终结果
+     * 
+     * @return mixed
+     */
+    private function handle($result)
+    {
+    	return;
+		$config = array
+		(
+			'AppId' => 'add_appid',
+			'CreateTime' => 'add_create_date',
+			'InfoType' => 'add_type',
+			'ComponentVerifyTicket' => 'add_ticket',
+		);
+		
+		foreach ($config as $k => $v) {
+			$this->result($k, $v, $result);
+		}
+		
+		# 事件处理
+		$this->event();
+		
+		$this->save();
+	}
+	
+	/**
+     * 事件处理
+     * 
+     * @return mixed
+     */
+	private function event()
+	{
+		if ($this->result['add_type'] == 'component_verify_ticket') {
+			
+		}
+	}
+	
+	/**
+     * 入库
+     * 
+     * @return mixed
+     */
+	private function save()
+	{
+		$this->result['add_info'] = is_array($this->result['add_info']) ? implode(',', $this->result['add_info']) : $this->result['add_info'];
+		$this->result['add_site'] = $this->core->site();
+		
+		# 入库 使用mid排重
+		$info = array();
+		if (isset($this->result['add_mid'])) {
+			$info = Dever::load('weixin/usermsg-getOne', array('where_mid' => $this->result['add_mid'], 'where_site' => $this->result['add_site']));
+			$this->result['id'] = $info['id'];
+		}
+
+		if (!$info) {
+			$this->result['id'] = Dever::load('weixin/usermsg-insert', $this->result);
+
+			# 记录点对点聊天记录 暂时不记录了
+			/*
+			if($this->result['add_type'] == 'text')
+			{
+				$update['add_state'] = 1;
+				$update['add_openid'] = $this->result['add_from'];
+				$update['add_usermsg_id'] = $this->result['id'];
+				$update['add_account'] = -1;
+				$update['add_type'] = $this->result['add_type'];
+				$update['add_info'] = Dever::load('weixin/user.msg', $this->result['id']);
+
+				Dever::load('weixin/usermsg_log-insert', $update);
+			}
+			*/
+		}
+	}
+	
+	/**
+     * 得到最终结果
+     * 
+     * @return mixed
+     */
+    private function result($key, $index, $result, $name = '')
+    {
+		if (isset($result[$key])) {
+			$value = trim($result[$key]);
+			if ($index == 'add_type') {
+				$this->type($value, $result);
+			}
+			if ($index == 'add_content') {
+				//$key = $name ? $name : $key;
+				$this->result[$index][0][$key] = $value;
+				$this->info($key, $value);
+			} elseif ($index == 'add_ctime') {
+				$this->result[$index] = $value ? $value : time();
+			} else {
+				$this->result[$index] = $value;
+			}
+		}
+	}
+
+	/**
+     * 根据状态得到用户发送的具体内容,为了响应及时,这里不做解析。
+     * 
+     * @return mixed
+     */
+    private function info($key, $value)
+    {
+    	$this->result['add_info'][] = $value;
+    }
+	
+	/**
+     * 得到type的值
+     * 
+     * @return mixed
+     */
+    private function type($index, $result)
+    {
+		$type = $this->config($index);
+		if (is_array($type)) {
+			foreach ($type as $k => $v) {
+				if (is_numeric($k)) {
+					$k = $v;
+				}
+				$this->result($k, 'add_content', $result, $v);
+			}
+		} else {
+			$this->result($type, 'add_content', $result);
+		}
+	}
+	
+	/**
+     * 得到对应关系
+     * 
+     * @return mixed
+     */
+    private function keywords($type)
+    {
+		# 根据keywords的type设定来设置对应关系
+		$config = array
+		(
+			1 => 'text',
+			2 => 'news',
+			//3 => 'news',
+			4 => 'voice',
+			5 => 'video',
+			6 => 'image',
+		);
+		
+		if (!isset($config[$type])) {
+			return false;
+		}
+		
+		$this->result['type'] = $config[$type];
+		
+		return $config[$type];
+	}
+
+    /**
+     * 配置type类型
+     * 
+     * @return mixed
+     */
+    private function config($key, $type = 'get')
+    {
+    	$config = array
+    	(
+    		# 文本
+    		'text' => array
+    		(
+				# 设置获取的key 应答
+				'get' => 'Content',
+				# 设置赋值的key 回复
+				'set' => 'Content',
+			),
+    		# 图片
+    		'image' => array
+    		(
+				'get' => array('PicUrl', 'MediaId'),
+				'set' => array
+				(
+					'Image' => array('MediaId' => 'pic')
+				),
+			),
+    		# 语音
+    		'voice' => array
+    		(
+				'get' => array('MediaId', 'Format'),
+				'set' => array
+				(
+					'Voice' => array('MediaId' => 'mp3')
+				),
+			),
+			# 视频
+    		'video' => array
+    		(
+				'get' => array('MediaId', 'ThumbMediaId'),
+				'set' => array
+				(
+					'Voice' => array('MediaId' => 'mp4', 'Title' => 'title', 'Description' => 'info')
+				),
+			),
+			# 小视频
+    		'shortvideo' => array
+    		(
+				'get' => array('MediaId', 'ThumbMediaId'),
+				'set' => false,
+			),
+			# 地理位置
+    		'location' => array
+    		(
+				'get' => array('Location_X', 'Location_Y', 'Scale', 'Label'),
+				'set' => false,
+			),
+			# 链接消息
+    		'link' => array
+    		(
+				'get' => array('Title', 'Description', 'Url', 'Label'),
+				'set' => false,
+			),
+			# 单图文消息
+    		'new' => array
+    		(
+				'get' => false,
+				'set' => array
+				(
+					'ArticleCount' => 1,
+					'Articles' => array
+					(
+						'item' => array('Title' => 'title', 'Description' => 'info', 'PicUrl' => 'pic', 'Url' => 'link')
+					)
+				),
+			),
+			# 多图文消息
+    		'news' => array
+    		(
+				'get' => false,
+				'set' => array
+				(
+					'ArticleCount' => 'total',
+					'Articles' => array
+					(
+						'item' => array('Title' => 'title', 'Description' => 'info', 'PicUrl' => 'pic', 'Url' => 'link')
+					)
+				),
+			),
+			# 音乐消息
+			'music' => array
+    		(
+				'get' => false,
+				'set' => false,
+			),
+			
+			# 事件消息,所有事件返回的字段都在此做说明
+			'event' => array
+    		(
+				'get' => array
+				(
+					'Event' => '事件',
+					'EventKey' => '事件ID',
+					'Latitude' => '纬度',
+					'Longitude' => '经度',
+					'Precision' => '精度',
+					'Ticket' => '二维码',
+					'MsgID' => '消息ID',
+					'Status' => '状态',
+					'TotalCount' => '粉丝数',
+					'FilterCount' => '过滤数',
+					'SentCount' => '成功数',
+					'ErrorCount' => '失败数',
+				),
+				'set' => false,
+			),
+    	);
+    	
+    	return $config[$key][$type];
+    }
+
+    /**
+     * 获取当前时间
+     * 
+     * @return mixed
+     */
+    private function time()
+    {
+		return time();
+    }
+
+    /**
+     * 拼装xml相应代码
+     * 
+     * @return mixed
+     */
+    private function xml($content)
+    {
+    	$xml = 	"<xml>\r\n"
+    	.$this->tag('ToUserName', $this->result['add_from']) . "\r\n"
+    	.$this->tag('FromUserName', $this->result['add_to']) . "\r\n"
+    	.$this->tag('CreateTime', $this->time()) . "\r\n"
+    	.$this->tag('MsgType', $this->result['type']) . "\r\n"
+    	.$content . "\r\n"
+    	.'</xml>';
+
+		return $xml;
+    }
+
+    /**
+     * 生成tag
+     * 
+     * @return mixed
+     */
+    private function tag($tag, $value = '')
+    {
+		if (!is_numeric($value) && strpos($value, '<') === false) {
+			$value = '<![CDATA['.$value.']]>';
+		}
+    	return '<'.$tag.'>'.$value.'</'.$tag.'>';
+    } 
+}

+ 53 - 0
src/User.php

@@ -0,0 +1,53 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Wechat_component\Src;
+
+use Dever;
+use Token\Lib\Wechat;
+
+class User
+{
+	public function logo($id)
+	{
+		$info = Dever::db('wechat_component/user')->one($id);
+		$oauth = Dever::db('token/oauth')->one($info['oauth_id']);
+		$wechat = new Wechat($info['project_id'], 'component');
+		$oauth['oauth'] = $oauth['id'];
+		$oauth['path'] = 'pages/index/index';
+		$param = $wechat->param('applet_qrcode', $oauth, false);
+		$url = $param['url'];
+		$html['LOGO'] = '<img src="'.$info['pic'].'"  width="150" />';
+		$html['正式版'] = '<img src="'.$info['qrcode'].'"  width="150" />';
+		if ($url) {
+			//$version = Dever::db('wechat_component/version')->one($id);
+			$html['体验版'] = '<img src="'.$url.'"  width="150" />';
+		}
+		
+
+		$html = Dever::table($html);
+		return $html;
+	}
+
+	public function qrcode($uid, $id)
+	{
+		$version = Dever::db('wechat_component/version_log')->one($id);
+		$info = Dever::db('wechat_component/user')->one($uid);
+		$oauth = Dever::db('token/oauth')->one($info['oauth_id']);
+		$wechat = new Wechat($info['project_id'], 'component');
+		$oauth['oauth'] = $oauth['id'];
+		$oauth['path'] = 'pages/index/index';
+		$param = $wechat->param('applet_qrcode', $oauth, false);
+		$url = $param['url'];
+		$html['返回信息'] = $version['result'];
+		if ($url) {
+			$html['体验版'] = '<img src="'.$url.'"  width="150" />';
+		}
+
+		$html = Dever::table($html);
+		return $html;
+	}
+}