diff --git a/server/app/admin/controller/user/BusinessTeam.php b/server/app/admin/controller/user/BusinessTeam.php index 5aac9d82..616a9d53 100644 --- a/server/app/admin/controller/user/BusinessTeam.php +++ b/server/app/admin/controller/user/BusinessTeam.php @@ -70,20 +70,4 @@ class BusinessTeam extends AdminBase } return JsonServer::error(BusinessTeamLogic::getError()); } - -// public function set() -// { -// if($this->request->isAjax()) { -// $post = $this->request->post(); -// ConfigServer::set('user_level', 'intro', $post['intro']); -// return JsonServer::success('设置成功'); -// } -// $intro = ConfigServer::get('user_level', 'intro'); -// $intro_default = config('default.user_level.intro'); -// -// return view('', [ -// 'intro' => $intro, -// 'intro_default' => $intro_default -// ]); -// } } \ No newline at end of file diff --git a/server/app/admin/controller/user/User.php b/server/app/admin/controller/user/User.php index 7bce7440..8fa0d1f6 100644 --- a/server/app/admin/controller/user/User.php +++ b/server/app/admin/controller/user/User.php @@ -1,7 +1,9 @@ LevelLogic::getLevelList(), 'tag_list' => TagLogic::getTagList(), - 'client_list' => ClientEnum::getClient(true) + 'client_list' => ClientEnum::getClient(true), + 'team_list' => BusinessTeamLogic::getBusinessTeamList() ]); } + public function add() + { + if($this->request->isAjax()) { + try{ + $input = input('post.'); + + $rule = [ + 'password|密码' => 'require|min:2|max:50', + 'password_confirm|确认密码' => 'require|min:2|max:50', + 'phone|手机' => 'require|mobile', + ]; + + $validate = Validate::rule($rule); + if (!$validate->check($input)) { + return JsonServer::error($validate->getError()); + } + + if ($input['password'] != $input['password_confirm']) { + return JsonServer::error('两次密码不一致'); + } + + if (\app\common\model\user\User::where('mobile', $input['phone'])->where('del', 0)->count()>0) { + return JsonServer::error('此手机号已被使用'); + } + $post = [ + 'mobile' => $input['phone'], + 'password' => $input['password'], + 'client' => ClientEnum::backend, + ]; + LoginLogic::register($post); + if (!empty(LoginLogic::getError())) { + return JsonServer::error(LoginLogic::getError()); + } + return JsonServer::success('添加成功'); + }catch(ValidateException $e) { + return JsonServer::error($e->getError()); + }catch(\Exception $e) { + return JsonServer::error($e->getMessage()); + } + + return JsonServer::error('添加失败'); + } + return view(); + } + public function setTag(){ if($this->request->isAjax()){ $post = $this->request->post(); @@ -65,7 +114,8 @@ class User extends AdminBase return view('', [ 'info' => $detail, - 'tag_list' => json_encode(TagLogic::getTagList()) + 'tag_list' => json_encode(TagLogic::getTagList()), + 'team_list' => json_encode(BusinessTeamLogic::getBusinessTeamList([$id])) ]); } diff --git a/server/app/admin/logic/user/BusinessTeamLogic.php b/server/app/admin/logic/user/BusinessTeamLogic.php index d7b47790..5e0c21bd 100644 --- a/server/app/admin/logic/user/BusinessTeamLogic.php +++ b/server/app/admin/logic/user/BusinessTeamLogic.php @@ -70,12 +70,17 @@ class BusinessTeamLogic extends Logic } } - public static function getBusinessTeamList() + public static function getBusinessTeamList($selected = []) { $levelArr = BusinessTeam::field('id,name,phone') + ->order('id desc') ->select() ->toArray(); - $levelArr[0] = ['id'=>0, 'name'=>'暂无团队', 'phone' => '']; + foreach ($levelArr as &$item) { + if (in_array($item['id'], $selected)) { + $item['selected'] = true; + } + } return $levelArr; } diff --git a/server/app/admin/logic/user/UserLogic.php b/server/app/admin/logic/user/UserLogic.php index fde7c850..4c8d8c49 100644 --- a/server/app/admin/logic/user/UserLogic.php +++ b/server/app/admin/logic/user/UserLogic.php @@ -148,7 +148,7 @@ class UserLogic extends Logic { $field = [ 'id', 'sn','nickname','avatar','mobile','sex','birthday','tag_ids', - 'remark','user_money','user_growth','user_integral','earnings', 'disable' + 'remark','user_money','user_growth','user_integral','earnings', 'disable', 'team_id' ]; $user = User::field($field)->where(['del' => 0, 'id' => $id])->findOrEmpty(); @@ -161,6 +161,8 @@ class UserLogic extends Logic } // 会员标签 $user['tag_ids'] = json_encode(explode(',', $user['tag_ids'])); + // 业务团队 + $user['team_ids'] = json_encode(explode(',', $user['team_id'])); return $user->toArray(); } @@ -175,6 +177,7 @@ class UserLogic extends Logic 'mobile' => $post['mobile'], 'birthday' => strtotime($post['birthday']), 'tag_ids' => $post['select'], + 'team_id' => $post['team_id'] ?? 0, 'remark' => $post['remark'], 'disable' => $post['disable'], 'update_time' => time() diff --git a/server/app/admin/view/user/business_team/add.html b/server/app/admin/view/user/business_team/add.html new file mode 100644 index 00000000..ef413cbe --- /dev/null +++ b/server/app/admin/view/user/business_team/add.html @@ -0,0 +1,31 @@ +{layout name="layout2" /} + +
业务团队:{{d.team_name}}