Commit b1b102f9 by lujunyi

店铺登录

parent 29e53dd2
......@@ -4,6 +4,7 @@
use App\Models\AdminUsers;
use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController;
use Dcat\Admin\Layout\Content;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
......@@ -11,6 +12,25 @@ class AuthController extends BaseAuthController
{
protected $view = 'admin.login';
public function getLogin(Content $content)
{
// 获取角色参数
$role = request()->get('role');
// 根据角色参数决定登录页面
if ($role === 'store') {
$this->view = 'admin.loginstore'; // 店铺管理员登录页面
} else {
$this->view = 'admin.login'; // 默认管理员登录页面
}
if ($this->guard()->check()) {
return redirect($this->getRedirectPath());
}
return $content->full()->body(view($this->view));
}
/**
* Handle a login request.
*
......
<style>
.login-page {
padding: 6rem 15rem;
flex: 1;
position: relative;
color: #4B5CC4;
background-color: rgba(0, 0, 0, 0.3);
text-align: center !important;
background: url({{ config('admin.login_backgroud') }}) center;
background-size: cover;
align-items: flex-end!important;
}
.login-box {
margin-top: -10rem;
padding: 5px;
}
.login-logo{
position: absolute;
top: 10px;
left: 20px;
text-align: left;
}
.login-img{
width: 30px;
}
.login-card-body {
padding: 1.5rem 1.8rem 1.6rem;
}
.card, .card-body {
border-radius: .25rem
}
.login-btn {
padding-left: 2rem!important;;
padding-right: 1.5rem!important;
}
.content {
overflow-x: hidden;
}
.form-group .control-label {
text-align: left;
}
.footer-icp {
position: absolute;
left: 50%;
bottom: 0px;
transform: translateX(-50%);
width: 100%;
color: #666;
font-size: 12px;
text-align: center;
padding: 5px 0;
background-color: #f5f5f5;
}
.footer-icp a {
color: #666;
text-decoration: none;
}
.footer-icp a:hover {
text-decoration: underline;
}
</style>
<div class="login-page">
<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.png') }}">
{{ config('admin.name') }}
<p style="font-size:0.5rem">一些描述信息,店铺登录界面</p>
</div>
<div class="card">
<div class="card-body login-card-body shadow-100">
<p class="login-box-msg mt-1 mb-1">{{ __('admin.welcome_back') }}</p>
<form id="login-form" method="POST" action="{{ admin_url('auth/login') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
<fieldset class="form-label-group form-group position-relative has-icon-left">
<input
type="text"
class="form-control {{ $errors->has('phone') ? 'is-invalid' : '' }}"
name="phone"
placeholder="手机号"
value="{{ old('phone') }}"
required
autofocus
>
<div class="form-control-position">
<i class="feather icon-user"></i>
</div>
<label for="phone">手机号</label>
<div class="help-block with-errors"></div>
@if($errors->has('phone'))
<span class="invalid-feedback text-danger" role="alert">
@foreach($errors->get('phone') as $message)
<span class="control-label" for="inputError"><i class="feather icon-x-circle"></i> {{$message}}</span><br>
@endforeach
</span>
@endif
</fieldset>
<fieldset class="form-label-group form-group position-relative has-icon-left d-flex align-items-center">
<input
id="verification_code"
type="text"
class="form-control {{ $errors->has('verification_code') ? 'is-invalid' : '' }}"
name="verification_code"
placeholder="短信验证码"
required
style="width: 60%; margin-right: 10px;"
>
<div class="form-control-position">
<i class="feather icon-lock"></i>
</div>
<button type="button" class="btn btn-secondary" id="get-verification-code" onclick="getVerificationCode()">
获取验证码
</button>
<div class="form-control-position" style="display: none;">
<i class="feather icon-lock"></i>
</div>
<label for="verification_code">{{ trans('admin.verification_code') }}</label>
<div class="help-block with-errors"></div>
@if($errors->has('verification_code'))
<span class="invalid-feedback text-danger" role="alert">
@foreach($errors->get('verification_code') as $message)
<span class="control-label" for="inputError"><i class="feather icon-x-circle"></i> {{$message}}</span><br>
@endforeach
</span>
@endif
</fieldset>
<div class="form-group d-flex justify-content-between align-items-center">
<div class="text-left">
@if(config('admin.auth.remember'))
<fieldset class="checkbox">
<div class="vs-checkbox-con vs-checkbox-primary">
<input id="remember" name="remember" value="1" type="checkbox" {{ old('remember') ? 'checked' : '' }}>
<span class="vs-checkbox">
<span class="vs-checkbox--check">
<i class="vs-icon feather icon-check"></i>
</span>
</span>
<span> {{ trans('admin.remember_me') }}</span>
</div>
</fieldset>
@endif
</div>
</div>
<button type="submit" class="btn btn-primary float-right login-btn">
{{ __('admin.login') }}
&nbsp;
<i class="feather icon-arrow-right"></i>
</button>
</form>
</div>
</div>
</div>
<div class="footer-icp">
<a href="https://beian.miit.gov.cn/" rel="noopener noreferrer" target="_blank">网站备案号:苏ICP备2024000133号</a>
</div>
</div>
<script>
Dcat.ready(function () {
// ajax表单提交
$('#login-form').form({
validate: true,
});
});
let countdown = 60; // 倒计时60秒
let timer;
function getVerificationCode() {
const phone = $('input[name="phone"]').val();
if (!phone) {
alert('请输入手机号');
return;
}
// 发送 AJAX 请求获取验证码
$.ajax({
url: '{{ admin_url('auth/get-verification-code') }}', // 替换为您的接口地址
method: 'POST',
data: {
phone: phone,
_token: '{{ csrf_token() }}'
},
success: function(response) {
if (response.success) {
alert('验证码已发送');
startCountdown();
} else {
alert(response.message || '获取验证码失败');
}
},
error: function() {
alert('请求失败,请重试');
}
});
}
function startCountdown() {
$('#get-verification-code').prop('disabled', true).text(`重新获取(${countdown}s)`);
timer = setInterval(function() {
countdown--;
$('#get-verification-code').text(`重新获取(${countdown}s)`);
if (countdown <= 0) {
clearInterval(timer);
$('#get-verification-code').prop('disabled', false).text('{{ __('admin.get_verification_code') }}');
countdown = 60; // 重置倒计时
}
}, 1000);
}
</script>
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