dever 6 years ago
parent
commit
af18d40992

+ 0 - 13
component/config/component.php

@@ -1,13 +0,0 @@
-<?php
-
-# 微信第三方平台 接口配置
-
-$config = array();
-
-$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'component' . DIRECTORY_SEPARATOR;
-
-# 载入素材配置
-//$config += include($path . 'media.php');
-
-
-return $config;

+ 190 - 0
component/config/component/applet.php

@@ -0,0 +1,190 @@
+<?php
+# applet基本接口配置
+
+$domain = '{domain}';
+
+# 设置服务域名
+$config['applet_domain'] = array
+(
+	'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',
+	),
+);
+
+
+return $config;

+ 49 - 3
component/config/wechat.php

@@ -1,9 +1,11 @@
 <?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?',
@@ -27,6 +29,7 @@ $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?',
@@ -44,6 +47,7 @@ $config['oauth'] = array
 	//第二步,拼装redirect,进行授权登录
 	'login' => array
 	(
+		'name' => '获取oauth login',
 		'method' => 'get',
 		'json' => false,
 		'url' => 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?',
@@ -59,6 +63,7 @@ $config['oauth'] = array
 	//第三步,获取到token
 	'oauth' => array
 	(
+		'name' => '获取oauth token',
 		'method' => 'post',
 		'json' => true,
 		'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?',
@@ -66,18 +71,59 @@ $config['oauth'] = array
 		(
 			'component_access_token' => 'token',
 			'component_appid' => 'appid',
-			'authorization_code' => 'code',
+			'authorization_code' => 'auth_code',
 		),
 		'response' => array
 		(
 			'authorization_info.authorizer_appid' => 'openid',
-			'authorization_info.authorizer_appid' => 'unionid',
+			'authorization_info.authorizer_appid.key' => 'unionid',
 			'authorization_info.authorizer_access_token' => 'oauth.oauth',
 			'authorization_info.authorizer_refresh_token' => 'refresh',
-			'authorization_info.func_info' => 'callback.func',
+			'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;

+ 190 - 0
component/database/auditing.php

@@ -0,0 +1,190 @@
+<?php
+/**
+ * tester
+ */
+
+$status = array
+(
+	1 => '审核中',
+	2 => '审核成功',
+	3 => '审核失败',
+);
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('component/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('component/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,
+		),
+
+		'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,
+		),
+
+		'statusDesc'		=> array
+		(
+			'type' 		=> 'varchar-40',
+			'name' 		=> '审核说明',
+			'default' 	=> '',
+			'desc' 		=> '审核说明',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> 'Dever::load("component/auditing.view", {status}, {id}, {user_id}, {project_id}, {auditid})',
+		),
+		
+		'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,
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'top' => Dever::config('base')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 108 - 0
component/database/domain.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ * domain
+ */
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'domain',
+	# 显示给用户看的名称
+	'lang' => '设置服务域名',
+	'order' => 99,
+	'end' => array
+	(
+		'insert' => array
+		(
+			'component/domain.update',
+		),
+		'update' => array
+		(
+			'component/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' 	=> 'is_string',
+			//'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')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 124 - 0
component/database/page.php

@@ -0,0 +1,124 @@
+<?php
+/**
+ * tester
+ */
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('component/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'page',
+	# 显示给用户看的名称
+	'lang' => '页面列表',
+	'order' => 93,
+	'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',
+		),
+		
+		'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,
+		),
+
+		'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,
+		),
+	),
+
+	'top' => Dever::config('base')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 156 - 0
component/database/publish.php

@@ -0,0 +1,156 @@
+<?php
+/**
+ * tester
+ */
+
+$status = array
+(
+	1 => '发布中',
+	2 => '发布成功',
+	3 => '发布失败',
+);
+
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('component/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('component/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,
+		),
+
+		'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')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 173 - 0
component/database/tabbar.php

