dever 5 years ago
commit
83aa1ff8dd
6 changed files with 407 additions and 0 deletions
  1. 30 0
      assets/test.html
  2. 16 0
      config/base.php
  3. 167 0
      database/collect.php
  4. 126 0
      database/reflux.php
  5. 7 0
      index.php
  6. 61 0
      src/Api.php

+ 30 - 0
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/js/lib/jquery.min.js" ></script>
+	<script src="http://cm.5dev.cn/dever_package/script/assets/js/share/weixin.js" ></script>
+	<script src="http://cm.5dev.cn/dever_package/script/assets/js/dever.js?v1" ></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
config/base.php

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

+ 167 - 0
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('token/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
database/reflux.php

@@ -0,0 +1,126 @@
+<?php
+
+$type = array
+(
+	1 => '微信',
+	2 => '微博',
+);
+
+$project = function()
+{
+	$array = array();
+	$info = Dever::load('token/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
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 layui-icon-website');
+include(DEVER_APP_PATH . '../boot.php');

+ 61 - 0
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('wechat_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;
+	}
+}