This commit is contained in:
mkm 2023-08-26 18:19:46 +08:00
parent 5ca65d37e5
commit 9df5ea73fa
7 changed files with 48 additions and 15 deletions

View File

@ -63,7 +63,8 @@ class IndexController extends BaseApiController
*/
public function config()
{
$result = IndexLogic::getConfigData();
$group_id=$this->userInfo['group_id'];
$result = IndexLogic::getConfigData($group_id);
return $this->data($result);
}

View File

@ -18,6 +18,7 @@ use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValida
use app\api\logic\LoginLogic;
use app\Request;
use app\api\logic\UserLogic;
use app\common\model\Company;
/**
* 登录注册

View File

@ -19,6 +19,8 @@ use app\common\logic\BaseLogic;
use app\common\model\article\Article;
use app\common\model\decorate\DecoratePage;
use app\common\model\decorate\DecorateTabbar;
use app\common\model\user\UserMenu;
use app\common\model\user\UserRole;
use app\common\service\ConfigService;
use app\common\service\FileService;
@ -104,8 +106,30 @@ class IndexLogic extends BaseLogic
* @author 段誉
* @date 2022/9/21 19:38
*/
public static function getConfigData()
public static function getConfigData($group_id=1)
{
if($group_id==null){
$group_id=1;
}
$group_find=UserRole::where('id',$group_id)->find();
$menu=[];
if($group_find){
$select=UserMenu::where('id','in',$group_find['menu_arr'])->field('id,pid,name,icon,sort,paths')->limit(100)->select()->toArray();
$arr=[];
foreach($select as $k=>$v){
if($v['pid']==0){
$arr[]=$v;
}
}
foreach($arr as $k=>$v){
foreach($select as $kk=>$vv){
if($v['id']==$vv['pid']){
$arr[$k]['children'][]=$vv;
}
}
}
$menu=$arr;
}
// 底部导航
$tabbar = DecorateTabbar::getTabbarLists();
// 导航颜色
@ -119,11 +143,11 @@ class IndexLogic extends BaseLogic
// 政策协议
'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')),
// 第三方登录 开关
'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')),
// 'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')),
// 微信授权登录
'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')),
// qq授权登录
'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')),
// 'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')),
];
// 网址信息
$website = [
@ -131,23 +155,15 @@ class IndexLogic extends BaseLogic
'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
];
// H5配置
$webPage = [
// 渠道状态 0-关闭 1-开启
'status' => ConfigService::get('web_page', 'status', 1),
// 关闭后渠道后访问页面 0-空页面 1-自定义链接
'page_status' => ConfigService::get('web_page', 'page_status', 0),
// 自定义链接
'page_url' => ConfigService::get('web_page', 'page_url', ''),
'url' => request()->domain() . '/mobile'
];
return [
'domain' => FileService::getFileUrl(),
'style' => $style,
'tabbar' => $tabbar,
'menu' => $menu,
'login' => $loginConfig,
'website' => $website,
'webPage' => $webPage,
'version'=> config('project.version')
];
}

View File

@ -65,6 +65,10 @@ class LoginLogic extends BaseLogic
} else {
$avatar = ConfigService::get('default_image', 'user_avatar');
}
$group_id=1;
if ($params['is_captain']) {
$group_id=2;
}
User::create([
'sn' => $userSn,
'avatar' => $avatar,
@ -85,6 +89,7 @@ class LoginLogic extends BaseLogic
'address' => $params['address'],
'qualification' => json_encode($params['qualification']),
'company_id' => $params['company_id'],
'group_id' => $group_id,
]);
return true;

View File

@ -83,6 +83,7 @@ class UserTokenCache extends BaseCache
'expire_time' => $userSession->expire_time,
'admin_id' => $user->admin_id,
'company_id'=>$user->company_id,
'group_id'=>$user->group_id
];
$ttl = new \DateTime(Date('Y-m-d H:i:s', $userSession->expire_time));

View File

@ -89,13 +89,19 @@ class CompanyLogic extends BaseLogic
$admin['password'] = create_password(123456, $passwordSalt);
$admin_id=Admin::strict(false)->insertGetId($admin);
//镇/街公司
if($params['company_type']==16){
AdminLogic::insertRole($admin_id, [3]);
$admin['group_id']=4;
}elseif($params['company_type']==17){
//村管理公司
AdminLogic::insertRole($admin_id, [4]);
$admin['group_id']=3;
}
elseif ($params['company_type']==18) {
//小组服务公司
AdminLogic::insertRole($admin_id, [6]);
$admin['group_id']=5;
}
$userSn = User::createUserSn();
$admin['admin_id']=$admin_id;

View File

@ -32,7 +32,10 @@ class UserRole extends BaseModel
public function getMenuArrAttr($value)
{
return json_decode($value);
if($value){
return json_decode($value);
}
return [];
}
}