@@ -0,0 +1,173 @@
+<?php
+/**
+ * tester
+ */
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('component/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$page = function()
+{
+	$array = array();
+	$info = Dever::load('component/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',
+			'option'	=> $template,
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		/*
+		'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',
+			'option'	=> $page,
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'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')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 95 - 0
component/database/template.php

@@ -0,0 +1,95 @@
+<?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,
+		),
+
+		'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')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 118 - 0
component/database/tester.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * tester
+ */
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'tester',
+	# 显示给用户看的名称
+	'lang' => '设置体验者',
+	'order' => 98,
+	'end' => array
+	(
+		'insert' => array
+		(
+			'component/tester.update',
+		),
+		'update' => array
+		(
+			'component/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' 	=> '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,
+		),
+
+		'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')->top,
+
+	'manage' => array
+	(
+		
+	),
+);

+ 190 - 0
component/database/user.php

@@ -0,0 +1,190 @@
+<?php
+/**
+ * user
+ */
+$type = array
+(
+	1 => '小程序',
+	2 => '订阅号',
+	3 => '服务号',
+);
+
+return array
+(
+	# 表名
+	'name' => 'user',
+	# 显示给用户看的名称
+	'lang' => '用户管理',
+	'order' => 100,
+	# 数据结构
+	'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')->top,
+
+	'manage' => array
+	(
+		//'delete' => true,
+		'insert' => false,
+		'edit' => false,
+	),
+);

+ 160 - 0
component/database/version.php

@@ -0,0 +1,160 @@
+<?php
+/**
+ * tester
+ */
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('component/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+return array
+(
+	# 表名
+	'name' => 'version',
+	# 显示给用户看的名称
+	'lang' => '版本管理',
+	'order' => 97,
+	'end' => array
+	(
+		'insert' => array
+		(
+			'component/version.update',
+		),
+		'update' => array
+		(
+			'component/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,
+		),
+		
+		'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')->top,
+
+	'manage' => array
+	(
+		'delete' => false,
+		'list_button' => array
+		(
+			'list' => array('日志', '"version_log&search_option_version_id={id}&oper_parent=version"'),
+
+			'oper' => array('提审', '"component/auditing.submit?id={id}"'),
+
+			'oper1' => array('发布', '"component/publish.submit?id={id}"'),
+		),
+	),
+);

+ 160 - 0
component/database/version_log.php

@@ -0,0 +1,160 @@
+<?php
+/**
+ * tester
+ */
+$user = function()
+{
+	$array = array();
+	$info = Dever::load('component/user-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$template = function()
+{
+	$array = array();
+	$info = Dever::load('component/template-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$version = function()
+{
+	$array = array();
+	$info = Dever::load('component/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("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')->top,
+
+	'manage' => array
+	(
+		'edit' => false,
+		'delete' => false,
+		'insert' => false,
+	),
+);

+ 0 - 157
component/service/Auth.php

@@ -1,157 +0,0 @@
-<?php
-/*
-|--------------------------------------------------------------------------
-| auth.php 用于做权限验证
-|--------------------------------------------------------------------------
-*/
-namespace Component\Service;
-
-use Dever;
-use Main\Lib\Wechat;
-
-class Auth
-{
-	const TYPE = 5;
-
-	/**
-	 * wechat
-	 *
-	 * @var Wechat
-	 */
-	private $wechat;
-	
-	/**
-	 * result
-	 *
-	 * @var array
-	 */
-	private $result;
-	
-	/**
-	 * output
-	 *
-	 * @var string
-	 */
-	private $output;
-	
-	/**
-     * 构造函数 初始化
-     * 
-     * @return mixed
-     */
-	public function __construct()
-	{
-		$this->wechat = new Wechat(self::TYPE);
-	}
-
-	/**
-     * 获取component token 一般为系统token
-     * 
-     * @return mixed
-     */
-	public function token_api()
-	{
-		return $this->wechat->token();
-	}
-
-	/**
-     * 获取预授权码 开始用户授权
-     * 
-     * @return mixed
-     */
-	public function test_api()
-	{
-		$link = $this->wechat->login('component/auth.oauth', false, false);
-		echo '<a href="'.$link.'">第三方平台授权</a>';die;
-	}
-
-	/**
-     * 获取预授权码 开始用户授权
-     * 
-     * @return mixed
-     */
-	public function get_api()
-	{
-		$this->wechat->login('component/auth.oauth');
-	}
-
-	/**
-     * 获取oauth的token 用户token
-     * 
-     * @return mixed
-     */
-	public function oauth_api()
-	{
-		$this->wechat->oauth();
-	}
-	
-	/**
-     * 业务推送接口 微信服务器会将所有请求都推送到这里
-     * 
-     * @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()
-    {
-		//$post = $_GET ? $_GET : $_POST;
-		$data = array();
-		$data['signature'] = '432ec06aa3a0f680924c9587ea215b4e490382b3';
-		$data['timestamp'] = '1525677152';
-		$data['nonce']	= '377902872';
-		$data['encrypt_type'] = 'aes';
-		$data['msg_signature'] = '7f62174a1402d955c2d8e61f69a309540714c579';
-
-
-		$xml = file_get_contents('php://input');
-
-		Dever::log(json_encode($_GET) . $xml);
-
-		$xml = "<xml>
-    <AppId><![CDATA[wxc50846069a0ae2d2]]></AppId>
-    <Encrypt><![CDATA[SYTZJTU4ZWOKAWhjWYgVEZQMRplYNo1ZuN5dL3hQoQmbLbYM0O5Iaw/FqpigtOAyIL3dIgoA1ti91C0Z45/qgl9w4Fxa1yi94tugaWQfq5pQGbRwBte5uR3okaFxVYW0ZQd3k0HWuMgAvt/pDoMn5hLpvxhfEKX4ZVvkY4fcgb0D4bz1xba0DCdpVqHmzk1ewbD01LeUNw9JQSSBiFX24x7JruXSvsXMn0gKfYUR1s5vavnoVz6CeyUYzW63Id+b4gxKDnBGAfsBQWFdtgoJg9Ze6AN2EBGmbltx8qr7L+UKCrExgpdBRyG2vDu4QQvk+lp/jjbao721zQGpgFqr1hIJjSiXX6M8my7l3wI+nHJpdF3PpCsEiml2zcFGDrd7PSS1A8PAYrDG8W84NNpK4Onz2ZxrRI/BusI999TiS/I88fT5XM4qMo2j2F488vvSRHdJxo7C+3V+rQFkBXSbVA==]]></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;
-		}
-    }
-}

+ 105 - 0
component/src/Auditing.php

@@ -0,0 +1,105 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class Auditing extends Core
+{
+	public $table = 'auditing';
+
+	public function submit()
+	{
+		$id = Dever::input('id');
+		$info = Dever::db('component/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'];
+			$id = Dever::upinto('component/auditing', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_version_id' => $param['version_id']), $param);
+			$this->set($v, $id);
+		}
+		Dever::alert('提交成功,请到审核历史中查看审核状态');
+		return;
+	}
+
+	# 查看审核状态
+	public function view($status, $id, $uid, $project, $auditid)
+	{
+		$html = array();
+		if ($status == 2) {
+			$html['审核状态'] = '审核成功';
+		} elseif ($status == 3) {
+			$html['审核状态'] = '审核失败';
+			$info = Dever::db('component/auditing')->one($id);
+			$html['说明'] = $info['statusDesc'];
+		} elseif ($status == 1) {
+			$user = Dever::db('component/user')->one($uid);
+			$oauth = Dever::db('main/oauth')->one($user['oauth_id']);
+			$wechat = new Wechat($project, 'component');
+			$oauth = $wechat->oauth($oauth['id']);
+			$oauth['oauth'] = $oauth['value'];
+			$oauth['auditid'] = $auditid;
+			$result = $wechat->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'] = $id;
+				Dever::db('component/auditing')->update($update);
+			}
+		}
+		
+
+		$html = Dever::table($html);
+
+		return $html;
+	}
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$oauth['method'] = 'applet_submit';
+		$project = Dever::db('main/project')->one($info['project_id']);
+		$user = Dever::db('component/user')->one($user);
+
+		# 获取类目
+		$result = $wechat->curl('applet_category', $oauth, false);
+
+		$item = array
+		(
+			'address' => 'pages/index/index',
+			'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;
+	}
+}

+ 218 - 0
component/src/Auth.php

@@ -0,0 +1,218 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| auth.php 用于做权限验证
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\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();
+	}
+
+	/**
+     * 获取component token 一般为系统token
+     * 
+     * @return mixed
+     */
+	public function token_api()
+	{
+		return $this->wechat->token();
+	}
+
+	/**
+     * 获取预授权码 开始用户授权
+     * 
+     * @return mixed
+     */
+	public function test_api()
+	{
+		$link = $this->wechat->login('component/auth.oauth', false, false);
+		echo '<a href="'.$link.'">第三方平台授权</a>';die;
+	}
+
+	/**
+     * 获取预授权码 开始用户授权
+     * 
+     * @return mixed
+     */
+	public function get_api()
+	{
+		$this->wechat->login('component/auth.oauth');
+	}
+
+	/**
+     * 获取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);
+		}
+		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('component/user', array('option_oauth_id' => $data['id']), $param);
+				
+				$list = Dever::db('component/domain')->state(array('option_project_id' => $param['project_id']));
+				$domain = array();
+				foreach ($list as $k => $v) {
+					if (!in_array($v['value'], $domain)) {
+						$domain[] = $v['value'];
+					}
+				}
+				//自动设置域名
+				$param['id'] = $id;
+				Dever::load('component/domain.set', $param, $domain);
+				
+				//自动设置体验者
+			}
+		}
+
+		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()
+    {
+		//$post = $_GET ? $_GET : $_POST;
+		/*
+		$data = array();
+		$data['signature'] = '9474754223130bc1c820537b8113b590ef3cbf8e';
+		$data['timestamp'] = '1525915492';
+		$data['nonce']	= '1211005377';
+		$data['encrypt_type'] = 'aes';
+		$data['msg_signature'] = 'f17b5c2d2cf1592e07803f190048289ff468ef2b';
+
+		$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>";
+		*/
+
+		$xml = file_get_contents('php://input');
+		$data = $_GET;
+		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']);
+			if (isset($result['ComponentVerifyTicket'])) {
+				$this->wechat->ticket($result['ComponentVerifyTicket'], 600, 100);
+			}
+			return true;
+		} else {
+			return false;
+		}
+    }
+}

+ 114 - 0
component/src/Core.php

@@ -0,0 +1,114 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class Core
+{
+	public function update($id, $data, $param = array())
+	{
+		$delete = false;
+		if (isset($param['state']) && $param['state'] == 2) {
+			$delete = true;
+		}
+		$info = Dever::db('component/' . $this->table)->one($id);
+		if (!$info) {
+			return;
+		}
+
+		$user = Dever::param('user', $param);
+		if (!$user) {
+			$user = Dever::db('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('component/user')->one($user);
+		}
+		if ($user && $user['oauth_id']) {
+			$oauth = Dever::db('main/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 = 'component/' . $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 == 'component/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 == 'component/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 == 'component/publish') {
+			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);
+		}
+		die;
+	}
+}

+ 35 - 0
component/src/Domain.php

@@ -0,0 +1,35 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| domain 服务域名设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class Domain extends Core
+{
+	public $table = 'domain';
+
+	public function value($info)
+	{
+		$list = Dever::db('component/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;
+	}
+}

+ 38 - 0
component/src/Publish.php

@@ -0,0 +1,38 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class Publish extends Core
+{
+	public $table = 'publish';
+
+	public function submit()
+	{
+		$id = Dever::input('id');
+		$info = Dever::db('component/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'];
+			$id = Dever::upinto('component/publish', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_version_id' => $param['version_id']), $param);
+			$this->set($v, $id);
+		}
+		Dever::alert('提交成功,请到发布历史中查看发布状态');
+		return;
+	}
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$oauth['method'] = 'applet_publish';
+		return $oauth;
+	}
+}

+ 2 - 4
component/service/Receive.php → component/src/Receive.php

@@ -4,15 +4,13 @@
 | receive.php 用于接收微信发过来的信息
 |--------------------------------------------------------------------------
 */
-namespace Component\Service;
+namespace Component\Src;
 
 use Dever;
 use Main\Lib\Wechat;
 
 class Receive
 {
-	const TYPE = 5;
-
 	/**
 	 * wechat
 	 *
@@ -41,7 +39,7 @@ class Receive
      */
 	public function __construct()
 	{
-		$this->wechat = new Wechat(self::TYPE);
+		$this->wechat = new Wechat();
 	}
 	
 	/**

+ 26 - 0
component/src/Tester.php

@@ -0,0 +1,26 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class Tester extends Core
+{
+	public $table = '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;
+	}
+}

+ 53 - 0
component/src/User.php

@@ -0,0 +1,53 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class User
+{
+	public function logo($id)
+	{
+		$info = Dever::db('component/user')->one($id);
+		$oauth = Dever::db('main/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);
+		$url = $param['url'];
+		$html['LOGO'] = '<img src="'.$info['pic'].'"  width="150" />';
+		$html['正式版'] = '<img src="'.$info['qrcode'].'"  width="150" />';
+		if ($url) {
+			//$version = Dever::db('component/version')->one($id);
+			$html['体验版'] = '<img src="'.$url.'"  width="150" />';
+		}
+		
+
+		$html = Dever::table($html);
+		return $html;
+	}
+
+	public function qrcode($uid, $id)
+	{
+		$version = Dever::db('component/version_log')->one($id);
+		$info = Dever::db('component/user')->one($uid);
+		$oauth = Dever::db('main/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);
+		$url = $param['url'];
+		$html['返回信息'] = $version['result'];
+		if ($url) {
+			$html['体验版'] = '<img src="'.$url.'"  width="150" />';
+		}
+
+		$html = Dever::table($html);
+		return $html;
+	}
+}

+ 103 - 0
component/src/Version.php

@@ -0,0 +1,103 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| tester 体验者设置
+|--------------------------------------------------------------------------
+*/
+namespace Component\Src;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class Version extends Core
+{
+	public $table = 'version';
+
+	public function handle($oauth, $info, $delete, $user, $wechat)
+	{
+		$template = Dever::db('component/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('main/project')->one($info['project_id']);
+		$user = Dever::db('component/user')->one($user);
+
+		$pageInfo = Dever::db('component/page')->state(array('option_template_id' => $template['id']));
+
+		$page = array();
+
+		if ($pageInfo) {
+			$i = 0;
+			foreach ($pageInfo as $k => $v) {
+				$page[$i] = $v['pagepath'];
+				$i++;
+			}
+		}
+
+		$tabbar = Dever::db('component/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'];
+				$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"
+		);
+		*/
+		$ext = array
+		(
+			'extEnable' => true,
+			'extAppid' => $oauth['openid'],
+			'directCommit' => false,
+			'ext' => array
+			(
+				'version' => $info['name'],
+				'desc' => $user['desc'],
+				'project' => $project['id'],
+			),
+			'extPages' => array(),
+			'pages' => $page,
+			'window' => array
+			(
+				'navigationBarTitleText' => $user['name'],
+			),
+			'tabBar' => array
+			(
+				'list' => $tab,
+			),
+		);
+
+		if (!$page) {
+			unset($ext['pages']);
+		}
+		$oauth['ext_json'] = json_encode($ext, JSON_UNESCAPED_UNICODE);
+
+		//print_r($oauth);die;
+		return $oauth;
+	}
+}

+ 2 - 1
config/base.php

@@ -3,7 +3,8 @@
 # 一些基本配置
 $config['base'] = array
 (
-	
+	# 后台头部菜单
+	'top' => 'main/project_id',
 );
 
 # 模板配置

+ 1 - 0
main/database/code.php

@@ -74,6 +74,7 @@ return array
 			'name' 		=> '状态',
 			'default' 	=> '1',
 			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
 		),
 		
 		'cdate'		=> array

+ 102 - 0
main/database/log.php

@@ -0,0 +1,102 @@
+<?php
+/**
+ * tester
+ */
+
+
+return array
+(
+	# 表名
+	'name' => 'log',
+	# 显示给用户看的名称
+	'lang' => '请求日志',
+	'order' => 1,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '请求名称',
+			'default' 	=> '',
+			'desc' 		=> '请求名称',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+		),
+
+		'url'		=> array
+		(
+			'type' 		=> 'varchar-255',
+			'name' 		=> '请求地址',
+			'default' 	=> '',
+			'desc' 		=> '请求地址',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+			
+		),
+
+		'param'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '请求信息',
+			'default' 	=> '',
+			'desc' 		=> '请求信息',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+		),
+
+		'result'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '微信返回信息',
+			'default' 	=> '',
+			'desc' 		=> '微信返回信息',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'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,
+		),
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'insert' => false,
+		'edit' => false,
+	),
+);

+ 1 - 0
main/database/oauth.php

@@ -110,6 +110,7 @@ return array
 			'name' 		=> '状态',
 			'default' 	=> '1',
 			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
 		),
 		
 		'cdate'		=> array

