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
699e96e5
Commit
699e96e5
authored
Mar 12, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
菜单权限控制
parent
f05e8411
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
131 deletions
+94
-131
Login.php
application/index/controller/Login.php
+20
-38
frame_tpl.html
application/index/view/global/frame_tpl.html
+1
-2
navigation.html
application/index/view/global/navigation.html
+1
-82
AAgents.php
application/model/AAgents.php
+3
-6
AuthRule.php
application/model/AuthRule.php
+15
-0
banner.js
public/resource/js/banner.js
+0
-1
login.js
public/resource/js/login.js
+1
-1
public.js
public/resource/js/public.js
+33
-1
menu_template_tpl.html
public/resource/template/menu_template_tpl.html
+20
-0
No files found.
application/index/controller/Login.php
View file @
699e96e5
...
...
@@ -74,56 +74,38 @@ class Login extends Basic
if
(
$list
[
'admin_off'
]
!=
'0'
||
empty
(
$list
[
'rules'
]))
{
return
$this
->
response
(
'103'
,
'用户无后台访问权限'
);
}
else
{
$rules
=
trim
(
$list
[
'rules'
],
','
);
//查询后台菜单
$where
=
"id in(
{
$rules
}
) and is_menu=1 and status=0 and pid=1 "
;
$nav
=
$this
->
authRule
->
loginRule
(
$where
);
$nav2
=
array
();
$url
=
''
;
//跳转页面
foreach
(
$nav
as
$k
=>
$v
){
if
(
$k
==
'0'
){
$url
=
$v
->
name
;
$nav
=
$this
->
authRule
->
getRule
(
$list
[
'rules'
]);
$menu_data
=
[];
$auth_data
=
[];
foreach
(
$nav
as
$k
=>
$v
)
{
if
(
$v
[
'is_menu'
]
==
1
)
{
$menu_data
[
$k
][
'id'
]
=
$v
[
'id'
];
$v
[
'name'
]
=
explode
(
'/'
,
$v
[
'name'
]);
$menu_data
[
$k
][
'name'
]
=
$v
[
'name'
][
1
];
$menu_data
[
$k
][
'title'
]
=
$v
[
'title'
];
$menu_data
[
$k
][
'pid'
]
=
$v
[
'pid'
];
}
else
{
$auth_data
[
$k
][
'id'
]
=
$v
[
'id'
];
$auth_data
[
$k
][
'name'
]
=
$v
[
'name'
];
$auth_data
[
$k
][
'title'
]
=
$v
[
'title'
];
$auth_data
[
$k
][
'pid'
]
=
$v
[
'pid'
];
}
$nav2
[
$v
->
id
]
=
$v
;
}
if
(
!
$url
)
{
return
$this
->
response
(
'104'
,
'用户无任何后台访模块问权限!'
);
}
//搜索菜单功能
$where
=
"id in(
{
$rules
}
) and is_menu=0 and status=0 "
;
$auth_rule
=
$this
->
authRule
->
loginRule
(
$where
);
$auth_rule_arr
=
array
();
foreach
(
$auth_rule
as
$v
)
{
$buttonUrl
=
explode
(
'/'
,
$v
->
name
);
$v
[
'action_control'
]
=
$buttonUrl
[
1
];
$auth_rule_arr
[
$v
->
pid
][]
=
$v
;
}
foreach
(
$nav2
as
$k
=>
$v
){
if
(
!
empty
(
$auth_rule_arr
[
$k
])){
$nav2
[
$k
][
'operation'
]
=
$auth_rule_arr
[
$k
];
}
}
$list
[
'nav'
]
=
$nav2
;
$list2
=
$list
->
toArray
();
//转化arr
$list
[
'menu'
]
=
list_to_tree
(
$menu_data
);
$list
[
'auth'
]
=
$auth_data
;
$list
=
$list
->
toArray
();
//转化arr
}
Session
::
set
(
"userName"
,
$list
[
"name"
]);
Session
::
set
(
"userId"
,
$list
[
"id"
]);
Session
::
set
(
"user_info"
,
$list2
);
Session
::
set
(
"lastLoginTime"
,
time
());
$this
->
operating_records
(
$list
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$data
[
'url'
]
=
$url
;
$data
[
'data'
]
=
$list2
;
if
(
$this
->
request
->
isAjax
())
{
return
$this
->
response
(
'200'
,
'登录成功'
,
$
data
);
return
$this
->
response
(
'200'
,
'登录成功'
,
$
list
);
}
else
{
$this
->
redirect
(
'/admin.php
/'
.
$url
);
$this
->
redirect
(
'/admin.php
'
);
}
return
;
}
...
...
application/index/view/global/frame_tpl.html
View file @
699e96e5
...
...
@@ -22,13 +22,12 @@
</div>
<div
class=
"dropdown"
>
<button
class=
"btn btn-default dropdown-toggle"
type=
"button"
id=
"dropdownMenu1"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"true"
>
管理员vip
<span
class=
"caret"
></span>
</button>
<ul
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenu1"
>
<li><a
href=
"#"
>
修改密码
</a></li>
<li
role=
"separator"
class=
"divider"
></li>
<li><a
href=
"/index/logout"
>
退出登录
</a></li>
<li><a
href=
"/index/logout"
id=
"logout"
>
退出登录
</a></li>
</ul>
</div>
</div>
...
...
application/index/view/global/navigation.html
View file @
699e96e5
<nav
class=
"navbar navbar-inverse"
id=
"sidebar-wrapper"
role=
"navigation"
>
<ul
class=
"nav sidebar-nav"
id=
"menu_bar"
>
<ul
class=
"nav sidebar-nav"
>
<!--便于后期更改使用-->
<!--<li class="sidebar-brand">-->
<!--<a href="#">-->
<!--Bootstrap 3-->
<!--</a>-->
<!--</li>-->
<!--<li class="dropdown">-->
<!--<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-fw fa-plus"></i> Dropdown <span class="caret"></span></a>-->
<!--<ul class="dropdown-menu" role="menu">-->
<!--<li class="dropdown-header">Dropdown heading</li>-->
<!--<li><a href="#">Action</a></li>-->
<!--<li><a href="#">Another action</a></li>-->
<!--<li><a href="#">Something else here</a></li>-->
<!--<li><a href="#">Separated link</a></li>-->
<!--<li><a href="#">One more separated link</a></li>-->
<!--</ul>-->
<!--</li>-->
<li
role=
"presentation"
class=
"active"
>
<a
href=
"/admin.php/index/banner.html"
>
首页轮播图
</a>
</li>
<li
role=
"presentation"
class=
"active"
>
<a
href=
"/admin.php/index/advertising"
>
首页弹窗
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/users_list.html"
>
客户列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/watch_shop.html"
>
预约看铺列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/transfer_list.html"
>
委托转铺列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/version.html"
>
版本号管理
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/auth.html"
>
角色管理
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/authRuleIndex.html"
>
权限管理
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/agent.html"
>
经纪人列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/storeList.html"
>
门店列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/districtList.html"
>
部门列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/remarkFollowIndex.html"
>
跟进列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/houseList.html"
>
商铺列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/houseEdit.html"
>
新增商铺
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/BusinessDistrict.html"
>
商圈列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/CellPhoneAgentIndex.html"
>
经纪人通话列表
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/CellPhoneIndex.html"
>
通话记录
</a>
</li>
<!--<li role="presentation">-->
<!--<a href="/admin.php/index/phoneList.html">号码池列表</a>-->
<!--</li>-->
<!--<li role="presentation">-->
<!--<a href="/admin.php/index/bindPhoneListIndex.html">号码绑定列表</a>-->
<!--</li>-->
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/setting_index.html"
>
参数设置
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"/admin.php/index/uLabelIndex.html"
>
客户标签
</a>
</li>
</ul>
</nav>
...
...
application/model/AAgents.php
View file @
699e96e5
...
...
@@ -191,16 +191,13 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
verifyUser
(
$field
,
$join
,
$params
)
public
function
verifyUser
(
$field
,
$join
,
$params
)
{
$r
=
$this
->
field
(
$field
)
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
$join
)
->
join
(
$join
)
->
where
(
$params
)
->
find
();
//echo $this->getLastSql();
return
$r
;
}
/**
...
...
application/model/AuthRule.php
View file @
699e96e5
...
...
@@ -164,4 +164,18 @@ class AuthRule extends BaseModel
$r
=
$this
->
where
(
"id"
,
'in'
,
$ids
)
->
update
([
$name
=>
$key
]);
return
$r
;
}
/**
* @param $id
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getRule
(
$id
)
{
return
$this
->
field
(
'id,name,title,pid,is_menu'
)
->
where
(
'status'
,
0
)
->
where
(
'id'
,
'in'
,
$id
)
->
select
();
}
}
\ No newline at end of file
public/resource/js/banner.js
View file @
699e96e5
...
...
@@ -104,7 +104,6 @@ define (['doT', 'text!temp/banner_template_tpl.html', 'ckfinder', 'ckfinderStart
data
:
params
,
dataType
:
'json'
,
success
:
function
(
data
)
{
console
.
log
(
data
.
data
);
var
temp
=
document
.
getElementById
(
'banner_list_tpl'
).
innerHTML
;
var
doTtmpl
=
doT
.
template
(
temp
);
$
(
"#banner_list"
).
html
(
doTtmpl
(
data
.
data
.
list
));
...
...
public/resource/js/login.js
View file @
699e96e5
...
...
@@ -45,7 +45,7 @@ $(function(){
success
:
function
(
data
)
{
if
(
typeof
data
===
'object'
)
{
if
(
data
.
code
==
200
)
{
console
.
log
(
'登录成功'
);
localStorage
.
setItem
(
'user_info'
,
JSON
.
stringify
(
data
.
data
)
);
location
.
href
=
'/admin.php/index/banner'
;
}
else
{
alert
(
data
[
'msg'
]);
...
...
public/resource/js/public.js
View file @
699e96e5
define
([
'doT'
,
'jquery'
],
function
(
doT
,
$
)
{
define
([
'doT'
,
'jquery'
,
'text!temp/menu_template_tpl.html'
],
function
(
doT
,
$
,
template
)
{
var
init
=
{
doTinit
:
function
()
{
doT
.
templateSettings
=
{
...
...
@@ -25,6 +25,38 @@ define(['doT', 'jquery'], function (doT, $) {
});
}
menu_bar
();
function
menu_bar
()
{
var
user_info_obj
=
localStorage
.
getItem
(
'user_info'
);
//读取缓存
$
(
"#menu_bar"
).
append
(
template
);
if
(
typeof
user_info_obj
===
'string'
)
{
var
user_info
=
JSON
.
parse
(
user_info_obj
);
var
temp
=
document
.
getElementById
(
'menu_tpl'
).
innerHTML
;
var
doTtmpl
=
doT
.
template
(
temp
);
$
(
"#dropdownMenu1"
).
append
(
user_info
[
'name'
]);
$
(
"#menu_bar"
).
html
(
doTtmpl
(
user_info
[
'menu'
]));
}
else
{
$
.
ajax
({
url
:
'/index/getMenu'
,
type
:
'POST'
,
async
:
true
,
data
:
""
,
dataType
:
'json'
,
success
:
function
(
data
)
{
var
temp
=
document
.
getElementById
(
'menu_tpl'
).
innerHTML
;
var
doTtmpl
=
doT
.
template
(
temp
);
$
(
"#menu_bar"
).
html
(
doTtmpl
(
data
.
data
.
menu
));
}
});
}
}
$
(
"#logout"
).
click
(
function
()
{
localStorage
.
removeItem
(
'user_info'
);
});
});
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
...
...
public/resource/template/menu_template_tpl.html
0 → 100644
View file @
699e96e5
<script
id=
"menu_tpl"
type=
"text/template"
>
[
%
if
(
it
)
{
%
]
[
%
for
(
var
item
in
it
){
%
]
<
li
class
=
"dropdown"
>
<
a
href
=
"#"
class
=
"dropdown-toggle"
data
-
toggle
=
"dropdown"
>
<
span
class
=
"glyphicon glyphicon-credit-card"
aria
-
hidden
=
"true"
><
/span><span class="span-list">
[
%= it[item
][
"title"
]
%]</
span
>
<
span
class
=
"glyphicon glyphicon-hand-down"
aria
-
hidden
=
"true"
><
/span></
a
>
<
ul
class
=
"dropdown-menu"
role
=
"menu"
>
[
%
for
(
var
item_menu
in
it
[
item
][
"_child"
]){
%
]
<
li
><
a
href
=
"[%= it[item]['_child'][item_menu]['name'] %]"
><
span
class
=
"glyphicon glyphicon-dashboard"
aria
-
hidden
=
"true"
><
/span> <span class="span-list">
[
%= it[item
][
"_child"
][
item_menu
][
'title'
]
%]</
span
><
/a></
li
>
[
%
}
%
]
<
/ul
>
<
/li
>
[
%
}
%
]
[
%
}
else
{
%
]
<
tr
>
<
td
colspan
=
"8"
style
=
"text-align:center;"
>
暂无数据
<
/td
>
<
/tr
>
[
%
}
%
]
</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