diff --git a/admin/src/api/consumer.ts b/admin/src/api/consumer.ts
index 2b536681..14bff02f 100644
--- a/admin/src/api/consumer.ts
+++ b/admin/src/api/consumer.ts
@@ -19,3 +19,8 @@ export function userEdit(params: any) {
export function adjustMoney(params: any) {
return request.post({ url: '/user.user/adjustMoney', params })
}
+
+//添加用户
+export function addUser(params: any) {
+ return request.post({ url: '/user.user/add', params })
+}
diff --git a/admin/src/views/consumer/lists/index.vue b/admin/src/views/consumer/lists/index.vue
index 86fd7dd0..8bed0b31 100644
--- a/admin/src/views/consumer/lists/index.vue
+++ b/admin/src/views/consumer/lists/index.vue
@@ -30,6 +30,7 @@
查询
重置
+ 创建
@@ -81,12 +82,34 @@
+
+
+
+
+
+
+
+
+ 初始密码:123456
+
+
+
+
+
+
+
diff --git a/app/adminapi/controller/user/UserController.php b/app/adminapi/controller/user/UserController.php
index 5afbda95..d8a73552 100644
--- a/app/adminapi/controller/user/UserController.php
+++ b/app/adminapi/controller/user/UserController.php
@@ -18,6 +18,13 @@ use app\adminapi\lists\user\UserLists;
use app\adminapi\logic\user\UserLogic;
use app\adminapi\validate\user\AdjustUserMoney;
use app\adminapi\validate\user\UserValidate;
+use app\api\validate\LoginAccountValidate;
+use app\common\model\auth\Admin;
+use app\common\model\auth\AdminRole;
+use app\common\model\user\User;
+use app\common\service\ConfigService;
+use think\facade\Config;
+use think\facade\Db;
/**
* 用户控制器
@@ -38,6 +45,43 @@ class UserController extends BaseAdminController
return $this->dataLists(new UserLists());
}
+ public function add()
+ {
+ try {
+ $params = $this->request->param();
+ $userSn = User::createUserSn();
+ $passwordSalt = Config::get('project.unique_identification');
+ $password = create_password(123456, $passwordSalt);
+ $avatar = ConfigService::get('default_image', 'user_avatar');
+
+ Db::transaction(function () use($userSn,$password,$avatar,$params) {
+ $user = User::create([
+ 'sn' => $userSn,
+ 'avatar' => env('project.project_url').'/'.$avatar,
+ 'nickname' => '用户' . $userSn,
+ 'account' => $params['mobile'],
+ 'mobile' => $params['mobile'],
+ 'password' => $password,
+ 'channel' => 6,
+ ]);
+ $admin = Admin::create([
+ 'user_id' => $user->id,
+ 'name' => '用户' . $userSn,
+ 'avatar' => env('project.project_url').'/'.$avatar,
+ 'account' => $params['mobile'],
+ 'password' => $password
+ ]);
+ AdminRole::create([
+ 'admin_id' => $admin->id,
+ 'role_id' => 1
+ ]);
+ });
+ return $this->success();
+ } catch (\Exception $e) {
+ return $this->fail($e->getMessage());
+
+ }
+ }
public function datas()
{
$datas = (new UserLogic())->datas(input(''));