+ 1 - 0
main/database/ticket.php

@@ -74,6 +74,7 @@ return array
 			'name' 		=> '状态',
 			'default' 	=> '1',
 			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
 		),
 		
 		'cdate'		=> array

+ 1 - 0
main/database/token.php

@@ -74,6 +74,7 @@ return array
 			'name' 		=> '状态',
 			'default' 	=> '1',
 			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
 		),
 		
 		'cdate'		=> array

+ 118 - 27
main/lib/Wechat.php

@@ -16,13 +16,6 @@ class Wechat
 	 * @var array
 	 */
 	private $config;
-
-	/**
-	 * config
-	 *
-	 * @var array
-	 */
-	private $token;
 	
 	/**
 	 * project
@@ -36,9 +29,10 @@ class Wechat
 	 * 
 	 * @return mixed
 	 */
-	public function __construct($type = 1, $project = false)
+	public function __construct($project = false, $type = '')
 	{
-		$this->config = Dever::config('wechat')->cAll;
+		$this->config = Dever::config('wechat', $type)->cAll;
+		$type = $this->config['type'];
 
 		if (!$project) {
 			$appid = Dever::input('appid');
@@ -86,15 +80,32 @@ class Wechat
 	 * 
 	 * @return mixed
 	 */
-	private function save($type = 'ticket', $value, $expires = false, $interval = 2000)
+	private function save($type = 'ticket', $value, $expires = false, $interval = 2000, $data = false)
 	{
 		if (strpos($type, '.')) {
 			$temp = explode('.', $type);
+			if ($temp[1] == 'refresh') {
+				$temp[1] = 'oauth';
+			}
 			$table = 'main/' . $temp[1];
 		} else {
 			$table = 'main/' . $type;
 		}
 		$db = Dever::db($table);
+
+		if ($data) {
+			if (isset($data['id'])) {
+				$where['option_id'] = $data['id'];
+				unset($data['id']);
+			}
+			if (isset($data['openid'])) {
+				$where['option_openid'] = $data['openid'];
+			}
+			if (isset($data['unionid'])) {
+				$where['option_unionid'] = $data['unionid'];
+			}
+		}
+		
 		$where['option_project_id'] = $this->project['id'];
 		$info = $db->one($where);
 
@@ -103,17 +114,15 @@ class Wechat
 		if ($info && time() - $info['mdate'] >= $info['expires']) {
 			$update = true;
 		} elseif($info) {
-			return $info['value'];
+			return $info;
 		}
 		if (!$info) {
 			$update = false;
 		}
-
 		if (!$value) {
-			$value = $this->param($type);
+			$value = $this->param($type, $info);
 		}
 
-		$data = array();
 		if (is_array($value) || (is_string($value) && strstr($value, 'http://'))) {
 			$result = $this->curl(false, $value);
 
@@ -138,15 +147,22 @@ class Wechat
 			}
 			if ($update == true) {
 				$data['where_id'] = $info['id'];
+				$id = $info['id'];
 				$db->update($data);
 			} else {
-				$db->insert($data);
+				$id = $db->insert($data);
+			}
+			$data['id'] = $id;
+			if ($id > 0 && isset($result['callback'])) {
+				foreach ($result['callback'] as $v) {
+					Dever::load($v[0], $id, $v[1], $this->project['id']);
+				}
 			}
 		} elseif($info && $info['value']) {
 			$data['value'] = $info['value'];
 		}
 
-		return $data['value'];
+		return $data;
 	}
 
 	/**
@@ -156,7 +172,8 @@ class Wechat
 	 */
 	public function token($value = false, $expires = false, $interval = 2000)
 	{
-		return $this->save('token', $value, $expires, $interval);
+		$result = $this->save('token', $value, $expires, $interval);
+		return $result['value'];
 	}
 
 	/**
@@ -166,7 +183,8 @@ class Wechat
 	 */
 	public function ticket($value = false, $expires = false, $interval = 200)
 	{
-		return $this->save('ticket', $value, $expires, $interval);
+		$result = $this->save('ticket', $value, $expires, $interval);
+		return $result['value'];
 	}
 
 	/**
@@ -174,9 +192,23 @@ class Wechat
 	 * 
 	 * @return mixed
 	 */
-	public function oauth($value = false, $expires = false, $interval = 200)
+	public function oauth($param, $interval = 2000)
 	{
-		return $this->save('oauth.oauth', $value, $expires, $interval);
+		if (is_array($param) && isset($param['auth_code'])) {
+			$result = $this->curl('oauth.oauth', $param);
+			if (isset($result['oauth.oauth'])) {
+				return $this->save('oauth.oauth', $result['oauth.oauth'], $result['expires_in'], $interval, $result);
+			} else {
+				Dever::alert('oauth error');
+			}
+		} else {
+			if (is_numeric($param)) {
+				$id = $param;
+				$param = array();
+				$param['id'] = $id;
+			}
+			return $this->save('oauth.refresh', false, false, $interval, $param);
+		}
 	}
 
 	/**
@@ -186,7 +218,19 @@ class Wechat
 	 */
 	public function code($value = false, $expires = false, $interval = 200)
 	{
-		return $this->save('oauth.code', $value, $expires, $interval);
+		$result = $this->save('oauth.code', $value, $expires, $interval);
+		return $result['value'];
+	}
+
+	/**
+	 * 获取最新的openid
+	 * 
+	 * @return mixed
+	 */
+	public function openid($id, $key = 'openid')
+	{
+		$info = Dever::db('main/oauth')->one($id);
+		return $info[$key];
 	}
 
 	/**
@@ -213,7 +257,7 @@ class Wechat
 	 * 
 	 * @return mixed
 	 */
-	public function curl($method, $param = array())
+	public function curl($method, $param = array(), $alert = true)
 	{
 		if (is_string($param)) {
 			$result = json_decode(Dever::curl($param), true);
@@ -223,11 +267,15 @@ class Wechat
 			}
 
 			$result = json_decode(Dever::curl($param['url'], $param['param'], $param['method'], $param['json']), true);
+			$this->log($result, $param['name'], $param['url'], $param['param']);
 		}
+		//print_r($param);die;
 		if (isset($result['errcode']) && $result['errcode'] != 0) {
 			$result = $param + $result;
 			Dever::log($result);
-			Dever::alert(json_encode($result));
+			if ($alert) {
+				Dever::alert(json_encode($result, JSON_UNESCAPED_UNICODE));
+			}
 		}
 
 		if (isset($param['response'])) {
@@ -240,11 +288,25 @@ class Wechat
 				} elseif (isset($result[$k])) {
 					$result[$v] = $result[$k];
 				}
+
+				if (strpos($v, 'callback.') !== false) {
+					$temp = explode('callback.', $v);
+					$result['callback'][] = array($temp[1], $result[$v]);
+				}
 			}
 		}
 		return $result;
 	}
 
