dever il y a 6 ans
Parent
commit
d6f9a5db85

+ 4 - 4
component/database/auditing.php → component/applet/database/auditing.php

@@ -24,7 +24,7 @@ $user = function()
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;
@@ -35,7 +35,7 @@ $template = function()
 $version = function()
 {
 	$array = array();
-	$info = Dever::load('component/version-state');
+	$info = Dever::load('component_applet/version-state');
 	if($info)
 	{
 		$array += $info;
@@ -97,7 +97,7 @@ return array
 			'match' 	=> 'is_string',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
-			'list'		=> '"{name}" ? "{name}" : Dever::load("component/version-one#name", {version_id})',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("component_applet/version-one#name", {version_id})',
 		),
 
 		'user_id'		=> array
@@ -158,7 +158,7 @@ return array
 			'desc' 		=> '审核说明',
 			'match' 	=> 'option',
 			'update'	=> 'textarea',
-			'list'		=> 'Dever::load("component/auditing.view", {id})',
+			'list'		=> 'Dever::load("component_applet/auditing.view", {id})',
 		),
 		
 		'state'		=> array

+ 2 - 2
component/database/domain.php → component/applet/database/domain.php

@@ -25,11 +25,11 @@ return array
 	(
 		'insert' => array
 		(
-			'component/domain.update',
+			'component_applet/domain.update',
 		),
 		'update' => array
 		(
-			'component/domain.update',
+			'component_applet/domain.update',
 		),
 	),
 	# 数据结构

+ 1 - 1
component/database/page.php → component/applet/database/page.php

@@ -6,7 +6,7 @@
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;

+ 3 - 3
component/database/publish.php → component/applet/database/publish.php

