|
@@ -52,7 +52,8 @@ function json_success($data=[],$msg='ok')
|
|
|
|
|
|
function json_error($code,$msg='')
|
|
|
{
|
|
|
- json_return(json_error_exception($code,$msg));
|
|
|
+ $error = json_error_exception($code,$msg);
|
|
|
+ json_return($error['code'],[],$error['msg']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -125,42 +126,6 @@ function _curl(array $params,$is_json=false )
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
-
|
|
|
-/**
|
|
|
- * 整理菜单住方法
|
|
|
- * @param $param
|
|
|
- * @return array
|
|
|
- */
|
|
|
-function prepareMenu($param)
|
|
|
-{
|
|
|
- $param = objToArray($param);
|
|
|
- $parent = []; //父类
|
|
|
- $child = []; //子类
|
|
|
-
|
|
|
- foreach($param as $key=>$vo){
|
|
|
-
|
|
|
- if(0 == $vo['type_id']){
|
|
|
- $vo['href'] = '#';
|
|
|
- $parent[] = $vo;
|
|
|
- }else{
|
|
|
- $vo['href'] = url($vo['control_name'] .'/'. $vo['action_name']); //跳转地址
|
|
|
- $child[] = $vo;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- foreach($parent as $key=>$vo){
|
|
|
- foreach($child as $k=>$v){
|
|
|
-
|
|
|
- if($v['type_id'] == $vo['id']){
|
|
|
- $parent[$key]['child'][] = $v;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- unset($child);
|
|
|
-
|
|
|
- return $parent;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* 统一返回信息
|
|
|
* @param $code
|
|
@@ -171,46 +136,6 @@ function msg($code, $data, $msg)
|
|
|
{
|
|
|
return compact('code', 'data', 'msg');
|
|
|
}
|
|
|
-
|
|
|
-/**
|
|
|
- * 整理出tree数据 --- layui tree
|
|
|
- * @param $pInfo
|
|
|
- * @param $spread
|
|
|
- */
|
|
|
-function getTree($pInfo, $spread = true)
|
|
|
-{
|
|
|
-
|
|
|
- $res = [];
|
|
|
- $tree = [];
|
|
|
- //整理数组
|
|
|
- foreach($pInfo as $key=>$vo){
|
|
|
-
|
|
|
- if($spread){
|
|
|
- $vo['spread'] = true; //默认展开
|
|
|
- }
|
|
|
- $res[$vo['id']] = $vo;
|
|
|
- $res[$vo['id']]['children'] = [];
|
|
|
- }
|
|
|
- unset($pInfo);
|
|
|
-
|
|
|
- //查找子孙
|
|
|
- foreach($res as $key=>$vo){
|
|
|
- if(0 != $vo['pid']){
|
|
|
- $res[$vo['pid']]['children'][] = &$res[$key];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //过滤杂质
|
|
|
- foreach( $res as $key=>$vo ){
|
|
|
- if(0 == $vo['pid']){
|
|
|
- $tree[] = $vo;
|
|
|
- }
|
|
|
- }
|
|
|
- unset( $res );
|
|
|
-
|
|
|
- return $tree;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* 对象转换成数组
|
|
|
* @param $obj
|
|
@@ -218,23 +143,4 @@ function getTree($pInfo, $spread = true)
|
|
|
function objToArray($obj)
|
|
|
{
|
|
|
return json_decode(json_encode($obj), true);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * 权限检测
|
|
|
- * @param $rule
|
|
|
- */
|
|
|
-function authCheck($rule)
|
|
|
-{
|
|
|
- $control = explode('/', $rule)['0'];
|
|
|
- if(in_array($control, ['login', 'index'])){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- if(in_array($rule, cache(session('role_id')))){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
}
|