+	public function log($result, $name, $url, $param)
+	{
+		$insert['name'] = $name;
+		$insert['url'] = $url;
+		$insert['result'] = json_encode($result, JSON_UNESCAPED_UNICODE);
+		$insert['param'] = json_encode($param, JSON_UNESCAPED_UNICODE);
+		Dever::db('main/log')->insert($insert);
+	}
+
 	/**
 	 * 拼装wechat需要的参数
 	 * 
@@ -261,9 +323,14 @@ class Wechat
 			}
 			$config = $this->config[$method];
 		}
+
+		if (!$param) {
+			$param = array();
+		}
 		
 		$param = $this->project + $param;
 
+		//print_r($param);die;
 		foreach ($config['param'] as $k => $v) {
 			if ($v == 'token') {
 				$config['url'] .= $k . '=' . $this->token();
@@ -272,12 +339,19 @@ class Wechat
 				$config['param'][$k] = $this->ticket();
 			} elseif ($v == 'code') {
 				$config['param'][$k] = $this->code();
-			}elseif ($v == 'oauth') {
-				$config['param'][$k] = $this->oauth();
-			} elseif (isset($param[$v]) && $param[$v]) {
+			} elseif ($v == 'oauth') {
+				if (!isset($param['oauth'])) {
+					Dever::alert('oauth erorr');
+				} elseif (is_numeric($param['oauth'])) {
+					$oauth = $this->oauth($param['oauth']);
+					$param['oauth'] = $oauth['value'];
+				}
+				$config['url'] .= $k . '=' . $param['oauth'];
+				unset($config['param'][$k]);
+			} elseif (!is_array($v) && isset($param[$v])) {
 				$config['param'][$k] = $param[$v];
 			} elseif($v) {
-				$config['param'][$k] = $v;
+				$config['param'][$k] = $this->replace($v, $param);
 			}
 		}
 
@@ -286,6 +360,23 @@ class Wechat
 		return $config;
 	}
 
+	/**
+	 * 替换{}
+	 * 
+	 * @return mixed
+	 */
+	public function replace($value, $param)
+	{
+		if (isset($param['domain']) && strpos($value, '{domain}') !== false) {
+			foreach ($param['domain'] as $k => $v) {
+				$param['domain'][$k] = str_replace('{domain}', $v, $value);
+			}
+			return $param['domain'];
+		}
+
+		return $value;
+	}
+
 	/**
 	 * 消息解密
 	 *