Compare commits

..

No commits in common. "afae859d8b9d5e606ba7161557d1009a5f646975" and "e369fe25ca9ed8de456c3a7428be08faed21ebef" have entirely different histories.

5 changed files with 631 additions and 936 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,13 +1,10 @@
/* ===== PC DESIGN ===== */ /* ===== PC DESIGN ===== */
$W: 1080; $W: 1000;
$H: 1920; $H: 1920;
// $picW: 438; $picW: 438;
// $picH: 560; $picH: 560;
$picW: 1080; $formW: 320;
$picH: 1118;
$formW: 420;
$tabW: $formW / 2; $tabW: $formW / 2;
// $rowH: 56;
$rowH: 56; $rowH: 56;
$buttonH: 50; $buttonH: 50;
@ -18,7 +15,6 @@ $containerBgImage: '../assets/images/bg.png';
$logoWidth: 417px; $logoWidth: 417px;
$logoHeight: 64px; $logoHeight: 64px;
$logoImage: '../assets/logo/login-logo.png'; $logoImage: '../assets/logo/login-logo.png';
$cnbmLogo: '../assets/logo/cnbm.png';
// container-content // container-content
$contentWidth: round($W / $H * 100) * 1vw; $contentWidth: round($W / $H * 100) * 1vw;
$contentHeight: round($picH / $W * 100) / 100 * $contentWidth; $contentHeight: round($picH / $W * 100) / 100 * $contentWidth;
@ -26,8 +22,7 @@ $contentBgColor: #ffffff;
// container-content-pic // container-content-pic
$picWidth: round($picW / $H * 100) * 1vw; $picWidth: round($picW / $H * 100) * 1vw;
$picHeight: inherit; $picHeight: inherit;
// $picImage: '../assets/images/pic.png'; $picImage: '../assets/images/pic.png';
$picImage: '../assets/images/login-bg.png';
// container-content-field // container-content-field
$fieldWidth: $contentWidth - $picWidth; $fieldWidth: $contentWidth - $picWidth;
$fieldHeight: inherit; $fieldHeight: inherit;
@ -39,308 +34,232 @@ $buttonHeight: $buttonH * 1px;
// - - - - - 页面基础设置 // - - - - - 页面基础设置
.container { .container {
.login-code { .login-code {
width: 33%; width: 33%;
height: 38px; height: 38px;
float: right; float: right;
img { img {
cursor: pointer; cursor: pointer;
width: 100%; width:100%;max-width:100px; height:auto;
max-width: 100px; vertical-align: middle;
height: auto; }
vertical-align: middle; }
} // 元素
} width: inherit;
// 元素 height: inherit;
width: inherit; min-width: 1080px;
height: inherit; min-height: 620px;
min-width: 1080px; background-color: $containerBgColor;
min-height: 620px; background-image: url($containerBgImage);
background-color: $containerBgColor; background-size: cover;
// background-image: url($containerBgImage); // 定位
background-size: cover; position: relative;
// 定位 display: flex;
position: relative; justify-content: center;
display: flex; align-items: center;
justify-content: center; // 文字
align-items: center; font-size: 14px;
// 文字 font-family: Microsoft YaHei;
font-size: 14px; font-weight: 400;
font-family: Microsoft YaHei; .logo {
font-weight: 400; // 元素
.logo { width: $logoWidth;
// 元素 height: $logoHeight;
width: $logoWidth; // background-image: url($logoImage);
height: $logoHeight; // background-size: contain;
// background-image: url($logoImage); // 定位
// background-size: contain; position: absolute;
// 定位 top: 50px;
position: absolute; left: 50%;
top: 50px; margin-left: -$logoWidth/2;
left: 50%; }
margin-left: -$logoWidth/2; .content {
} // 元素
.content { width: $contentWidth;
// 元素 height: $contentHeight;
// width: $contentWidth; background-color: #ffffff;
// height: $contentHeight; box-shadow: 0px 16px 40px rgba(0, 0, 0, 0.07);
width: 100%; border-radius: 20px;
height: 100%; // 定位
background-color: #ffffff; position: relative;
// box-shadow: 0px 16px 40px rgba(0, 0, 0, 0.07); .pic {
// border-radius: 20px; // 元素
// 定位 width: $picWidth;
position: relative; height: $picHeight;
display: flex; background-image: url($picImage);
background-repeat: no-repeat;
.pic { background-size: cover;
// 元素 border-radius: 20px 0 0 20px;
width: $picWidth; // 定位
height: $picHeight; position: absolute;
background-image: url($picImage); top: 0;
background-repeat: no-repeat; left: 0;
background-size: 100% 100%; }
background-position: 0 0; .field {
position: relative; width: $fieldWidth;
height: $fieldHeight;
&::after { // 定位
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: $picWidth;
width: 100%; display:flex;
height: 100%; justify-content: center;
} align-items: center;
} .pc-title{ width: 100%; clear: both;}
.field { .mobile-title,
// background: #ccc3; .mobile-switch {
position: relative; display: none;
padding-top: 196px; }
flex: 1; .form {
display: flex; box-sizing: border-box;
flex-direction: column; width: $formWidth;
// justify-content: center; // - - - tab
align-items: center; :deep(.el-tabs__content) {
.pc-title { padding: 20px 0 0;
width: 100%; }
text-align: center; :deep(.el-tabs__item) {
clear: both; // 元素
position: relative; width: $tabWidth;
top: -36px; height: $rowHeight;
padding: 0;
// h3.title { // 文字
// position: relative; line-height: $rowHeight;
color: #666666;
// &::before { }
// content: ''; :deep(.el-tabs__item.is-active) {
// background: url($cnbmLogo) 100% / 100% no-repeat; font-weight: bold;
// height: 48px; color: #2F53EB;
// width: 48px; }
// position: absolute; :deep(.el-tabs__active-bar) {
// left: 0px; height: 3px;
// top: 4px; border-radius: 2px;
// display: inline-block; }
// } // - - - input
// } :deep(.el-input__inner) {
} // 元素
.mobile-title, width: 100%;
.mobile-switch { height: $rowHeight;
display: none; background: #f5f5f5;
} border: 0;
.form { border-radius: 28px;
margin-top: 32px; // 文字
box-sizing: border-box; text-align: center;
// width: $formWidth; line-height: 19px;
width: 100%; color: #262626;
// - - - tab }
:deep(.el-tabs__nav) { .code:deep(.el-input__inner) {
// background: #f0f3; padding: 0 24px;
} // 文字
:deep(.el-tabs__content) { text-align: left;
padding: 20px 0 0; }
} :deep(.el-input__inner::-webkit-input-placeholder) { /* WebKit browsers */
:deep(.el-tabs__item) { font-weight: 400;
user-select: none; color: #8C8C8C;
// 元素 }
width: $tabWidth; :deep(.el-input__inner:-moz-placeholder) { /* Mozilla Firefox 4 to 18 */
height: $rowHeight; font-weight: 400;
padding: 0; color: #8C8C8C;
// 文字 }
line-height: $rowHeight; :deep(.el-input__inner::-moz-placeholder) { /* Mozilla Firefox 19+ */
color: #666666; font-weight: 400;
font-size: 18px; color: #8C8C8C;
font-weight: 400; opacity:1;
text-align: center; }
} :deep(.el-input__inner:-ms-input-placeholder) { /* Internet Explorer 10+ */
:deep(.el-tabs__item.is-active) { font-weight: 400;
font-weight: 500; color: #8C8C8C !important;
color: #2f53eb; }
} :deep(.el-form-item) {
:deep(.el-tabs__active-bar) { position: relative;
height: 3px; .button-code {
border-radius: 2px; // 元素
} height: $rowHeight;
// - - - input box-sizing: border-box;
:deep(.el-input__inner) { // 定位
// 元素 position: absolute;
width: 100%; top: 0;
height: $rowHeight; right: 20px;
background: #f5f5f5; z-index: 1;
border: 0; // 文字
border-radius: 28px; line-height: 20px;
// 文字 font-size: 14px;
text-align: center; font-family: PingFang SC;
line-height: 19px; font-weight: 400;
color: #262626; color: #2F53EB;
} span {
.code:deep(.el-input__inner) { padding-left: 15px;
padding: 0 24px; border-left: 2px solid #D9D9D9;
// 文字 }
text-align: left; }
} }
:deep(.el-input__inner::-webkit-input-placeholder) { :deep(.el-form-item__error) {
/* WebKit browsers */ padding-left: 24px;
font-weight: 400; }
color: #8c8c8c; .button {
} width: 100%;
:deep(.el-input__inner:-moz-placeholder) { height: $buttonHeight;
/* Mozilla Firefox 4 to 18 */ background: rgba(24, 144, 255, 0.2);
font-weight: 400; border: 0;
color: #8c8c8c; border-radius: 24px;
} margin-bottom: 20px;
:deep(.el-input__inner::-moz-placeholder) { // 文字
/* Mozilla Firefox 19+ */ line-height: 26px;
font-weight: 400; font-size: 20px;
color: #8c8c8c; color: #FFFFFF;
opacity: 1; }
} .button-active {
:deep(.el-input__inner:-ms-input-placeholder) { background: #2F53EB;
/* Internet Explorer 10+ */ box-shadow: 0px 2px 8px rgba(0, 80, 184, 0.2);
font-weight: 400; }
color: #8c8c8c !important; }
} }
:deep(.el-form-item) { }
position: relative; .footer {
.button-code { // 元素
// 元素 height: 16px;
height: $rowHeight; line-height: 16px;
box-sizing: border-box; font-size: 12px;
// 定位 color: #8c8c8c;
position: absolute; // 定位
top: 0; position: absolute;
right: 20px; bottom: 30px;
z-index: 1; a,
// 文字 a:hover,
line-height: 20px; a:active {
font-size: 14px; color: inherit;
font-family: PingFang SC; text-decoration: none;
font-weight: 400; }
color: #2f53eb; }
span {
padding-left: 15px;
border-left: 2px solid #d9d9d9;
}
}
}
:deep(.el-form-item__error) {
padding-left: 24px;
}
.button {
width: 100%;
height: $buttonHeight;
background: rgba(24, 144, 255, 0.2);
border: 0;
border-radius: 24px;
margin-bottom: 20px;
// 文字
line-height: 26px;
font-size: 20px;
color: #ffffff;
}
.button-active {
background: #2f53eb;
box-shadow: 0px 2px 8px rgba(0, 80, 184, 0.2);
}
}
}
}
.login-form {
* {
user-select: none;
}
// - - - input
:deep(.el-input__inner) {
// 元素
width: 420px;
height: 66px;
color: #262626;
font-size: 18px;
}
:deep(.el-checkbox__label) {
font-size: 18px;
line-height: 14px;
}
}
.footer {
user-select: none;
// 元素
height: 16px;
line-height: 16px;
font-size: 12px;
color: #8c8c8c;
// 定位
position: absolute;
bottom: 30px;
a,
a:hover,
a:active {
color: inherit;
text-decoration: none;
}
}
} }
// - - - - - PC 最小尺寸设置 // - - - - - PC 最小尺寸设置
@media screen and (min-width: 599px) and (max-width: 1366px) { @media screen and (min-width: 599px) and (max-width: 1366px) {
.container { .container {
min-width: 599px; .content {
.content { width: 710px;
// width: 710px; height: 397px;
// height: 397px; .pic {
width: 100%; width: 314px;
height: 100%; }
.pic { .field {
// width: 314px; width: calc(710px - 314px);
display: none; left: 314px;
} .form {
.field { width: 320px;
// width: calc(710px - 314px); :deep(.el-input__inner) {
// left: 314px; width: 320px;
// justify-content: center; height: 56px;
width: 100%; }
.button {
.pc-title { height: 50px;
h3 { }
font-size: 2.4rem !important; }
} }
} }
}
.form {
// width: 320px;
:deep(.el-input__inner) {
width: 320px;
height: 56px;
}
.button {
height: 50px;
}
}
}
}
}
} }
/* ===== MOBILE DESIGN ===== */ /* ===== MOBILE DESIGN ===== */
$mobileW: 375; $mobileW: 375;
$mobileH: 812; $mobileH: 812;
@ -354,142 +273,115 @@ $mobileButtonH: 48;
$mobileContainerBgImage: '../assets/images/bg-mobile.png'; $mobileContainerBgImage: '../assets/images/bg-mobile.png';
// container-content // container-content
$mobileContentWidth: round($mobileContentW / $mobileW * 100) * 1vw; $mobileContentWidth: round($mobileContentW / $mobileW * 100) * 1vw;
$mobileContentHeight: round($mobileContentH / $mobileW * 100) / 100 * $mobileContentHeight: round($mobileContentH / $mobileW * 100) / 100 * $mobileContentWidth;
$mobileContentWidth;
// container-content-field-form // container-content-field-form
$mobileFormWidth: round($mobileFormW / $mobileW * 100) * 1vw; $mobileFormWidth: round($mobileFormW / $mobileW *100) * 1vw;
$mobileRowHeight: $mobileRowH * 1px; $mobileRowHeight: $mobileRowH * 1px;
$mobileButtonHeight: $mobileButtonH * 1px; $mobileButtonHeight: $mobileButtonH * 1px;
$iconBgImage: '../assets/images/icon.png'; $iconBgImage: '../assets/images/icon.png';
// - - - - - 移动端设置 // - - - - - 移动端设置
@media screen and (max-width: 599px) { @media screen and (max-width: 599px) {
.container { .container {
// 元素 // 元素
background-image: url($mobileContainerBgImage); background-image: url($mobileContainerBgImage);
min-width: 280px; min-width: 280px;
min-height: 568px; min-height: 568px;
// 文字 // 文字
font-size: 14px; font-size: 17px;
font-family: PingFang SC; font-family: PingFang SC;
font-weight: bold; font-weight: bold;
.logo { .logo {
display: none; display: none;
} }
.pc-title { .content {
display: none; // 元素
} width: $mobileContentWidth;
height: $mobileContentHeight;
.content { min-width: 250px;
// 元素 min-height: 340px;
width: $mobileContentWidth; // 定位
height: $mobileContentHeight; display: flex;
min-width: 250px; justify-content: center;
min-height: 340px; align-items: center;
// 定位 .pic {
display: flex; display: none;
justify-content: center; }
align-items: center; .field {
.pic { // 元素
display: none; width: inherit;
} min-height: inherit;
.field { // 定位
padding: 0; left: 0;
// 元素 display: flex;
width: inherit; flex-direction: column;
min-height: inherit; .mobile-title {
// 定位 // 元素
left: 0; margin: 0 0 20px;
display: flex; display: block;
flex-direction: column; }
.form {
.mobile-title { width: $mobileFormWidth;
// 元素 // - - - tab
margin: 0; :deep(.el-tabs__header) {
display: block; display: none;
} }
:deep(.el-tabs__content) {
.form { padding: 0;
}
// - - - input
:deep(.el-input__inner) {
height: $mobileRowHeight;
line-height: 24px;
// 文字
text-align: center;
color: #262626;
}
:deep(.el-form-item) {
.button-code {
// 元素
height: $mobileRowHeight;
}
}
.button {
height: $mobileButtonHeight;
line-height: 24px;
color: #FFFFFF;
}
}
.mobile-switch {
display: block;
line-height: 20px;
font-size: 14px;
font-weight: 400;
color: #595959;
margin: 0; margin: 0;
width: $mobileFormWidth; .icon {
// - - - tab width: 14px;
:deep(.el-tabs__header) { height: 14px;
display: none; display: inline-block;
} background-image: url($iconBgImage);
:deep(.el-tabs__content) { background-size: cover;
padding: 0; }
} }
// - - - input .mobile-switch:hover {
:deep(.el-input__inner) { cursor: pointer;
height: $mobileRowHeight; }
line-height: 24px; }
// 文字 }
text-align: center; .footer {
color: #262626; // 元素
} font-size: 12px;
:deep(.el-form-item) { font-family: PingFang SC;
.button-code { font-weight: 400;
// 元素 line-height: 17px;
height: $mobileRowHeight; color: #333333;
} opacity: 0.6;
} // 定位
.button { position: absolute;
height: $mobileButtonHeight; bottom: 20px;
line-height: 24px; }
color: #ffffff; }
}
}
.login-form {
:deep(.el-input__inner) {
height: $mobileRowHeight;
line-height: 24px;
// 文字
text-align: center;
color: #262626;
}
:deep(#button-form-item) {
margin: 0 !important;
button {
// 元素
height: $mobileRowHeight;
}
}
}
.mobile-switch {
display: block;
line-height: 20px;
font-size: 14px;
font-weight: 400;
color: #595959;
margin: 0;
.icon {
width: 14px;
height: 14px;
display: inline-block;
background-image: url($iconBgImage);
background-size: cover;
}
}
.mobile-switch:hover {
cursor: pointer;
}
}
}
.footer {
// 元素
font-size: 12px;
font-family: PingFang SC;
font-weight: 400;
line-height: 17px;
color: #333333;
opacity: 0.6;
// 定位
// position: absolute;
bottom: -32px;
}
}
} }

View File

@ -1,238 +1,81 @@
<template xmlns=""> <template xmlns="">
<div class="container"> <div class="container">
<div class="logo"></div> <div class="logo"></div>
<!-- 登录区域 --> <!-- 登录区域 -->
<div class="content"> <div class="content">
<!-- 配图 --> <!-- 配图 -->
<div class="pic"> <div class="pic"></div>
<div <!-- 表单 -->
class="welcome" <div class="field">
style=" <!-- [移动端]标题 -->
position: absolute; <h2 class="mobile-title">
top: 15%; <h3 class="title">芋道后台管理系统</h3>
left: 20%; </h2>
user-select: none;
display: flex;
flex-direction: column;
align-items: flex-start;
">
<strong
style="
letter-spacing: 1px;
font-family: Arial, Helvetica, sans-serif;
font-weight: 500;
font-size: 88px;
">
<span style="color: #26b9de">Wel</span>
<span style="color: #fff">come</span>
</strong>
<p
style="
margin: 0;
font-size: 26px;
letter-spacing: 1px;
color: #26b9de;
opacity: 75%;
">
<span
style="
display: inline-block;
height: 20px;
width: 20px;
margin-left: 8px;
margin-right: 12px;
border-radius: 100%;
background: #26b9de;
"></span>
产线生产监控系统
</p>
</div>
<video
src="/static/videos/login.webm"
muted
autoplay
loop
style="
user-select: none;
position: absolute;
top: 28%;
width: 100%;
height: 70%;
"></video>
</div>
<!-- 表单 -->
<div class="field">
<!-- [移动端]标题 -->
<h2 class="mobile-title">
<h3 class="title">中建材智能自动化研究院有限公司</h3>
</h2>
<h2 class="pc-title" style="">
<h3
class="title"
style="
margin: 0;
margin-left: 32px;
font-weight: 400;
user-select: none;
color: #000;
font-size: 36px;
line-height: 54px;
letter-spacing: 2px;
">
<img
src="../assets/logo/cnbm.png"
alt="cnbm_logo"
style="
height: 48px;
width: 48px;
position: relative;
top: 12px;
right: 8px;
" />
<span>中建材智能自动化研究院有限公司</span>
</h3>
<h3
class="sub-title"
style="
margin: 0;
margin-left: 32px;
font-weight: 400;
user-select: none;
color: #000;
font-size: 36px;
line-height: 54px;
letter-spacing: 2px;
">
产线生产监控系统
</h3>
</h2>
<!-- 表单 --> <!-- 表单 -->
<div class="form-cont"> <div class="form-cont">
<el-tabs <el-tabs class="form" v-model="loginForm.loginType" style=" float:none;">
class="form" <el-tab-pane label="账号密码登录" name="uname">
v-model="loginForm.loginType" </el-tab-pane>
style="float: none"> <el-tab-pane label="短信验证码登录" name="sms">
<el-tab-pane label="账号密码登录" name="uname"></el-tab-pane> </el-tab-pane>
<el-tab-pane label="短信验证码登录" name="sms"></el-tab-pane> </el-tabs>
</el-tabs> <div>
<div style=""> <el-form ref="loginForm" :model="loginForm" :rules="LoginRules" class="login-form">
<el-form <el-form-item prop="tenantName" v-if="tenantEnable">
ref="loginForm" <el-input v-model="loginForm.tenantName" type="text" auto-complete="off" placeholder='租户'>
:model="loginForm" <svg-icon slot="prefix" icon-class="tree" class="el-input__icon input-icon" />
:rules="LoginRules" </el-input>
class="login-form"> </el-form-item>
<el-form-item prop="tenantName" v-if="tenantEnable"> <!-- 账号密码登录 -->
<el-input <div v-if="loginForm.loginType === 'uname'">
v-model="loginForm.tenantName" <el-form-item prop="username">
type="text" <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
auto-complete="off" <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
placeholder="租户"> </el-input>
<!-- <svg-icon </el-form-item>
slot="prefix" <el-form-item prop="password">
icon-class="tree" <el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码"
class="el-input__icon input-icon" /> --> @keyup.enter.native="getCode">
</el-input> <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-form-item> </el-input>
<!-- 账号密码登录 --> </el-form-item>
<div v-if="loginForm.loginType === 'uname'"> <el-checkbox v-model="loginForm.rememberMe" style="margin:0 0 25px 0;">记住密码</el-checkbox>
<el-form-item prop="username"> </div>
<el-input
v-model="loginForm.username"
type="text"
auto-complete="off"
placeholder="账号">
<!-- <svg-icon
slot="prefix"
icon-class="user"
class="el-input__icon input-icon" /> -->
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="loginForm.password"
type="password"
auto-complete="off"
placeholder="密码"
@keyup.enter.native="getCode">
<!-- <svg-icon
slot="prefix"
icon-class="password"
class="el-input__icon input-icon" /> -->
</el-input>
</el-form-item>
<el-checkbox
v-model="loginForm.rememberMe"
style="margin: 0 0 25px 0">
记住密码
</el-checkbox>
</div>
<!-- 短信验证码登录 --> <!-- 短信验证码登录 -->
<div v-if="loginForm.loginType === 'sms'"> <div v-if="loginForm.loginType === 'sms'">
<el-form-item prop="mobile"> <el-form-item prop="mobile">
<el-input <el-input v-model="loginForm.mobile" type="text" auto-complete="off" placeholder="请输入手机号">
v-model="loginForm.mobile" <svg-icon slot="prefix" icon-class="phone" class="el-input__icon input-icon" />
type="text" </el-input>
auto-complete="off" </el-form-item>
placeholder="请输入手机号"> <el-form-item prop="mobileCode">
<!-- <svg-icon <el-input v-model="loginForm.mobileCode" type="text" auto-complete="off" placeholder="短信验证码"
slot="prefix" class="sms-login-mobile-code-prefix" @keyup.enter.native="handleLogin">
icon-class="phone" <template>
class="el-input__icon input-icon" /> --> <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input> </template>
</el-form-item> <template slot="append">
<el-form-item prop="mobileCode"> <span v-if="mobileCodeTimer <= 0" class="getMobileCode" @click="getSmsCode"
<el-input style="cursor: pointer;">获取验证码</span>
v-model="loginForm.mobileCode" <span v-if="mobileCodeTimer > 0" class="getMobileCode">{{ mobileCodeTimer }}秒后可重新获取</span>
type="text" </template>
auto-complete="off" </el-input>
placeholder="短信验证码" </el-form-item>
class="sms-login-mobile-code-prefix" </div>
@keyup.enter.native="handleLogin">
<!-- <template>
<svg-icon
slot="prefix"
icon-class="password"
class="el-input__icon input-icon" />
</template> -->
<template slot="suffix">
<span
v-if="mobileCodeTimer <= 0"
class="getMobileCode"
@click="getSmsCode"
style="
cursor: pointer;
color: #0b58ff;
font-size: 18px;
line-height: 66px;
padding-right: 12px;
">
获取验证码
</span>
<span v-if="mobileCodeTimer > 0" class="getMobileCode">
{{ mobileCodeTimer }}秒后可重新获取
</span>
</template>
</el-input>
</el-form-item>
</div>
<!-- 下方的登录按钮 --> <!-- 下方的登录按钮 -->
<el-form-item id="button-form-item" style="width: 100%; margin-top: 32px"> <el-form-item style="width:100%;">
<el-button <el-button :loading="loading" size="medium" type="primary" style="width:100%;"
:loading="loading" @click.native.prevent="getCode">
size="medium" <span v-if="!loading"> </span>
type="primary" <span v-else> 中...</span>
style="width: 100%; height: 66px; font-size: 18px;" </el-button>
@click.native.prevent="getCode"> </el-form-item>
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
</el-form-item>
<!-- 社交登录 --> <!-- 社交登录 -->
<!-- <el-form-item style="width:100%;"> <!-- <el-form-item style="width:100%;">
<div class="oauth-login" style="display:flex"> <div class="oauth-login" style="display:flex">
<div class="oauth-login-item" v-for="item in SysUserSocialTypeEnum" :key="item.type" @click="doSocialLogin(item)"> <div class="oauth-login-item" v-for="item in SysUserSocialTypeEnum" :key="item.type" @click="doSocialLogin(item)">
<img :src="item.img" height="25px" width="25px" alt="登录" > <img :src="item.img" height="25px" width="25px" alt="登录" >
@ -240,305 +83,265 @@
</div> </div>
</div> </div>
</el-form-item> --> </el-form-item> -->
</el-form> </el-form>
</div> </div>
</div> </div>
</div>
</div>
<!-- footer --> <!-- 图形验证码 -->
<div class="footer"> <Verify ref="verify" :captcha-type="'blockPuzzle'" :img-size="{ width: '400px', height: '200px' }"
Copyright © 2023 中建材智能自动化院 All Rights Reserved. @success="handleLogin" />
</div>
</div>
</div>
<!-- 图形验证码 --> <!-- footer -->
<Verify <div class="footer">
ref="verify" Copyright © 2023 中建材智能自动化院 All Rights Reserved.
:captcha-type="'blockPuzzle'" </div>
:img-size="{ width: '400px', height: '200px' }" </div>
@success="handleLogin" />
</div>
</template> </template>
<script> <script>
import { sendSmsCode, socialAuthRedirect } from '@/api/login'; import { sendSmsCode, socialAuthRedirect } from "@/api/login";
import { getTenantIdByName } from '@/api/system/tenant'; import { getTenantIdByName } from "@/api/system/tenant";
import { SystemUserSocialTypeEnum } from '@/utils/constants'; import { SystemUserSocialTypeEnum } from "@/utils/constants";
import { getCaptchaEnable, getTenantEnable } from '@/utils/ruoyi'; import { getCaptchaEnable, getTenantEnable } from "@/utils/ruoyi";
import { import {
getPassword, getPassword,
getRememberMe, getRememberMe, getTenantName,
getTenantName, getUsername,
getUsername, removePassword, removeRememberMe, removeTenantName,
removePassword, removeUsername,
removeRememberMe, setPassword, setRememberMe, setTenantId, setTenantName,
removeTenantName, setUsername
removeUsername, } from "@/utils/auth";
setPassword,
setRememberMe,
setTenantId,
setTenantName,
setUsername,
} from '@/utils/auth';
import Verify from '@/components/Verifition/Verify'; import Verify from '@/components/Verifition/Verify';
import { resetUserPwd } from '@/api/system/user'; import { resetUserPwd } from "@/api/system/user";
export default { export default {
name: 'Login', name: "Login",
components: { components: {
Verify, Verify
}, },
data() { data() {
return { return {
codeUrl: '', codeUrl: "",
captchaEnable: true, captchaEnable: true,
tenantEnable: true, tenantEnable: true,
mobileCodeTimer: 0, mobileCodeTimer: 0,
loginForm: { loginForm: {
loginType: 'uname', loginType: "uname",
username: 'admin', username: "admin",
password: 'admin123', password: "admin123",
captchaVerification: '', captchaVerification: "",
mobile: '', mobile: "",
mobileCode: '', mobileCode: "",
rememberMe: false, rememberMe: false,
tenantName: '技术中心', tenantName: "技术中心",
}, },
scene: 21, scene: 21,
LoginRules: { LoginRules: {
username: [ username: [
{ required: true, trigger: 'blur', message: '用户名不能为空' }, { required: true, trigger: "blur", message: "用户名不能为空" }
], ],
password: [ password: [
{ required: true, trigger: 'blur', message: '密码不能为空' }, { required: true, trigger: "blur", message: "密码不能为空" }
], ],
mobile: [ mobile: [
{ required: true, trigger: 'blur', message: '手机号不能为空' }, { required: true, trigger: "blur", message: "手机号不能为空" },
{ {
validator: function (rule, value, callback) { validator: function (rule, value, callback) {
if ( if (/^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/.test(value) === false) {
/^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/.test( callback(new Error("手机号格式错误"));
value } else {
) === false callback();
) { }
callback(new Error('手机号格式错误')); }, trigger: "blur"
} else { }
callback(); ],
} tenantName: [
}, { required: true, trigger: "blur", message: "租户不能为空" },
trigger: 'blur', {
}, validator: (rule, value, callback) => {
], // debugger
tenantName: [ getTenantIdByName(value).then(res => {
{ required: true, trigger: 'blur', message: '租户不能为空' }, const tenantId = res.data;
{ if (tenantId && tenantId >= 0) {
validator: (rule, value, callback) => { //
// debugger setTenantId(tenantId)
getTenantIdByName(value).then((res) => { callback();
const tenantId = res.data; } else {
if (tenantId && tenantId >= 0) { callback('租户不存在');
// }
setTenantId(tenantId); });
callback(); },
} else { trigger: 'blur'
callback('租户不存在'); }
} ]
}); },
}, loading: false,
trigger: 'blur', redirect: undefined,
}, //
], SysUserSocialTypeEnum: SystemUserSocialTypeEnum,
}, };
loading: false, },
redirect: undefined, created() {
// //
SysUserSocialTypeEnum: SystemUserSocialTypeEnum, this.tenantEnable = getTenantEnable();
}; if (this.tenantEnable) {
}, getTenantIdByName(this.loginForm.tenantName).then(res => { //
created() { const tenantId = res.data;
// if (tenantId && tenantId >= 0) {
this.tenantEnable = getTenantEnable(); setTenantId(tenantId)
if (this.tenantEnable) { }
getTenantIdByName(this.loginForm.tenantName).then((res) => { });
// }
const tenantId = res.data; //
if (tenantId && tenantId >= 0) { this.captchaEnable = getCaptchaEnable();
setTenantId(tenantId); //
} this.redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : undefined;
}); this.getCookie();
} },
// methods: {
this.captchaEnable = getCaptchaEnable(); getCode() {
// //
this.redirect = this.$route.query.redirect if (!this.captchaEnable) {
? decodeURIComponent(this.$route.query.redirect) this.handleLogin({})
: undefined; return;
this.getCookie(); }
},
methods: {
getCode() {
//
if (!this.captchaEnable) {
this.handleLogin({});
return;
}
// //
// //
this.$refs.verify.show(); this.$refs.verify.show()
}, },
getCookie() { getCookie() {
const username = getUsername(); const username = getUsername();
const password = getPassword(); const password = getPassword();
const rememberMe = getRememberMe(); const rememberMe = getRememberMe();
const tenantName = getTenantName(); const tenantName = getTenantName();
this.loginForm = { this.loginForm = {
...this.loginForm, ...this.loginForm,
username: username ? username : this.loginForm.username, username: username ? username : this.loginForm.username,
password: password ? password : this.loginForm.password, password: password ? password : this.loginForm.password,
rememberMe: rememberMe ? getRememberMe() : false, rememberMe: rememberMe ? getRememberMe() : false,
tenantName: tenantName ? tenantName : this.loginForm.tenantName, tenantName: tenantName ? tenantName : this.loginForm.tenantName,
}; };
}, },
handleLogin(captchaParams) { handleLogin(captchaParams) {
this.$refs.loginForm.validate((valid) => { this.$refs.loginForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true; this.loading = true;
// Cookie // Cookie
if (this.loginForm.rememberMe) { if (this.loginForm.rememberMe) {
setUsername(this.loginForm.username); setUsername(this.loginForm.username)
setPassword(this.loginForm.password); setPassword(this.loginForm.password)
setRememberMe(this.loginForm.rememberMe); setRememberMe(this.loginForm.rememberMe)
setTenantName(this.loginForm.tenantName); setTenantName(this.loginForm.tenantName)
} else { } else {
removeUsername(); removeUsername()
removePassword(); removePassword()
removeRememberMe(); removeRememberMe()
removeTenantName(); removeTenantName()
} }
this.loginForm.captchaVerification = this.loginForm.captchaVerification = captchaParams.captchaVerification
captchaParams.captchaVerification; //
// // console.log("", this.loginForm);
// console.log("", this.loginForm); this.$store.dispatch(this.loginForm.loginType === "sms" ? "SmsLogin" : "Login", this.loginForm).then(() => {
this.$store this.$router.push({ path: this.redirect || "/" }).catch(() => {
.dispatch( });
this.loginForm.loginType === 'sms' ? 'SmsLogin' : 'Login', }).catch(() => {
this.loginForm this.loading = false;
) });
.then(() => { }
this.$router.push({ path: this.redirect || '/' }).catch(() => {}); });
}) },
.catch(() => { async doSocialLogin(socialTypeEnum) {
this.loading = false; //
}); this.loading = true;
} let tenant = false;
}); if (this.tenantEnable) {
}, await this.$prompt('请输入租户名称', "提示", {
async doSocialLogin(socialTypeEnum) { confirmButtonText: "确定",
// cancelButtonText: "取消"
this.loading = true; }).then(async ({ value }) => {
let tenant = false; await getTenantIdByName(value).then(res => {
if (this.tenantEnable) { const tenantId = res.data;
await this.$prompt('请输入租户名称', '提示', { tenant = true
confirmButtonText: '确定', if (tenantId && tenantId >= 0) {
cancelButtonText: '取消', setTenantId(tenantId)
}) }
.then(async ({ value }) => { });
await getTenantIdByName(value).then((res) => { }).catch(() => {
const tenantId = res.data; // loading
tenant = true; this.loading = false;
if (tenantId && tenantId >= 0) {
setTenantId(tenantId);
}
});
})
.catch(() => {
// loading
this.loading = false;
return false; return false
}); });
} else { } else {
tenant = true; tenant = true
} }
if (tenant) { if (tenant) {
// redirectUri // redirectUri
const redirectUri = const redirectUri = location.origin + '/social-login?'
location.origin + + encodeURIComponent('type=' + socialTypeEnum.type + '&redirect=' + (this.redirect || "/")); //
'/social-login?' + // const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback';
encodeURIComponent( // const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback';
'type=' + //
socialTypeEnum.type + socialAuthRedirect(socialTypeEnum.type, encodeURIComponent(redirectUri)).then((res) => {
'&redirect=' + // console.log(res.url);
(this.redirect || '/') window.location.href = res.data;
); // });
// const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback'; }
// const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback'; },
// /** ========== 以下为升级短信登录 ========== */
socialAuthRedirect( getSmsCode() {
socialTypeEnum.type, if (this.mobileCodeTimer > 0) return;
encodeURIComponent(redirectUri) this.$refs.loginForm.validate(valid => {
).then((res) => { if (!valid) return;
// console.log(res.url); sendSmsCode(this.loginForm.mobile, this.scene, this.loginForm.uuid, this.loginForm.code).then(res => {
window.location.href = res.data; this.$modal.msgSuccess("获取验证码成功")
}); this.mobileCodeTimer = 60;
} let msgTimer = setInterval(() => {
}, this.mobileCodeTimer = this.mobileCodeTimer - 1;
/** ========== 以下为升级短信登录 ========== */ if (this.mobileCodeTimer <= 0) {
getSmsCode() { clearInterval(msgTimer);
if (this.mobileCodeTimer > 0) return; }
this.$refs.loginForm.validate((valid) => { }, 1000);
if (!valid) return; });
sendSmsCode( });
this.loginForm.mobile, }
this.scene, }
this.loginForm.uuid,
this.loginForm.code
).then((res) => {
this.$modal.msgSuccess('获取验证码成功');
this.mobileCodeTimer = 60;
let msgTimer = setInterval(() => {
this.mobileCodeTimer = this.mobileCodeTimer - 1;
if (this.mobileCodeTimer <= 0) {
clearInterval(msgTimer);
}
}, 1000);
});
});
},
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '~@/assets/styles/login.scss'; @import "~@/assets/styles/login.scss";
.oauth-login { .oauth-login {
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
} }
.oauth-login-item { .oauth-login-item {
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 10px; margin-right: 10px;
} }
.oauth-login-item img { .oauth-login-item img {
height: 25px; height: 25px;
width: 25px; width: 25px;
} }
.oauth-login-item span:hover { .oauth-login-item span:hover {
text-decoration: underline red; text-decoration: underline red;
color: red; color: red;
} }
.sms-login-mobile-code-prefix { .sms-login-mobile-code-prefix {
:deep(.el-input__prefix) { :deep(.el-input__prefix) {
top: 22%; top: 22%;
} }
} }</style>
</style>