@@ -24,7 +24,7 @@ $user = function()
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;
@@ -35,7 +35,7 @@ $template = function()
 $version = function()
 {
 	$array = array();
-	$info = Dever::load('component/version-state');
+	$info = Dever::load('component_applet/version-state');
 	if($info)
 	{
 		$array += $info;
@@ -96,7 +96,7 @@ return array
 			'match' 	=> 'is_string',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
-			'list'		=> '"{name}" ? "{name}" : Dever::load("component/version-one#name", {version_id})',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("component_applet/version-one#name", {version_id})',
 		),
 
 		'user_id'		=> array

+ 3 - 3
component/database/revert.php → component/applet/database/revert.php

@@ -24,7 +24,7 @@ $user = function()
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;
@@ -35,7 +35,7 @@ $template = function()
 $version = function()
 {
 	$array = array();
-	$info = Dever::load('component/version-state');
+	$info = Dever::load('component_applet/version-state');
 	if($info)
 	{
 		$array += $info;
@@ -96,7 +96,7 @@ return array
 			'match' 	=> 'is_string',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
-			'list'		=> '"{name}" ? "{name}" : Dever::load("component/version-one#name", {version_id})',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("component_applet/version-one#name", {version_id})',
 		),
 
 		'user_id'		=> array

+ 2 - 2
component/database/tabbar.php → component/applet/database/tabbar.php

@@ -6,7 +6,7 @@
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;
@@ -17,7 +17,7 @@ $template = function()
 $page = function()
 {
 	$array = array();
-	$info = Dever::load('component/page-state');
+	$info = Dever::load('component_applet/page-state');
 	if($info)
 	{
 		$array += $info;

+ 0 - 0
component/database/template.php → component/applet/database/template.php


+ 2 - 2
component/database/tester.php → component/applet/database/tester.php

@@ -24,11 +24,11 @@ return array
 	(
 		'insert' => array
 		(
-			'component/tester.update',
+			'component_applet/tester.update',
 		),
 		'update' => array
 		(
-			'component/tester.update',
+			'component_applet/tester.update',
 		),
 	),
 	# 数据结构

+ 3 - 3
component/database/unaudit.php → component/applet/database/unaudit.php

@@ -24,7 +24,7 @@ $user = function()
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;
@@ -35,7 +35,7 @@ $template = function()
 $version = function()
 {
 	$array = array();
-	$info = Dever::load('component/version-state');
+	$info = Dever::load('component_applet/version-state');
 	if($info)
 	{
 		$array += $info;
@@ -96,7 +96,7 @@ return array
 			'match' 	=> 'is_string',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
-			'list'		=> '"{name}" ? "{name}" : Dever::load("component/version-one#name", {version_id})',
+			'list'		=> '"{name}" ? "{name}" : Dever::load("component_applet/version-one#name", {version_id})',
 		),
 
 		'user_id'		=> array

+ 7 - 7
component/database/version.php → component/applet/database/version.php

@@ -16,7 +16,7 @@ $user = function()
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;
@@ -36,11 +36,11 @@ return array
 	(
 		'insert' => array
 		(
-			'component/version.update',
+			'component_applet/version.update',
 		),
 		'update' => array
 		(
-			'component/version.update',
+			'component_applet/version.update',
 		),
 	),
 	# 数据结构
@@ -163,13 +163,13 @@ return array
 		(
 			'list' => array('日志', '"version_log&search_option_version_id={id}&oper_parent=version"'),
 
-			'oper' => array('提审', '"component/auditing.submit?id={id}"'),
+			'oper' => array('提审', '"component_applet/auditing.submit?id={id}"'),
 
-			'oper3' => array('撤回', '"component/unaudit.submit?id={id}"'),
+			'oper3' => array('撤回', '"component_applet/unaudit.submit?id={id}"'),
 
-			'oper1' => array('发布', '"component/publish.submit?id={id}"'),
+			'oper1' => array('发布', '"component_applet/publish.submit?id={id}"'),
 
-			'oper2' => array('回退', '"component/revert.submit?id={id}"'),
+			'oper2' => array('回退', '"component_applet/revert.submit?id={id}"'),
 		),
 	),
 );

+ 2 - 2
component/database/version_log.php → component/applet/database/version_log.php

@@ -16,7 +16,7 @@ $user = function()
 $template = function()
 {
 	$array = array();
-	$info = Dever::load('component/template-state');
+	$info = Dever::load('component_applet/template-state');
 	if($info)
 	{
 		$array += $info;
@@ -27,7 +27,7 @@ $template = function()
 $version = function()
 {
 	$array = array();
-	$info = Dever::load('component/version-state');
+	$info = Dever::load('component_applet/version-state');
 	if($info)
 	{
 		$array += $info;

+ 8 - 0
component/applet/index.php

@@ -0,0 +1,8 @@
+<?php
+define('DEVER_APP_NAME', 'component_applet');
+define('DEVER_APP_LIB', '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');
+include(DEVER_APP_PATH . '../../boot.php');

+ 8 - 7
component/src/Auditing.php → component/applet/src/Auditing.php

@@ -4,19 +4,20 @@
 | tester 体验者设置
 |--------------------------------------------------------------------------
 */
-namespace Component\Src;
+namespace Component\Applet\Src;
 
 use Dever;
 use Main\Lib\Wechat;
+use Component\Src\Core;
 
 class Auditing extends Core
 {
-	public $table = 'auditing';
+	public $table = 'component_applet/auditing';
 
 	public function submit()
 	{
 		$id = Dever::input('id');
-		$info = Dever::db('component/version')->one($id);
+		$info = Dever::db('component_applet/version')->one($id);
 		$user = explode(',', $info['user']);
 		foreach ($user as $k => $v) {
 			$param = array();
@@ -26,7 +27,7 @@ class Auditing extends Core
 			$param['name'] = $info['name'];
 			$param['status'] = 1;
 			$param['statusDesc'] = '审核中';
-			$id = Dever::upinto('component/auditing', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$id = Dever::upinto('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('提交成功,请到审核历史中查看审核状态');
@@ -40,7 +41,7 @@ class Auditing extends Core
      */
     public function cron()
     {
-        $data = Dever::db('component/auditing')->state();
+        $data = Dever::db('component_applet/auditing')->state();
         if ($data) {
         	$wechat = array();
         	foreach ($data as $k => $v) {
@@ -76,7 +77,7 @@ class Auditing extends Core
 
 					if ($update) {
 						$update['where_id'] = $v['id'];
-						Dever::db('component/auditing')->update($update);
+						Dever::db('component_applet/auditing')->update($update);
 					}
         		}
         	}
@@ -86,7 +87,7 @@ class Auditing extends Core
 	# 查看审核状态
 	public function view($id)
 	{
-		$info = Dever::db('component/auditing')->one($id);
+		$info = Dever::db('component_applet/auditing')->one($id);
 		$status = $info['status'];
 		$html = array();
 		if ($status == 2) {

+ 4 - 3
component/src/Domain.php → component/applet/src/Domain.php

@@ -4,18 +4,19 @@
 | domain 服务域名设置
 |--------------------------------------------------------------------------
 */
-namespace Component\Src;
+namespace Component\Applet\Src;
 
 use Dever;
 use Main\Lib\Wechat;
+use Component\Src\Core;
 
 class Domain extends Core
 {
-	public $table = 'domain';
+	public $table = 'component_applet/domain';
 
 	public function value($info)
 	{
-		$list = Dever::db('component/domain')->state(array('option_project_id' => $info['project_id']));
+		$list = Dever::db('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'])) {

+ 5 - 4
component/src/Publish.php → component/applet/src/Publish.php

@@ -4,19 +4,20 @@
 | tester 体验者设置
 |--------------------------------------------------------------------------
 */
-namespace Component\Src;
+namespace Component\Applet\Src;
 
 use Dever;
 use Main\Lib\Wechat;
+use Component\Src\Core;
 
 class Publish extends Core
 {
-	public $table = 'publish';
+	public $table = 'component_applet/publish';
 
 	public function submit()
 	{
 		$id = Dever::input('id');
-		$info = Dever::db('component/version')->one($id);
+		$info = Dever::db('component_applet/version')->one($id);
 		$user = explode(',', $info['user']);
 		foreach ($user as $k => $v) {
 			$param = array();
@@ -25,7 +26,7 @@ class Publish extends Core
 			$param['version_id'] = $info['id'];
 			$param['name'] = $info['name'];
 			$param['status'] = 1;
-			$id = Dever::upinto('component/publish', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$id = Dever::upinto('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('提交成功,请到发布历史中查看发布状态');

+ 5 - 4
component/src/Revert.php → component/applet/src/Revert.php

@@ -4,19 +4,20 @@
 | tester 体验者设置
 |--------------------------------------------------------------------------
 */
-namespace Component\Src;
+namespace Component\Applet\Src;
 
 use Dever;
 use Main\Lib\Wechat;
+use Component\Src\Core;
 
 class Revert extends Core
 {
-	public $table = 'revert';
+	public $table = 'component_applet/revert';
 
 	public function submit()
 	{
 		$id = Dever::input('id');
-		$info = Dever::db('component/version')->one($id);
+		$info = Dever::db('component_applet/version')->one($id);
 		$user = explode(',', $info['user']);
 		foreach ($user as $k => $v) {
 			$param = array();
@@ -25,7 +26,7 @@ class Revert extends Core
 			$param['version_id'] = $info['id'];
 			$param['name'] = $info['name'];
 			$param['status'] = 1;
-			$id = Dever::upinto('component/revert', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$id = Dever::upinto('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('提交成功,请到版本回退历史中查看回退状态');

+ 3 - 2
component/src/Tester.php → component/applet/src/Tester.php

@@ -4,14 +4,15 @@
 | tester 体验者设置
 |--------------------------------------------------------------------------
 */
-namespace Component\Src;
+namespace Component\Applet\Src;
 
 use Dever;
 use Main\Lib\Wechat;
+use Component\Src\Core;
 
 class Tester extends Core
 {
-	public $table = 'tester';
+	public $table = 'component_applet/tester';
 
 	public function handle($oauth, $info, $delete, $user, $wechat)
 	{

+ 5 - 4
component/src/Unaudit.php → component/applet/src/Unaudit.php

@@ -4,19 +4,20 @@
 | tester 体验者设置
 |--------------------------------------------------------------------------
 */
-namespace Component\Src;
+namespace Component\Applet\Src;
 
 use Dever;
 use Main\Lib\Wechat;
+use Component\Src\Core;
 
 class Unaudit extends Core
 {
-	public $table = 'unaudit';
+	public $table = 'component_applet/unaudit';
 
 	public function submit()
 	{
 		$id = Dever::input('id');
-		$info = Dever::db('component/version')->one($id);
+		$info = Dever::db('component_applet/version')->one($id);
 		$user = explode(',', $info['user']);
 		foreach ($user as $k => $v) {
 			$param = array();
@@ -25,7 +26,7 @@ class Unaudit extends Core
 			$param['version_id'] = $info['id'];
 			$param['name'] = $info['name'];
 			$param['status'] = 1;
-			$id = Dever::upinto('component/unaudit', array('option_user_id' => $v, 'option_project_id' => $param['project_id'], 'option_name' => $param['name']), $param);
+			$id = Dever::upinto('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('提交成功,请到审核撤回历史中查看撤回状态');

+ 7 - 6
component/src/Version.php → component/applet/src/Version.php

@@ -4,18 +4,19 @@
 | tester 体验者设置
 |--------------------------------------------------------------------------
 */
-namespace Component\Src;
+namespace Component\Applet\Src;
 
 use Dever;
 use Main\Lib\Wechat;
+use Component\Src\Core;
 
 class Version extends Core
 {
-	public $table = 'version';
+	public $table = 'component_applet/version';
 
 	public function handle($oauth, $info, $delete, $user, $wechat)
 	{
-		$template = Dever::db('component/template')->one($info['template_id']);
+		$template = Dever::db('component_applet/template')->one($info['template_id']);
 		$oauth['method'] = 'applet_commit';
 		$oauth['template_id'] = $template['template'] - 1;
 		$oauth['user_version'] = $info['name'];
@@ -24,9 +25,9 @@ class Version extends Core
 		$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']));
+		//$pageInfo = Dever::db('component_applet/page')->state(array('option_template_id' => $template['id']));
 
-		$pageInfo = Dever::db('component/page')->state();
+		$pageInfo = Dever::db('component_applet/page')->state();
 
 		$page = array();
 
@@ -38,7 +39,7 @@ class Version extends Core
 			}
 		}
 
-		$tabbar = Dever::db('component/tabbar')->state(array('option_template_id' => $template['id']));
+		$tabbar = Dever::db('component_applet/tabbar')->state(array('option_template_id' => $template['id']));
 		$tab = array();
 		if ($tabbar) {
 			$i = 0;

+ 0 - 5
component/config/base.php

@@ -7,10 +7,5 @@ $config['base'] = array
 	'top' => 'main/project_id-5',
 );
 
-# 模板配置
-$config['template'] = array
-(
-	
-);
 
 return $config;

+ 8 - 8
component/src/Core.php

@@ -17,7 +17,7 @@ class Core
 		if (isset($param['state']) && $param['state'] == 2) {
 			$delete = true;
 		}
-		$info = Dever::db('component/' . $this->table)->one($id);
+		$info = Dever::db($this->table)->one($id);
 		if (!$info) {
 			return;
 		}
@@ -65,7 +65,7 @@ class Core
 	{
 		$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'];
+			$table = $send['t'];
 			$info = Dever::db($table)->one($send['i']);
 			$wechat = new Wechat($info['project_id'], 'component');
 			$oauth = $wechat->oauth($send['o']);
@@ -82,7 +82,7 @@ class Core
 	public function log($table, $user, $info, $result, $method, $param)
 	{
 		print_r($result);
-		if ($table == 'component/version') {
+		if ($table == 'component_applet/version') {
 			$insert['user_id'] = $user;
 			$insert['name'] = $info['name'];
 			$insert['template_id'] = $info['template_id'];
@@ -90,7 +90,7 @@ class Core
 			$insert['version_id'] = $info['id'];
 			$insert['result'] = json_encode($result);
 			Dever::db($table . '_log')->insert($insert);
-		} elseif ($table == 'component/auditing') {
+		} elseif ($table == 'component_applet/auditing') {
 			if (isset($result['auditid'])) {
 				$update['auditid'] = $result['auditid'];
 			}
@@ -98,7 +98,7 @@ class Core
 			$update['result'] = json_encode($result);
 			$update['where_id'] = $info['id'];
 			Dever::db($table)->update($update);
-		} elseif ($table == 'component/publish' || $table == 'component/revert' || $table == 'component/unaudit') {
+		} elseif ($table == 'component_applet/publish' || $table == 'component_applet/revert' || $table == 'component_applet/unaudit') {
 			if ($result['errcode'] == 0) {
 				$update['status'] = 2;
 			} else {
@@ -109,16 +109,16 @@ class Core
 			$update['where_id'] = $info['id'];
 			Dever::db($table)->update($update);
 
-			if ($table == 'component/unaudit' && $update['status'] == 2) {
+			if ($table == '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('component/auditing')->all($audit);
+				$audit = Dever::db('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('component/auditing')->update($update);
+						Dever::db('component_applet/auditing')->update($update);
 					}
 				}
 			}

+ 7 - 61
component/src/Receive.php

@@ -116,69 +116,15 @@ class Receive
      */
     private function request()
     {
-		//$post = $_GET ? $_GET : $_POST;
-
-		$post = file_get_contents('php://input');
-
-/*
-		$post = ' <xml>
- <ToUserName><![CDATA[toUser]]></ToUserName>
- <FromUserName><![CDATA[ow29VvzICifpOTq_9EDGT3AhYpqg]]></FromUserName> 
- <CreateTime>1442067297</CreateTime>
- <MsgType><![CDATA[text]]></MsgType>
- <Content><![CDATA[dfd]]></Content>
- <MsgId>1311112322222222</MsgId>
- </xml>';
- 
- /*
-		$post = '<xml>
-<ToUserName><![CDATA[toUser]]></ToUserName>
-<FromUserName><![CDATA[FromUser]]></FromUserName>
-<CreateTime>123456789</CreateTime>
-<MsgType><![CDATA[event]]></MsgType>
-<Event><![CDATA[subscribe]]></Event>
-</xml>';
-
-
-		$post = ' <xml>
- <ToUserName><![CDATA[toUser]]></ToUserName>
- <FromUserName><![CDATA[ow29VvzICifpOTq_9EDGT3AhYpqg]]></FromUserName>
- <CreateTime>1442067297</CreateTime>
- <MsgType><![CDATA[image]]></MsgType>
- <PicUrl><![CDATA[http://mmbiz.qpic.cn/mmbiz/OxUBpiaYgpHiaDaiccrsX3MrFEVtjIfEAZk8zoJDZ4gXWWW2CIFic6Dicqndu23wMgA4Icg3yE4SRZg6L5jqanu9kvQ/0]]></PicUrl>
- <MediaId><![CDATA[media_id]]></MediaId>
- <MsgId>111</MsgId>
- </xml>';
-
- 		$post = '<xml>
-<ToUserName><![CDATA[toUser]]></ToUserName>
-<FromUserName><![CDATA[ow29VvzICifpOTq_9EDGT3AhYpqg]]></FromUserName>
-<CreateTime>1442067297</CreateTime>
-<MsgType><![CDATA[voice]]></MsgType>
-<MediaId><![CDATA[media_id]]></MediaId>
-<Format><![CDATA[Format]]></Format>
-<MsgId>23123213</MsgId>
-</xml>';
-
-
-		$post = '<xml>
-<ToUserName><![CDATA[toUser]]></ToUserName>
-<FromUserName><![CDATA[FromUser]]></FromUserName>
-<CreateTime>123456789</CreateTime>
-<MsgType><![CDATA[event]]></MsgType>
-<Event><![CDATA[CLICK]]></Event>
-<EventKey><![CDATA[EVENTKEY]]></EventKey>
-</xml>';
-*/
-		Dever::log(time());
-		if (!empty($post)) {
-			$post = json_encode($post);
-			Dever::log($post);
-			return;
+		$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($post, 'SimpleXMLElement', LIBXML_NOCDATA);
+          	$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);
+          	//$this->handle($result);
 		} else {
 			return false;
 		}

+ 16 - 0
service/config/base.php

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

+ 44 - 0
service/config/wechat.php

@@ -0,0 +1,44 @@
+<?php
+# 公众号基本配置
+$config['type'] = 2;
+
+$config['token'] = array
+(
+	'name' => '获取公众号的token',
+	'method' => 'get',
+	'json' => false,
+	'url' => 'https://api.weixin.qq.com/cgi-bin/token?',
+	'param' => array
+	(
+		'appid' => 'appid',
+		'secret' => 'secret',
+		'grant_type' => 'client_credential',
+	),
+	//针对一些返回的名称,做转换
+	'response' => array
+	(
+		'access_token' => 'token',
+		'expires_in' => 'expires_in',
+	),
+);
+
+$config['ticket'] = array
+(
+	'name' => '获取公众号的ticket',
+	'method' => 'get',
+	'json' => false,
+	'url' => 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?',
+	'param' => array
+	(
+		'type' => 'jsapi',
+		'access_token' => 'token',
+	),
+	//针对一些返回的名称,做转换
+	'response' => array
+	(
+		'jsapi_ticket' => 'ticket',
+		'expires_in' => 'expires_in',
+	),
+);
+
+return $config;

+ 7 - 0
service/index.php

@@ -0,0 +1,7 @@
+<?php
+define('DEVER_APP_NAME', 'service');
+define('DEVER_APP_LANG', '公众号');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 80);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-hdd');
+include(DEVER_APP_PATH . '../boot.php');

+ 75 - 0
service/src/Auth.php

@@ -0,0 +1,75 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| auth.php 用于做权限验证
+|--------------------------------------------------------------------------
+*/
+namespace Service\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(false, 'service');
+	}
+
+	/**
+     * 获取签名数据,主要用于jssdk
+     * 
+     * @return mixed
+     */
+	public function sign()
+	{
+		$url = Dever::input('url');
+		return $this->wechat->sign($url);
+	}
+
+	/**
+     * 获取ticket
+     * 
+     * @return mixed
+     */
+	public function ticket()
+	{
+		return $this->wechat->ticket(false, false, 2000, true);
+	}
+
+	/**
+     * 获取token 一般为系统token
+     * 
+     * @return mixed
+     */
+	public function token()
+	{
+		return $this->wechat->token(false, false, 2000, true);
+	}
+}

+ 30 - 0
share/assets/test.html

@@ -0,0 +1,30 @@
+<html lang="zh-CN">
+<head>
+	<title>test share</title>
+	<script src="http://cm.5dev.cn/dever_package/script/assets/lib/jquery/jquery.min.js" ></script>
+	<script src="http://cm.5dev.cn/dever_package/script/assets/lib/share/weixin.js" ></script>
+	<script src="http://cm.5dev.cn/dever_package/script/assets/dever/share.js" ></script>
+</head>
+
+<body>
+<a>分享</a>
+
+</body>
+
+<script>
+$(function()
+{
+	var uid = -1;
+	var project = 25;
+	var url = 'http://cm.5dev.cn/wechat/share/?api.';
+	var param = {
+		title : '大家好',
+        img : 'http://card_res.5dev.cn/1/2018/05/31/89f88317d56d94ff4e43b67edb019cee.jpg',
+        desc : '大家好',
+        url : location.href,
+	};
+	var button = false;
+	Dever.Share().Init(uid, project, url, param, button);
+})
+</script>
+</html>

+ 16 - 0
share/config/base.php

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

+ 167 - 0
share/database/collect.php

@@ -0,0 +1,167 @@
+<?php
+
+$type = array
+(
+	1 => '微信',
+	2 => '微博',
+);
+
+$actType = array
+(
+	1 => '分享给朋友',
+	2 => '分享到朋友圈',
+	3 => '分享到QQ',
+);
+
+$actResult = array
+(
+	1 => '分享成功',
+	2 => '取消分享',
+	3 => '分享失败',
+);
+
+$project = function()
+{
+	$array = array();
+	$info = Dever::load('main/project-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+return array
+(
+	# 表名
+	'name' => 'collect',
+	# 显示给用户看的名称
+	'lang' => '分享列表',
+	'order' => 90,
+	# 数据结构
+	'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',
+			'option'	=> $project,
+			'list'		=> true,
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户ID',
+			'default' 	=> '-1',
+			'desc' 		=> '用户ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'url'		=> array
+		(
+			'type' 		=> 'varchar-300',
+			'name' 		=> '分享地址',
+			'default' 	=> '',
+			'desc' 		=> '分享地址',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'ua'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '用户ua数据',
+			'default' 	=> '',
+			'desc' 		=> '用户ua数据',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+		),
+		
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '分享类型',
+			'default' 	=> '1',
+			'desc' 		=> '分享类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'search'	=> 'select',
+			'option'	=> $type,
+			'list'		=> true,
+		),
+
+		'actType'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '分享行为',
+			'default' 	=> '1',
+			'desc' 		=> '分享行为',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'search'	=> 'select',
+			'option'	=> $actType,
+			'list'		=> true,
+		),
+
+		'actResult'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '分享结果',
+			'default' 	=> '1',
+			'desc' 		=> '分享结果',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			//'search'	=> 'select',
+			'option'	=> $actResult,
+			'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' 		=> '',
+			'default' 	=> '',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	'manage' => array
+	(
+		'delete' => false,
+		'insert' => false,
+		'edit' => false,
+		# 开启批量管理
+		//'mul' => true,
+	),
+);

+ 126 - 0
share/database/reflux.php

@@ -0,0 +1,126 @@
+<?php
+
+$type = array
+(
+	1 => '微信',
+	2 => '微博',
+);
+
+$project = function()
+{
+	$array = array();
+	$info = Dever::load('main/project-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+return array
+(
+	# 表名
+	'name' => 'reflux',
+	# 显示给用户看的名称
+	'lang' => '回流列表',
+	'order' => 80,
+	# 数据结构
+	'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',
+			'option'	=> $project,
+			'list'		=> true,
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户ID',
+			'default' 	=> '-1',
+			'desc' 		=> '用户ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'url'		=> array
+		(
+			'type' 		=> 'varchar-300',
+			'name' 		=> '分享地址',
+			'default' 	=> '',
+			'desc' 		=> '分享地址',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'ua'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '用户ua数据',
+			'default' 	=> '',
+			'desc' 		=> '用户ua数据',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+			'modal'		=> '查看详情',
+		),
+
+		'param'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'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' 		=> '',
+			'default' 	=> '',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	'manage' => array
+	(
+		'delete' => false,
+		'insert' => false,
+		'edit' => false,
+		# 开启批量管理
+		//'mul' => true,
+	),
+);

+ 7 - 0
share/index.php

@@ -0,0 +1,7 @@
+<?php
+define('DEVER_APP_NAME', 'share');
+define('DEVER_APP_LANG', '分享');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 10);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-phone-alt');
+include(DEVER_APP_PATH . '../boot.php');

+ 61 - 0
share/src/Api.php

@@ -0,0 +1,61 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| data.php 分享相关接口
+|--------------------------------------------------------------------------
+*/
+namespace Share\Src;
+
+use Dever;
+
+class Api
+{
+	/**
+     * 获取签名数据,主要用于jssdk
+     * 
+     * @return mixed
+     */
+	public function init()
+	{
+		return Dever::load('service/auth.sign');
+	}
+
+	/**
+     * 分享数据
+     * 
+     * @return mixed
+     */
+	public function collect()
+	{
+		$data['project_id'] = Dever::input('project');
+		$data['url'] = urldecode(Dever::input('url'));
+		$data['actType'] = Dever::input('actType');
+		$data['actResult'] = Dever::input('actResult');
+		$data['ua'] = urldecode(Dever::input('ua'));
+		$data['uid'] = Dever::input('uid');
+		$data['type'] = Dever::input('type');
+
+		$id = Dever::db('share/collect')->insert($data);
+
+		return $id;
+	}
+
+	/**
+     * 回流数据
+     * 
+     * @return mixed
+     */
+	public function reflux()
+	{
+		$data['project_id'] = Dever::input('project');
+		$data['url'] = urldecode(Dever::input('url'));
+		$data['param'] = urldecode(Dever::input('param'));
+		$data['ua'] = urldecode(Dever::input('ua'));
+		$data['uid'] = Dever::input('uid');
+		$data['type'] = Dever::input('type');
+
+		$id = Dever::db('share/reflux')->insert($data);
+
+		return $id;
+	}
+}