Commit 6ea285f5 by 赵增煜
parents 8f1c3e96 6cdb77f1
......@@ -3,6 +3,7 @@ APP_ENV=local
APP_KEY=base64:X9/EwE4Bb65OLiZ54TizbwXD0cceNHFPTLNvP1xJQrY=
APP_DEBUG=true
APP_URL=http://localhost
APP_STORE_URL=https://药店域名
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
......
......@@ -16,11 +16,17 @@ class AuthController extends BaseAuthController
public function getLogin(Content $content)
{
// 获取请求域名
$requestDomain = request()->host(); // 不带协议|不带端口
// env中配置的药店端域名
$parsedUrl = parse_url(env('APP_STORE_URL'));
$appStoreUrl = $parsedUrl['host'];
// 获取角色参数
$role = request()->get('role');
// 根据角色参数决定登录页面
if ($role === 'store') {
if (($requestDomain == $appStoreUrl) || ($role === 'store')) {
$this->view = 'admin.loginstore'; // 店铺管理员登录页面
} else {
$this->view = 'admin.login'; // 默认管理员登录页面
......
......@@ -121,7 +121,7 @@ protected function form()
return Form::make(new DrugRepository('tag'), function (Form $form) {
$form->display('id')->width(4);
$form->text('name')->width(4)->required()->maxLength(64, '最多输入64个字符');
$form->text('code')->readonly()->width(4);
$form->display('code')->width(4);
$form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'name'))->width(4);
$form->text('spec')->width(4)->required()->maxLength(128, '最多输入128个字符');
$form->text('dosage_form')->width(4)->required()->maxLength(128, '最多输入128个字符');
......
......@@ -171,21 +171,23 @@ protected function form()
$admin = Administrator::where('pharmacy_id', $pharmacyId)->first();
if ($admin) {
// 如果存在,更新相应字段
$admin->username = $mobile; // 更新账号
$admin->name = $name; // 更新账号姓名
$admin->save();
if ($mobile && $name) {
$admin->username = $mobile; // 更新账号
$admin->name = $name; // 更新账号姓名
$admin->save();
}
} else {
// 如果不存在,新增管理员
$admin = new Administrator();
$admin->username = $mobile; // 药店手机号作为管理员账号
$admin->name = $name; // 药店名称当做用户的姓名
$admin->password = bcrypt(Str::random(10)); // 设置管理员密码
$admin->pharmacy_id = $pharmacyId; // 药店ID
$admin->save(); // 保存新管理员
// 关联药店管理员角色
$admin->roles()->attach($role->id);
if ($mobile && $name && $pharmacyId) {
$admin = new Administrator();
$admin->username = $mobile; // 药店手机号作为管理员账号
$admin->name = $name; // 药店名称当做用户的姓名
$admin->password = bcrypt(Str::random(10)); // 设置管理员密码
$admin->pharmacy_id = $pharmacyId; // 药店ID
$admin->save(); // 保存新管理员
// 关联药店管理员角色
$admin->roles()->attach($role->id);
}
}
DB::commit();
} catch (\Exception $e) {
......
......@@ -20,7 +20,7 @@ public function setNameAttribute($value)
$this->attributes['name'] = $value;
$pinyin = new Pinyin();
$abbr = $pinyin->abbr($this->name)->join(''); // 获取拼音首字母
$abbr = $pinyin->abbr($value)->join(''); // 获取拼音首字母
$this->attributes['code'] = strtoupper($abbr);
}
}
......@@ -41,7 +41,7 @@ public function setNameAttribute($value)
$this->attributes['name'] = $value;
$pinyin = new Pinyin();
$abbr = $pinyin->abbr($this->name)->join(''); // 获取拼音首字母
$abbr = $pinyin->abbr($value)->join(''); // 获取拼音首字母
$this->attributes['code'] = strtoupper($abbr);
}
......
......@@ -64,7 +64,7 @@
<div class="login-box">
<div class="login-logo mb-2" style="font-size:1.8rem;font-weight: normal;">
<img class="avatar img-circle login-img" src="{{ admin_asset('@admin/images/logo.jpg') }}">
{{ config('admin.name') }}
{{ config('admin.name') }}-药店端
<p style="font-size:0.5rem"></p>
</div>
<div class="card">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment