Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
52f6bd7d
Commit
52f6bd7d
authored
Jan 16, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit
parent
b0585786
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
253 additions
and
397 deletions
+253
-397
Auth.php
application/index/controller/Auth.php
+25
-3
AuthUntils.php
application/index/untils/AuthUntils.php
+140
-75
index.html
application/index/view/auth/index.html
+22
-0
navigation.html
application/index/view/global/navigation.html
+8
-5
AuthGroup.php
application/model/AuthGroup.php
+28
-38
AuthGroupAccess.php
application/model/AuthGroupAccess.php
+0
-2
auth.js
public/resource/js/auth.js
+16
-258
auth_template_tpl.html
public/resource/template/auth_template_tpl.html
+14
-16
No files found.
application/index/controller/Auth.php
View file @
52f6bd7d
<?php
/**
* Created by PhpStorm.
* User:
fuju
* User:
hujun
* Date: 2018/1/16
* Time: 13:51
*/
namespace
app\index\controller
;
class
Auth
use
app\index\extend\Basic
;
use
app\index\untils\AuthUntils
;
use
app\model\AuthGroup
;
class
Auth
extends
Basic
{
/**
* 权限列表页
*
* @return type
*/
public
function
index
(){
return
view
(
'index'
);
}
public
function
getAuth
()
{
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
''
;
$params
=
$this
->
request
->
param
();
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$auth_group
=
New
AuthGroup
();
$data
=
$auth_group
->
getList
(
$pageNo
,
$pageSize
,
''
,
'*'
);
return
$this
->
response
(
200
,
''
,
$data
);
}
}
\ No newline at end of file
application/index/untils/AuthUntils.php
View file @
52f6bd7d
...
...
@@ -8,13 +8,13 @@
// +----------------------------------------------------------------------
// | Author: luofei614 <weibo.com/luofei614>
// +----------------------------------------------------------------------
namespace
app\index\u
til
;
namespace
app\index\u
ntils
;
use
think\Db
;
use
think\Config
;
use
think\Session
;
use
think\Request
;
use
think\Loader
;
use
think\Loader
;
/**
* 权限认证类
...
...
@@ -72,132 +72,189 @@ DROP TABLE IF EXISTS `think_auth_group_access`;
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
*/
class
Auth
{
class
AuthUntils
{
/**
* @var object 对象实例
*/
protected
static
$instance
;
/**
* 当前请求实例
* @var Request
*/
protected
$request
;
//默认配置
protected
$
_config
=
array
(
'auth_on'
=>
true
,
// 认证
开关
'auth_type'
=>
1
,
// 认证方式,1为实时认证;2为登录认证。
'auth_group'
=>
'__AUTH_GROUP__
'
,
// 用户组数据表名
protected
$
config
=
[
'auth_on'
=>
1
,
// 权限
开关
'auth_type'
=>
1
,
// 认证方式,1为实时认证;2为登录认证。
'auth_group'
=>
'auth_group
'
,
// 用户组数据表名
'auth_group_access'
=>
'auth_group_access'
,
// 用户-用户组关系表
'auth_rule'
=>
'auth_rule'
,
// 权限规则表
'auth_user'
=>
'member'
// 用户信息表
);
'auth_rule'
=>
'auth_rule'
,
// 权限规则表
'auth_user'
=>
'agents'
,
// 用户信息表
];
/**
* 类架构函数
* Auth constructor.
*/
public
function
__construct
()
{
//可设置配置项 auth, 此配置项为数组。
if
(
$auth
=
Config
::
get
(
'auth'
))
{
$this
->
config
=
array_merge
(
$this
->
config
,
$auth
);
}
// 初始化request
$this
->
request
=
Request
::
instance
();
}
public
function
__construct
()
{
$t
=
config
(
'auth_config'
);
if
(
config
(
'auth_config'
))
{
//可设置配置项 auth_config, 此配置项为数组。
$this
->
_config
=
array_merge
(
$this
->
_config
,
config
(
'auth_config'
));
/**
* 初始化
* @access public
* @param array $options 参数
* @return \think\Request
*/
public
static
function
instance
(
$options
=
[])
{
if
(
is_null
(
self
::
$instance
))
{
self
::
$instance
=
new
static
(
$options
);
}
return
self
::
$instance
;
}
/**
* 检查权限
* @param name string|array 需要验证的规则列表,支持逗号分隔的权限规则或索引数组
* @param uid int 认证用户的id
* @param string mode 执行check的模式
* @param relation string 如果为 'or' 表示满足任一条规则即通过验证;如果为 'and'则表示需满足所有规则才能通过验证
* @return boolean 通过验证返回true;失败返回false
* @param $name string|array 需要验证的规则列表,支持逗号分隔的权限规则或索引数组
* @param $uid int 认证用户的id
* @param int $type 认证类型
* @param string $mode 执行check的模式
* @param string $relation 如果为 'or' 表示满足任一条规则即通过验证;如果为 'and'则表示需满足所有规则才能通过验证
* @return bool 通过验证返回true;失败返回false
*/
public
function
check
(
$name
,
$uid
,
$type
=
1
,
$mode
=
'url'
,
$relation
=
'or'
)
{
if
(
!
$this
->
_config
[
'auth_on'
])
public
function
check
(
$name
,
$uid
,
$type
=
1
,
$mode
=
'url'
,
$relation
=
'or'
)
{
if
(
!
$this
->
config
[
'auth_on'
])
{
return
true
;
}
$count
=
Db
::
name
(
$this
->
config
[
'auth_rule'
])
->
where
(
'name'
,
$name
)
->
count
();
if
(
$count
==
0
)
{
return
true
;
$authList
=
$this
->
getAuthList
(
$uid
,
$type
);
//获取用户需要验证的所有有效规则列表
}
// 获取用户需要验证的所有有效规则列表
$authList
=
$this
->
getAuthList
(
$uid
,
$type
);
if
(
is_string
(
$name
))
{
$name
=
strtolower
(
$name
);
if
(
strpos
(
$name
,
','
)
!==
false
)
{
$name
=
explode
(
','
,
$name
);
}
else
{
$name
=
array
(
$name
)
;
$name
=
[
$name
]
;
}
}
$list
=
array
()
;
//保存验证通过的规则名
if
(
$mode
==
'url'
)
{
$REQUEST
=
unserialize
(
strtolower
(
serialize
(
$
_REQUEST
)));
$list
=
[]
;
//保存验证通过的规则名
if
(
'url'
==
$mode
)
{
$REQUEST
=
unserialize
(
strtolower
(
serialize
(
$
this
->
request
->
param
()
)));
}
foreach
(
$authList
as
$auth
)
{
$query
=
preg_replace
(
'/^.+\?/U'
,
''
,
$auth
);
if
(
$mode
==
'url'
&&
$query
!=
$auth
)
{
if
(
'url'
==
$mode
&&
$query
!=
$auth
)
{
parse_str
(
$query
,
$param
);
//解析规则中的param
$intersect
=
array_intersect_assoc
(
$REQUEST
,
$param
);
$auth
=
preg_replace
(
'/\?.*$/U'
,
''
,
$auth
);
if
(
in_array
(
$auth
,
$name
)
&&
$intersect
==
$param
)
{
//如果节点相符且url参数满足
$auth
=
preg_replace
(
'/\?.*$/U'
,
''
,
$auth
);
if
(
in_array
(
$auth
,
$name
)
&&
$intersect
==
$param
)
{
//如果节点相符且url参数满足
$list
[]
=
$auth
;
}
}
else
{
if
(
in_array
(
$auth
,
$name
))
{
$list
[]
=
$auth
;
}
}
else
if
(
in_array
(
$auth
,
$name
))
{
$list
[]
=
$auth
;
}
}
if
(
$relation
==
'or'
and
!
empty
(
$list
))
{
if
(
'or'
==
$relation
&&
!
empty
(
$list
))
{
return
true
;
}
$diff
=
array_diff
(
$name
,
$list
);
if
(
$relation
==
'and'
and
empty
(
$diff
))
{
if
(
'and'
==
$relation
&&
empty
(
$diff
))
{
return
true
;
}
return
false
;
}
/**
* 根据用户id获取用户组,返回值为数组
* @param uid int 用户id
* @param
$
uid int 用户id
* @return array 用户所属的用户组 array(
* array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
* ...)
*
array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
*
...)
*/
public
function
getGroups
(
$uid
)
{
static
$groups
=
array
();
if
(
isset
(
$groups
[
$uid
]))
public
function
getGroups
(
$uid
=
''
)
{
static
$groups
=
[];
if
(
isset
(
$groups
[
$uid
]))
{
return
$groups
[
$uid
];
$user_groups
=
\think\Db
::
name
(
$this
->
_config
[
'auth_group_access'
])
->
alias
(
'a'
)
->
join
(
$this
->
_config
[
'auth_group'
]
.
" g"
,
"g.id=a.group_id"
)
->
where
(
"a.uid='
$uid
' and g.status='1'"
)
->
field
(
'uid,group_id,title,rules'
)
->
select
();
$groups
[
$uid
]
=
$user_groups
?
$user_groups
:
array
();
}
// 转换表名
$auth_group_access
=
Loader
::
parseName
(
$this
->
config
[
'auth_group_access'
],
0
);
$auth_group
=
Loader
::
parseName
(
$this
->
config
[
'auth_group'
],
0
);
// 执行查询
// $user_groups = Db::view($auth_group_access, 'uid,group_id')
// ->view($auth_group, 'title,rules', "{$auth_group_access}.group_id={$auth_group}.id", 'LEFT')
// ->where("{$auth_group_access}.uid='{$uid}' and {$auth_group}.status='1'")
// ->select();
$user_groups
=
Db
::
name
(
$auth_group_access
)
->
alias
(
'a'
)
->
where
(
"a.uid='
$uid
' and g.status='1'"
)
->
join
(
$auth_group
.
' g'
,
'a.group_id=g.id'
)
->
select
();
$groups
[
$uid
]
=
$user_groups
?:
[];
return
$groups
[
$uid
];
}
/**
* 获得权限列表
* @param integer $uid
用户id
* @param integer $uid 用户id
* @param integer $type
* @return array
*/
protected
function
getAuthList
(
$uid
,
$type
)
{
static
$_authList
=
array
();
//保存用户验证通过的权限列表
$t
=
implode
(
','
,
(
array
)
$type
);
protected
function
getAuthList
(
$uid
,
$type
)
{
static
$_authList
=
[];
//保存用户验证通过的权限列表
$t
=
implode
(
','
,
(
array
)
$type
);
if
(
isset
(
$_authList
[
$uid
.
$t
]))
{
return
$_authList
[
$uid
.
$t
];
}
if
(
$this
->
_config
[
'auth_type'
]
==
2
&&
isset
(
$_SESSION
[
'_auth_list_'
.
$uid
.
$t
]
))
{
return
$_SESSION
[
'_auth_list_'
.
$uid
.
$t
]
;
if
(
2
==
$this
->
config
[
'auth_type'
]
&&
Session
::
has
(
'_auth_list_'
.
$uid
.
$t
))
{
return
Session
::
get
(
'_auth_list_'
.
$uid
.
$t
)
;
}
//读取用户所属用户组
$groups
=
$this
->
getGroups
(
$uid
);
$ids
=
array
()
;
//保存用户所属用户组设置的所有权限规则id
$ids
=
[]
;
//保存用户所属用户组设置的所有权限规则id
foreach
(
$groups
as
$g
)
{
$ids
=
array_merge
(
$ids
,
explode
(
','
,
trim
(
$g
[
'rules'
],
','
)));
}
$ids
=
array_unique
(
$ids
);
if
(
empty
(
$ids
))
{
$_authList
[
$uid
.
$t
]
=
array
()
;
return
array
();
}
$map
=
array
(
'id'
=>
array
(
'in'
,
$ids
),
'
type'
=>
$type
,
'
status'
=>
1
,
)
;
$_authList
[
$uid
.
$t
]
=
[]
;
return
[];
}
$map
=
[
'
id'
=>
[
'in'
,
$ids
]
,
'
type'
=>
$type
]
;
//读取用户组所有权限规则
$rules
=
\think\Db
::
name
(
$this
->
_
config
[
'auth_rule'
])
->
where
(
$map
)
->
field
(
'condition,name'
)
->
select
();
$rules
=
Db
::
name
(
$this
->
config
[
'auth_rule'
])
->
where
(
$map
)
->
field
(
'condition,name'
)
->
select
();
//循环规则,判断结果。
$authList
=
array
();
//
$authList
=
[];
//
foreach
(
$rules
as
$rule
)
{
if
(
!
empty
(
$rule
[
'condition'
]))
{
//根据condition进行验证
$user
=
$this
->
getUserInfo
(
$uid
);
//获取用户信息,一维数组
if
(
!
empty
(
$rule
[
'condition'
]))
{
//根据condition进行验证
$user
=
$this
->
getUserInfo
(
$uid
);
//获取用户信息,一维数组
$command
=
preg_replace
(
'/\{(\w*?)\}/'
,
'$user[\'\\1\']'
,
$rule
[
'condition'
]);
//dump($command);//debug
@
(
eval
(
'$condition=('
.
$command
.
');'
));
if
(
$condition
)
{
$authList
[]
=
strtolower
(
$rule
[
'name'
]);
...
...
@@ -208,22 +265,30 @@ class Auth {
}
}
$_authList
[
$uid
.
$t
]
=
$authList
;
if
(
$this
->
_config
[
'auth_type'
]
==
2
)
{
if
(
2
==
$this
->
config
[
'auth_type'
]
)
{
//规则列表结果保存到session
$_SESSION
[
'_auth_list_'
.
$uid
.
$t
]
=
$authList
;
Session
::
set
(
'_auth_list_'
.
$uid
.
$t
,
$authList
)
;
}
return
array_unique
(
$authList
);
}
/**
* 获得用户资料,根据自己的情况读取数据库
* 获得用户资料
* @param $uid
* @return mixed
*/
protected
function
getUserInfo
(
$uid
)
{
static
$userinfo
=
array
();
if
(
!
isset
(
$userinfo
[
$uid
]))
{
$userinfo
[
$uid
]
=
\think\Db
::
name
(
$this
->
_config
[
'auth_user'
])
->
where
(
array
(
'uid'
=>
$uid
))
->
find
();
protected
function
getUserInfo
(
$uid
)
{
static
$user_info
=
[];
$user
=
Db
::
name
(
$this
->
config
[
'auth_user'
]);
// 获取用户表主键
$_pk
=
is_string
(
$user
->
getPk
())
?
$user
->
getPk
()
:
'uid'
;
if
(
!
isset
(
$user_info
[
$uid
]))
{
$user_info
[
$uid
]
=
$user
->
where
(
$_pk
,
$uid
)
->
find
();
}
return
$userinfo
[
$uid
];
}
return
$user_info
[
$uid
];
}
}
application/index/view/auth/index.html
0 → 100644
View file @
52f6bd7d
{layout name="global/frame_tpl" /}
<input
type=
"hidden"
class=
"page-load"
id=
"auth"
/>
<div
id=
"page-content-wrapper"
>
<div
class=
"container"
>
<div
class=
"col-lg-10 col-lg-offset-0"
>
<table
class=
"table table-responsive table-bordered table-hover dataTable"
>
<thead>
<tr>
<th
class=
"text-center"
>
ID
</th>
<th
class=
"text-center"
>
角色名
</th>
<th
class=
"text-center"
>
描述
</th>
<th
class=
"text-center"
>
状态
</th>
<th
class=
"text-center"
>
操作
</th>
</tr>
</thead>
<tbody
id=
"auth_list"
>
</tbody>
</table>
</div>
</div>
</div>
\ No newline at end of file
application/index/view/global/navigation.html
View file @
52f6bd7d
...
...
@@ -18,20 +18,23 @@
<!--</ul>-->
<!--</li>-->
<li
role=
"presentation"
class=
"active"
>
<a
href=
"/admin.php/index/banner"
>
首页轮播图
</a>
<a
href=
"/admin.php/index/banner
.html
"
>
首页轮播图
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/users_list"
>
用户列表
</a>
<a
href=
"/admin.php/index/users_list
.html
"
>
用户列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/watch_shop"
>
预约看铺列表
</a>
<a
href=
"/admin.php/index/watch_shop
.html
"
>
预约看铺列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/transfer_list"
>
委托转铺列表
</a>
<a
href=
"/admin.php/index/transfer_list
.html
"
>
委托转铺列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/version"
>
版本号管理
</a>
<a
href=
"/admin.php/index/version.html"
>
版本号管理
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/auth.html"
>
权限管理
</a>
</li>
</ul>
...
...
application/model/AuthGroup.php
View file @
52f6bd7d
<?php
// 权限模型
// +----------------------------------------------------------------------
// | Copyright (c) 2016-2017 http://www.eacoo123.com, All rights reserved.
// +----------------------------------------------------------------------
// | [EacooPHP] 并不是自由软件,可免费使用,未经许可不能去掉EacooPHP相关版权。
// | 禁止在EacooPHP整体或任何部分基础上发展任何派生、修改或第三方版本用于重新分发
// +----------------------------------------------------------------------
// | Author: 心云间、凝听 <981248356@qq.com>
// +----------------------------------------------------------------------
namespace
app\admin\model
;
// 权限模型
use
app\common\model\Base
;
class
AuthGroup
extends
Base
namespace
app\model
;
use
think\Model
;
class
AuthGroup
extends
Model
{
const
TYPE_ADMIN
=
1
;
// 管理员用户组类型标识
const
MEMBER
=
'
user
s'
;
const
MEMBER
=
'
agent
s'
;
const
AUTH_GROUP_ACCESS
=
'auth_group_access'
;
// 关系表表名
const
AUTH_EXTEND
=
'auth_extend'
;
// 动态权限扩展信息表
const
AUTH_GROUP
=
'auth_group'
;
// 用户组表名
const
AUTH_EXTEND_CATEGORY_TYPE
=
1
;
// 分类权限标识
const
AUTH_EXTEND_MODEL_TYPE
=
2
;
//分类权限标识
// 定义时间戳字段名
protected
$createTime
=
''
;
protected
$updateTime
=
''
;
protected
$insert
=
[
'status'
=>
1
];
/**
...
...
@@ -34,7 +19,6 @@ class AuthGroup extends Base
* 默认返回正常状态的管理员用户组列表
* @param array $where 查询条件,供where()方法使用
*
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
public
function
getGroups
(
$where
=
array
()){
$map
=
array
(
'status'
=>
1
);
...
...
@@ -44,7 +28,6 @@ class AuthGroup extends Base
/**
* 把用户添加到用户组,支持批量添加用户到用户组
* @author 朱亚杰 <zhuyajie@topthink.net>
*
* 示例: 把uid=1的用户添加到group_id为1,2的组 `AuthGroupModel->addToGroup(1,'1,2');`
*/
...
...
@@ -73,15 +56,6 @@ class AuthGroup extends Base
}
}
// $user_auth_role = db('users')->where(array('uid'=>$u))->value('auth_groups');
// if ($user_auth_role) {
// $user_auth_role = explode(',', $user_auth_role);
// $user_auth_role = array_merge($user_auth_role,$gid);
// } else{
// $user_auth_role = $gid;
// }
// db('users')->where(array('uid'=>$u))->update(['auth_groups',implode(',',$user_auth_role)]);//同时将用户角色关联(16/07/06新增)
}
if
(
!
empty
(
$add
)
&&
is_array
(
$add
))
{
...
...
@@ -129,7 +103,6 @@ class AuthGroup extends Base
* 将用户从用户组中移除
* @param int|string|array $gid 用户组id
* @param int|string|array $cid 分类id
* @author 朱亚杰 <xcoolcc@gmail.com>
*/
public
function
removeFromGroup
(
$uid
,
$gid
){
$del_result
=
model
(
self
::
AUTH_GROUP_ACCESS
)
->
where
(
array
(
'uid'
=>
$uid
,
'group_id'
=>
$gid
)
)
->
delete
();
...
...
@@ -143,12 +116,11 @@ class AuthGroup extends Base
}
return
$del_result
;
}
/**
/**
* 获取某个用户组的用户列表
*
* @param int $group_id 用户组id
*
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
static
public
function
userInGroup
(
$group_id
){
$prefix
=
config
(
'database.prefix'
);
...
...
@@ -165,7 +137,6 @@ class AuthGroup extends Base
/**
* 检查id是否全部存在
* @param array|string $gid 用户组id列表
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
public
function
checkId
(
$modelname
,
$mid
,
$msg
=
'以下id不存在:'
){
if
(
is_array
(
$mid
)){
...
...
@@ -186,12 +157,31 @@ class AuthGroup extends Base
return
false
;
}
}
/**
/**
* 检查用户组是否全部存在
* @param array|string $gid 用户组id列表
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
public
function
checkGroupId
(
$gid
){
return
$this
->
checkId
(
'AuthGroup'
,
$gid
,
'以下用户组id不存在:'
);
}
/**
* 返回权限分组
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
* @param type $field
* @param type $params
* @return type
*/
public
function
getList
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'id desc'
,
$field
=
''
,
$params
=
''
)
{
return
$this
->
field
(
$field
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
}
}
application/model/AuthGroupAccess.php
View file @
52f6bd7d
...
...
@@ -3,8 +3,6 @@
namespace
app\admin\model
;
use
think\Model
;
class
AuthGroupAccess
extends
Base
{
// 设置完整的数据表(包含前缀)
...
...
public/resource/js/auth.js
View file @
52f6bd7d
define
([
'doT'
,
'text!temp/
watc
h_template_tpl.html'
,
'css!style/home.css'
,
'pagination'
,
'bootstrapJs'
],
function
(
doT
,
template
)
{
user
=
{
define
([
'doT'
,
'text!temp/
aut
h_template_tpl.html'
,
'css!style/home.css'
,
'pagination'
,
'bootstrapJs'
],
function
(
doT
,
template
)
{
auth
=
{
pageNo
:
1
,
/*第几页*/
pageSize
:
10
,
/*每页显示多少条*/
father_id
:
''
,
agents_id
:
''
,
watch_id
:
''
,
urls
:
''
,
init
:
function
()
{
;(
function
(
$
){
$
.
fn
.
datetimepicker
.
dates
[
'zh-CN'
]
=
{
days
:
[
"星期日"
,
"星期一"
,
"星期二"
,
"星期三"
,
"星期四"
,
"星期五"
,
"星期六"
,
"星期日"
],
daysShort
:
[
"周日"
,
"周一"
,
"周二"
,
"周三"
,
"周四"
,
"周五"
,
"周六"
,
"周日"
],
daysMin
:
[
"日"
,
"一"
,
"二"
,
"三"
,
"四"
,
"五"
,
"六"
,
"日"
],
months
:
[
"01"
,
"02"
,
"03"
,
"04"
,
"05"
,
"06"
,
"07"
,
"08"
,
"09"
,
"10"
,
"11"
,
"12"
],
monthsShort
:
[
"01"
,
"02"
,
"03"
,
"04"
,
"05"
,
"06"
,
"07"
,
"08"
,
"09"
,
"10"
,
"11"
,
"12"
],
today
:
"今日"
,
suffix
:
[],
meridiem
:
[
"am"
,
"pm"
],
weekStart
:
1
,
};
}(
jQuery
));
$
(
'.form_datetime'
).
datetimepicker
({
//language: 'fr',
weekStart
:
1
,
todayBtn
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
startView
:
2
,
forceParse
:
0
,
showMeridian
:
1
});
$
(
'.form_date'
).
datetimepicker
({
language
:
'zh-CN'
,
weekStart
:
1
,
todayBtn
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
startView
:
2
,
minView
:
2
,
forceParse
:
0
});
$
(
'.form_time'
).
datetimepicker
({
language
:
'zh-CN'
,
weekStart
:
1
,
todayBtn
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
startView
:
1
,
minView
:
0
,
maxView
:
1
,
forceParse
:
0
});
//初始化dot
$
(
"body"
).
append
(
template
);
user
.
getList
();
user
.
event
();
auth
.
getList
();
auth
.
event
();
},
event
:
function
()
{
$
(
"#form_search_reset"
).
click
(
function
()
{
document
.
getElementById
(
"form_search"
).
reset
();
});
$
(
"#search"
).
click
(
function
()
{
user
.
getList
(
1
);
});
$
(
"#submit_follow"
).
click
(
function
()
{
user
.
addFollow
();
});
$
(
'#datetimepicker'
).
datetimepicker
({
format
:
'yyyy-MM-dd'
,
language
:
'zh-CN'
,
pickTime
:
false
}).
on
(
'changeDate'
,
function
(){
$
(
this
).
datetimepicker
(
'hide'
);
});
$
(
document
).
delegate
(
".phone_jia"
,
"click"
,
function
()
{
/*手机检索姓名*/
var
ldHtml
=
$
(
'.phone_list'
);
var
stopstatus
=
true
;
var
valueCurrent
=
''
;
var
ajaxObj
;
$
(
function
()
{
$
(
document
).
on
(
'input'
,
'.phone_jia'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
var
_this
=
$
(
this
);
_this
.
next
().
css
(
"display"
,
"block"
);
valueCurrent
=
_this
.
val
();
if
(
valueCurrent
!=
''
){
resetLoad
();
loadMain
(
valueCurrent
,
_this
.
next
());
}
else
{
ldHtml
.
html
(
''
);
return
false
;
}
});
});
function
resetLoad
(){
if
(
ajaxObj
){
ajaxObj
.
abort
();
}
ldHtml
.
html
(
''
);
stopstatus
=
true
;
}
function
loadMain
(
phone
,
obj
)
{
ajaxObj
=
$
.
ajax
({
type
:
"GET"
,
url
:
'/index/getBroker'
,
data
:
{
'phone'
:
phone
},
timeout
:
10000
,
dataType
:
"json"
,
beforeSend
:
function
()
{
},
success
:
function
(
data
)
{
if
(
data
.
code
===
200
){
$
(
"#agents_list"
).
show
();
var
_html
=
''
;
$
.
each
(
data
.
data
,
function
(
i
,
data
)
{
_html
+=
'<li class="addphone"><span class="id">'
+
data
[
'id'
]
+
'-</span><span class="phone_name">'
+
data
[
'realname'
]
+
'</span><span class="phone_span">-</span><span class="phone-phone">'
+
data
[
'phone'
]
+
'</span><span class="hidden father_id">'
+
data
[
'father_id'
]
+
'</span></li>'
;
});
$
(
"#agents_list"
).
html
(
_html
);
}
},
error
:
function
()
{
},
complete
:
function
(
xhr
,
textStatus
)
{
if
(
textStatus
===
"timeout"
)
{
/*处理超时的逻辑*/
alert
(
"请求超时"
);
}
}
});
}
});
/*选择经纪人*/
$
(
document
).
delegate
(
".addphone"
,
"click"
,
function
()
{
user
.
addphone
(
$
(
this
));
});
$
(
document
).
delegate
(
".add_applies"
,
"click"
,
function
()
{
user
.
watch_id
=
$
(
this
).
attr
(
"data-id"
);
$
(
"input[name='phone']"
).
val
(
''
);
});
$
(
document
).
delegate
(
"#submit_applies"
,
"click"
,
function
()
{
if
(
$
(
'input[name="phone"]'
).
val
()
==
''
)
{
alert
(
'报备人信息不能为空'
);
return
;
}
var
params
=
{};
params
.
shop_id
=
user
.
father_id
;
params
.
agents_id
=
user
.
agents_id
;
params
.
watch_id
=
user
.
watch_id
;
$
.
ajax
({
url
:
'/index/add_applies'
,
type
:
'POST'
,
async
:
true
,
data
:
params
,
dataType
:
'json'
,
success
:
function
(
data
)
{
if
(
data
.
code
==
200
)
{
alert
(
data
.
msg
);
$
(
"#modal-watch"
).
modal
(
'hide'
);
user
.
getList
(
1
);
}
else
{
alert
(
data
.
msg
);
}
}
});
});
},
getList
:
function
(
pageNo
)
{
user
.
pageNo
=
pageNo
;
auth
.
pageNo
=
pageNo
;
var
params
=
{};
params
.
start_date
=
$
(
"#start_date"
).
val
();
params
.
end_date
=
$
(
"#end_date"
).
val
();
params
.
name
=
$
(
"#name"
).
val
();
params
.
phone
=
$
(
"#phone"
).
val
();
params
.
shop_name
=
$
(
"#shop_name"
).
val
();
params
.
pageNo
=
user
.
pageNo
;
params
.
pageSize
=
user
.
pageSize
;
params
.
pageNo
=
auth
.
pageNo
;
params
.
pageSize
=
auth
.
pageSize
;
$
.
ajax
({
url
:
'/index/get
_watch
'
,
url
:
'/index/get
Auth.html
'
,
type
:
'GET'
,
async
:
true
,
async
:
true
,
data
:
params
,
dataType
:
'json'
,
success
:
function
(
data
)
{
var
temp
=
document
.
getElementById
(
'
watc
h_list_tpl'
).
innerHTML
;
var
temp
=
document
.
getElementById
(
'
aut
h_list_tpl'
).
innerHTML
;
var
doTtmpl
=
doT
.
template
(
temp
);
$
(
"#
sublet_list"
).
html
(
doTtmpl
(
data
.
data
.
list
));
$
(
"#
auth_list"
).
html
(
doTtmpl
(
data
.
data
));
/*分页代码*/
$
(
"#pagediv"
).
pagination
({
length
:
data
.
data
.
total
,
current
:
pageNo
,
every
:
user
.
pageSize
,
every
:
auth
.
pageSize
,
onClick
:
function
(
el
)
{
user
.
getList
(
el
.
num
.
current
);
auth
.
getList
(
el
.
num
.
current
);
}
});
}
});
},
addFollow
:
function
()
{
var
params
=
{};
params
.
type
=
2
;
params
.
id
=
id
;
params
.
content
=
$
(
"#content"
).
val
();
$
.
ajax
({
url
:
'/index/addFollow'
,
type
:
'POST'
,
async
:
true
,
data
:
params
,
dataType
:
'json'
,
success
:
function
(
data
)
{
if
(
data
.
code
==
200
)
{
$
(
"#modal-process"
).
modal
(
'hide'
);
}
else
{
alert
(
data
.
msg
);
}
}
});
},
addphone
:
function
(
obj
)
{
var
phone_name
=
$
(
obj
).
find
(
".phone_name"
).
html
();
var
phone_phone
=
$
(
obj
).
find
(
".phone-phone"
).
html
();
var
phone_span
=
$
(
obj
).
find
(
".phone_span"
).
html
();
var
id
=
$
(
obj
).
find
(
".id"
).
html
();
var
val
=
id
+
phone_name
+
phone_span
+
phone_phone
;
user
.
father_id
=
$
(
obj
).
find
(
".father_id"
).
html
();
user
.
agents_id
=
id
.
substring
(
0
,
id
.
length
-
1
)
$
(
"input[name='phone']"
).
val
(
val
);
$
(
obj
).
parent
().
hide
();
$
(
"#agents_list"
).
html
(
''
);
return
;
}
};
return
user
;
});
var
id
;
function
alertFollow
(
obj
){
id
=
$
(
obj
).
attr
(
"data-id"
);
$
(
"#content"
).
val
(
''
);
$
.
ajax
({
url
:
'/index/followList'
,
type
:
'GET'
,
async
:
true
,
data
:
{
"id"
:
id
,
"type"
:
2
},
dataType
:
'json'
,
success
:
function
(
data
)
{
if
(
data
.
code
==
200
)
{
var
str
=
''
;
$
.
each
(
data
.
data
,
function
(
i
,
item
)
{
str
+=
"<tr><td>"
+
item
[
'content'
]
+
"</td><td>"
+
item
[
'admin_name'
]
+
"</td><td>"
+
item
[
'create_time'
]
+
"</td></tr>"
;
$
(
"#list_follow"
).
html
(
str
);
});
}
else
{
alert
(
data
.
msg
);
}
}
});
}
return
auth
;
});
\ No newline at end of file
public/resource/template/auth_template_tpl.html
View file @
52f6bd7d
<script
id=
"
watc
h_list_tpl"
type=
"text/template"
>
<script
id=
"
aut
h_list_tpl"
type=
"text/template"
>
[
%
if
(
it
)
{
%
]
[
%
for
(
var
item
in
it
){
%
]
<
tr
>
<
td
>
[
%=
it
[
item
][
'house_title'
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
'appellation'
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"phone"
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"expect_time"
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"other_require"
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"create_time"
]
%
]
<
/td
>
<
tr
class
=
"text-center"
>
<
td
>
[
%=
it
[
item
][
'id'
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
'title'
]
%
]
<
/td
>
<
td
>
<
a
class
=
"btn1 btn-success "
href
=
"#modal-process"
data
-
toggle
=
"modal"
data
-
id
=
"[%= it[item]['id'] %]"
onclick
=
"alertFollow(this)"
>
跟进
<
/a
>
<
a
data
-
toggle
=
"modal"
data
-
id
=
"[%= it[item]['id'] %]"
[
%
if
(
it
[
item
][
"applies_id"
]
==
0
){
%
]
href
=
"#modal-watch"
class
=
"btn1 btn-danger add_applies"
>
转为报备
<
/a
>
[
%
}
else
{
%
]
class
=
"btn1 btn-info"
>
已转为报备
<
/a
>
[
%
if
(
it
[
item
][
'description'
])
{
%
]
[
%=
it
[
item
][
'description'
]
%
]
[
%
}
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"status"
]
%
]
<
/td
>
<
td
>
<
a
title
=
"编辑"
class
=
"btn btn-success btn-xs"
href
=
"/admin.php/admin/auth/roleedit/group_id/1.html"
style
=
"margin-right:6px;"
>
编辑
<
/a
>
<
a
title
=
"权限分配"
class
=
"btn btn-info btn-xs"
href
=
"/admin.php/admin/auth/access/group_id/1.html"
style
=
"margin-right:6px;"
>
权限分配
<
/a
>
<
a
title
=
"成员授权"
class
=
"btn btn-primary btn-xs"
href
=
"/admin.php/admin/auth/accessuser/group_id/1.html"
style
=
"margin-right:6px;"
>
成员授权
<
/a
>
<
/td
>
<
/tr
>
[
%
}
%
]
[
%
}
else
{
%
]
...
...
@@ -24,4 +22,4 @@
<
td
colspan
=
"8"
style
=
"text-align:center;"
>
暂无数据
<
/td
>
<
/tr
>
[
%
}
%
]
</script>
\ No newline at end of file
</script>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment