projects/line-lb #72

Merged
g7hoo merged 2 commits from projects/line-lb into projects/line-test 2023-11-14 09:22:16 +08:00
5 changed files with 939 additions and 631 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

BIN
src/assets/logo/cnbm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,10 +1,13 @@
/* ===== PC DESIGN ===== */ /* ===== PC DESIGN ===== */
$W: 1000; $W: 1080;
$H: 1920; $H: 1920;
$picW: 438; // $picW: 438;
$picH: 560; // $picH: 560;
$formW: 320; $picW: 1080;
$picH: 1118;
$formW: 420;
$tabW: $formW / 2; $tabW: $formW / 2;
// $rowH: 56;
$rowH: 56; $rowH: 56;
$buttonH: 50; $buttonH: 50;
@ -15,6 +18,7 @@ $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;
@ -22,7 +26,8 @@ $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;
@ -34,231 +39,310 @@ $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%;max-width:100px; height:auto; width: 100%;
vertical-align: middle; max-width: 100px;
} height: auto;
} vertical-align: middle;
// 元素 }
width: inherit; }
height: inherit; // 元素
min-width: 1080px; width: inherit;
min-height: 620px; height: inherit;
background-color: $containerBgColor; min-width: 1080px;
background-image: url($containerBgImage); min-height: 620px;
background-size: cover; background-color: $containerBgColor;
// 定位 // background-image: url($containerBgImage);
position: relative; background-size: cover;
display: flex; // 定位
justify-content: center; position: relative;
align-items: center; display: flex;
// 文字 justify-content: center;
font-size: 14px; align-items: center;
font-family: Microsoft YaHei; // 文字
font-weight: 400; font-size: 14px;
.logo { font-family: Microsoft YaHei;
// 元素 font-weight: 400;
width: $logoWidth; .logo {
height: $logoHeight; // 元素
// background-image: url($logoImage); width: $logoWidth;
// background-size: contain; height: $logoHeight;
// 定位 // background-image: url($logoImage);
position: absolute; // background-size: contain;
top: 50px; // 定位
left: 50%; position: absolute;
margin-left: -$logoWidth/2; top: 50px;
} left: 50%;
.content { margin-left: -$logoWidth/2;
// 元素 }
width: $contentWidth; .content {
height: $contentHeight; // 元素
background-color: #ffffff; // width: $contentWidth;
box-shadow: 0px 16px 40px rgba(0, 0, 0, 0.07); // height: $contentHeight;
border-radius: 20px; width: 100%;
// 定位 height: 100%;
position: relative; background-color: #ffffff;
.pic { // box-shadow: 0px 16px 40px rgba(0, 0, 0, 0.07);
// 元素 // border-radius: 20px;
width: $picWidth; // 定位
height: $picHeight; position: relative;
background-image: url($picImage); display: flex;
background-repeat: no-repeat;
background-size: cover; .pic {
border-radius: 20px 0 0 20px; // 元素
// 定位 width: $picWidth;
position: absolute; height: $picHeight;
top: 0; background-image: url($picImage);
left: 0; background-repeat: no-repeat;
} background-size: 100% 100%;
.field { background-position: 0 0;
width: $fieldWidth; position: relative;
height: $fieldHeight;
// 定位 &::after {
position: absolute; content: '';
top: 0; position: absolute;
left: $picWidth; top: 0;
display:flex; left: 0;
justify-content: center; width: 100%;
align-items: center; height: 100%;
.pc-title{ width: 100%; clear: both;} // background: #f003;
.mobile-title, display: inline-block;
.mobile-switch { }
display: none; }
} .field {
.form { // background: #ccc3;
box-sizing: border-box; position: relative;
width: $formWidth; padding-top: 196px;
// - - - tab flex: 1;
:deep(.el-tabs__content) { display: flex;
padding: 20px 0 0; flex-direction: column;
} // justify-content: center;
:deep(.el-tabs__item) { align-items: center;
// 元素 .pc-title {
width: $tabWidth; width: 100%;
height: $rowHeight; text-align: center;
padding: 0; clear: both;
// 文字 position: relative;
line-height: $rowHeight; top: -36px;
color: #666666;
} // h3.title {
:deep(.el-tabs__item.is-active) { // position: relative;
font-weight: bold;
color: #2F53EB; // &::before {
} // content: '';
:deep(.el-tabs__active-bar) { // background: url($cnbmLogo) 100% / 100% no-repeat;
height: 3px; // height: 48px;
border-radius: 2px; // width: 48px;
} // position: absolute;
// - - - input // left: 0px;
:deep(.el-input__inner) { // top: 4px;
// 元素 // display: inline-block;
width: 100%; // }
height: $rowHeight; // }
background: #f5f5f5; }
border: 0; .mobile-title,
border-radius: 28px; .mobile-switch {
// 文字 display: none;
text-align: center; }
line-height: 19px; .form {
color: #262626; margin-top: 32px;
} box-sizing: border-box;
.code:deep(.el-input__inner) { // width: $formWidth;
padding: 0 24px; width: 100%;
// 文字 // - - - tab
text-align: left; :deep(.el-tabs__nav) {
} // background: #f0f3;
:deep(.el-input__inner::-webkit-input-placeholder) { /* WebKit browsers */ }
font-weight: 400; :deep(.el-tabs__content) {
color: #8C8C8C; padding: 20px 0 0;
} }
:deep(.el-input__inner:-moz-placeholder) { /* Mozilla Firefox 4 to 18 */ :deep(.el-tabs__item) {
font-weight: 400; user-select: none;
color: #8C8C8C; // 元素
} width: $tabWidth;
:deep(.el-input__inner::-moz-placeholder) { /* Mozilla Firefox 19+ */ height: $rowHeight;
font-weight: 400; padding: 0;
color: #8C8C8C; // 文字
opacity:1; line-height: $rowHeight;
} color: #666666;
:deep(.el-input__inner:-ms-input-placeholder) { /* Internet Explorer 10+ */ font-size: 18px;
font-weight: 400; font-weight: 400;
color: #8C8C8C !important; text-align: center;
} }
:deep(.el-form-item) { :deep(.el-tabs__item.is-active) {
position: relative; font-weight: 500;
.button-code { color: #2f53eb;
// 元素 }
height: $rowHeight; :deep(.el-tabs__active-bar) {
box-sizing: border-box; height: 3px;
// 定位 border-radius: 2px;
position: absolute; }
top: 0; // - - - input
right: 20px; :deep(.el-input__inner) {
z-index: 1; // 元素
// 文字 width: 100%;
line-height: 20px; height: $rowHeight;
font-size: 14px; background: #f5f5f5;
font-family: PingFang SC; border: 0;
font-weight: 400; border-radius: 28px;
color: #2F53EB; // 文字
span { text-align: center;
padding-left: 15px; line-height: 19px;
border-left: 2px solid #D9D9D9; color: #262626;
} }
} .code:deep(.el-input__inner) {
} padding: 0 24px;
:deep(.el-form-item__error) { // 文字
padding-left: 24px; text-align: left;
} }
.button { :deep(.el-input__inner::-webkit-input-placeholder) {
width: 100%; /* WebKit browsers */
height: $buttonHeight; font-weight: 400;
background: rgba(24, 144, 255, 0.2); color: #8c8c8c;
border: 0; }
border-radius: 24px; :deep(.el-input__inner:-moz-placeholder) {
margin-bottom: 20px; /* Mozilla Firefox 4 to 18 */
// 文字 font-weight: 400;
line-height: 26px; color: #8c8c8c;
font-size: 20px; }
color: #FFFFFF; :deep(.el-input__inner::-moz-placeholder) {
} /* Mozilla Firefox 19+ */
.button-active { font-weight: 400;
background: #2F53EB; color: #8c8c8c;
box-shadow: 0px 2px 8px rgba(0, 80, 184, 0.2); opacity: 1;
} }
} :deep(.el-input__inner:-ms-input-placeholder) {
} /* Internet Explorer 10+ */
} font-weight: 400;
.footer { color: #8c8c8c !important;
// 元素 }
height: 16px; :deep(.el-form-item) {
line-height: 16px; position: relative;
font-size: 12px; .button-code {
color: #8c8c8c; // 元素
// 定位 height: $rowHeight;
position: absolute; box-sizing: border-box;
bottom: 30px; // 定位
a, position: absolute;
a:hover, top: 0;
a:active { right: 20px;
color: inherit; z-index: 1;
text-decoration: none; // 文字
} line-height: 20px;
} font-size: 14px;
font-family: PingFang SC;
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 {
.content { min-width: 599px;
width: 710px; .content {
height: 397px; // width: 710px;
.pic { // height: 397px;
width: 314px; width: 100%;
} height: 100%;
.field { .pic {
width: calc(710px - 314px); // width: 314px;
left: 314px; display: none;
.form { }
width: 320px; .field {
:deep(.el-input__inner) { // width: calc(710px - 314px);
width: 320px; // left: 314px;
height: 56px; // justify-content: center;
} width: 100%;
.button {
height: 50px;
}
}
}
}
}
}
.pc-title {
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;
@ -273,115 +357,142 @@ $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 * $mobileContentWidth; $mobileContentHeight: round($mobileContentH / $mobileW * 100) / 100 *
$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: 17px; font-size: 14px;
font-family: PingFang SC; font-family: PingFang SC;
font-weight: bold; font-weight: bold;
.logo { .logo {
display: none; display: none;
} }
.content { .pc-title {
// 元素 display: none;
width: $mobileContentWidth; }
height: $mobileContentHeight;
min-width: 250px; .content {
min-height: 340px; // 元素
// 定位 width: $mobileContentWidth;
display: flex; height: $mobileContentHeight;
justify-content: center; min-width: 250px;
align-items: center; min-height: 340px;
.pic { // 定位
display: none; display: flex;
} justify-content: center;
.field { align-items: center;
// 元素 .pic {
width: inherit; display: none;
min-height: inherit; }
// 定位 .field {
left: 0; padding: 0;
display: flex; // 元素
flex-direction: column; width: inherit;
.mobile-title { min-height: inherit;
// 元素 // 定位
margin: 0 0 20px; left: 0;
display: block; display: flex;
} flex-direction: column;
.form {
width: $mobileFormWidth; .mobile-title {
// - - - tab // 元素
:deep(.el-tabs__header) { margin: 0;
display: none; display: block;
} }
:deep(.el-tabs__content) {
padding: 0; .form {
}
// - - - 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;
.icon { width: $mobileFormWidth;
width: 14px; // - - - tab
height: 14px; :deep(.el-tabs__header) {
display: inline-block; display: none;
background-image: url($iconBgImage); }
background-size: cover; :deep(.el-tabs__content) {
} padding: 0;
} }
.mobile-switch:hover { // - - - input
cursor: pointer; :deep(.el-input__inner) {
} height: $mobileRowHeight;
} line-height: 24px;
} // 文字
.footer { text-align: center;
// 元素 color: #262626;
font-size: 12px; }
font-family: PingFang SC; :deep(.el-form-item) {
font-weight: 400; .button-code {
line-height: 17px; // 元素
color: #333333; height: $mobileRowHeight;
opacity: 0.6; }
// 定位 }
position: absolute; .button {
bottom: 20px; height: $mobileButtonHeight;
} 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,81 +1,238 @@
<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> <div class="pic">
<!-- 表单 --> <div
<div class="field"> class="welcome"
<!-- [移动端]标题 --> style="
<h2 class="mobile-title"> position: absolute;
<h3 class="title">芋道后台管理系统</h3> top: 15%;
</h2> left: 20%;
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 class="form" v-model="loginForm.loginType" style=" float:none;"> <el-tabs
<el-tab-pane label="账号密码登录" name="uname"> class="form"
</el-tab-pane> v-model="loginForm.loginType"
<el-tab-pane label="短信验证码登录" name="sms"> style="float: none">
</el-tab-pane> <el-tab-pane label="账号密码登录" name="uname"></el-tab-pane>
</el-tabs> <el-tab-pane label="短信验证码登录" name="sms"></el-tab-pane>
<div> </el-tabs>
<el-form ref="loginForm" :model="loginForm" :rules="LoginRules" class="login-form"> <div style="">
<el-form-item prop="tenantName" v-if="tenantEnable"> <el-form
<el-input v-model="loginForm.tenantName" type="text" auto-complete="off" placeholder='租户'> ref="loginForm"
<svg-icon slot="prefix" icon-class="tree" class="el-input__icon input-icon" /> :model="loginForm"
</el-input> :rules="LoginRules"
</el-form-item> class="login-form">
<!-- 账号密码登录 --> <el-form-item prop="tenantName" v-if="tenantEnable">
<div v-if="loginForm.loginType === 'uname'"> <el-input
<el-form-item prop="username"> v-model="loginForm.tenantName"
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号"> type="text"
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> auto-complete="off"
</el-input> placeholder="租户">
</el-form-item> <!-- <svg-icon
<el-form-item prop="password"> slot="prefix"
<el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码" icon-class="tree"
@keyup.enter.native="getCode"> class="el-input__icon input-icon" /> -->
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> </el-input>
</el-input> </el-form-item>
</el-form-item> <!-- 账号密码登录 -->
<el-checkbox v-model="loginForm.rememberMe" style="margin:0 0 25px 0;">记住密码</el-checkbox> <div v-if="loginForm.loginType === 'uname'">
</div> <el-form-item prop="username">
<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 v-model="loginForm.mobile" type="text" auto-complete="off" placeholder="请输入手机号"> <el-input
<svg-icon slot="prefix" icon-class="phone" class="el-input__icon input-icon" /> v-model="loginForm.mobile"
</el-input> type="text"
</el-form-item> auto-complete="off"
<el-form-item prop="mobileCode"> placeholder="请输入手机号">
<el-input v-model="loginForm.mobileCode" type="text" auto-complete="off" placeholder="短信验证码" <!-- <svg-icon
class="sms-login-mobile-code-prefix" @keyup.enter.native="handleLogin"> slot="prefix"
<template> icon-class="phone"
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> class="el-input__icon input-icon" /> -->
</template> </el-input>
<template slot="append"> </el-form-item>
<span v-if="mobileCodeTimer <= 0" class="getMobileCode" @click="getSmsCode" <el-form-item prop="mobileCode">
style="cursor: pointer;">获取验证码</span> <el-input
<span v-if="mobileCodeTimer > 0" class="getMobileCode">{{ mobileCodeTimer }}秒后可重新获取</span> v-model="loginForm.mobileCode"
</template> type="text"
</el-input> auto-complete="off"
</el-form-item> placeholder="短信验证码"
</div> class="sms-login-mobile-code-prefix"
@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 style="width:100%;"> <el-form-item id="button-form-item" style="width: 100%; margin-top: 32px">
<el-button :loading="loading" size="medium" type="primary" style="width:100%;" <el-button
@click.native.prevent="getCode"> :loading="loading"
<span v-if="!loading"> </span> size="medium"
<span v-else> 中...</span> type="primary"
</el-button> style="width: 100%; height: 66px; font-size: 18px;"
</el-form-item> @click.native.prevent="getCode">
<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="登录" >
@ -83,265 +240,305 @@
</div> </div>
</div> </div>
</el-form-item> --> </el-form-item> -->
</el-form> </el-form>
</div> </div>
</div> </div>
</div>
</div>
<!-- 图形验证码 --> <!-- footer -->
<Verify ref="verify" :captcha-type="'blockPuzzle'" :img-size="{ width: '400px', height: '200px' }" <div class="footer">
@success="handleLogin" /> Copyright © 2023 中建材智能自动化院 All Rights Reserved.
</div>
</div>
</div>
<!-- footer --> <!-- 图形验证码 -->
<div class="footer"> <Verify
Copyright © 2023 中建材智能自动化院 All Rights Reserved. ref="verify"
</div> :captcha-type="'blockPuzzle'"
</div> :img-size="{ width: '400px', height: '200px' }"
@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, getTenantName, getRememberMe,
getUsername, getTenantName,
removePassword, removeRememberMe, removeTenantName, getUsername,
removeUsername, removePassword,
setPassword, setRememberMe, setTenantId, setTenantName, removeRememberMe,
setUsername removeTenantName,
} from "@/utils/auth"; removeUsername,
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 (/^(?:(?:\+|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) { if (
callback(new Error("手机号格式错误")); /^(?:(?:\+|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(
} else { value
callback(); ) === false
} ) {
}, trigger: "blur" callback(new Error('手机号格式错误'));
} } else {
], callback();
tenantName: [ }
{ required: true, trigger: "blur", message: "租户不能为空" }, },
{ trigger: 'blur',
validator: (rule, value, callback) => { },
// debugger ],
getTenantIdByName(value).then(res => { tenantName: [
const tenantId = res.data; { required: true, trigger: 'blur', message: '租户不能为空' },
if (tenantId && tenantId >= 0) { {
// validator: (rule, value, callback) => {
setTenantId(tenantId) // debugger
callback(); getTenantIdByName(value).then((res) => {
} else { const tenantId = res.data;
callback('租户不存在'); if (tenantId && tenantId >= 0) {
} //
}); setTenantId(tenantId);
}, callback();
trigger: 'blur' } else {
} callback('租户不存在');
] }
}, });
loading: false, },
redirect: undefined, trigger: 'blur',
// },
SysUserSocialTypeEnum: SystemUserSocialTypeEnum, ],
}; },
}, loading: false,
created() { redirect: undefined,
// //
this.tenantEnable = getTenantEnable(); SysUserSocialTypeEnum: SystemUserSocialTypeEnum,
if (this.tenantEnable) { };
getTenantIdByName(this.loginForm.tenantName).then(res => { // },
const tenantId = res.data; created() {
if (tenantId && tenantId >= 0) { //
setTenantId(tenantId) this.tenantEnable = getTenantEnable();
} if (this.tenantEnable) {
}); getTenantIdByName(this.loginForm.tenantName).then((res) => {
} //
// const tenantId = res.data;
this.captchaEnable = getCaptchaEnable(); if (tenantId && tenantId >= 0) {
// setTenantId(tenantId);
this.redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : undefined; }
this.getCookie(); });
}, }
methods: { //
getCode() { this.captchaEnable = getCaptchaEnable();
// //
if (!this.captchaEnable) { this.redirect = this.$route.query.redirect
this.handleLogin({}) ? decodeURIComponent(this.$route.query.redirect)
return; : undefined;
} 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 = captchaParams.captchaVerification this.loginForm.captchaVerification =
// captchaParams.captchaVerification;
// console.log("", this.loginForm); //
this.$store.dispatch(this.loginForm.loginType === "sms" ? "SmsLogin" : "Login", this.loginForm).then(() => { // console.log("", this.loginForm);
this.$router.push({ path: this.redirect || "/" }).catch(() => { this.$store
}); .dispatch(
}).catch(() => { this.loginForm.loginType === 'sms' ? 'SmsLogin' : 'Login',
this.loading = false; this.loginForm
}); )
} .then(() => {
}); this.$router.push({ path: this.redirect || '/' }).catch(() => {});
}, })
async doSocialLogin(socialTypeEnum) { .catch(() => {
// this.loading = false;
this.loading = true; });
let tenant = false; }
if (this.tenantEnable) { });
await this.$prompt('请输入租户名称', "提示", { },
confirmButtonText: "确定", async doSocialLogin(socialTypeEnum) {
cancelButtonText: "取消" //
}).then(async ({ value }) => { this.loading = true;
await getTenantIdByName(value).then(res => { let tenant = false;
const tenantId = res.data; if (this.tenantEnable) {
tenant = true await this.$prompt('请输入租户名称', '提示', {
if (tenantId && tenantId >= 0) { confirmButtonText: '确定',
setTenantId(tenantId) cancelButtonText: '取消',
} })
}); .then(async ({ value }) => {
}).catch(() => { await getTenantIdByName(value).then((res) => {
// loading const tenantId = res.data;
this.loading = false; tenant = true;
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 = location.origin + '/social-login?' const redirectUri =
+ encodeURIComponent('type=' + socialTypeEnum.type + '&redirect=' + (this.redirect || "/")); // location.origin +
// const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback'; '/social-login?' +
// const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback'; encodeURIComponent(
// 'type=' +
socialAuthRedirect(socialTypeEnum.type, encodeURIComponent(redirectUri)).then((res) => { socialTypeEnum.type +
// console.log(res.url); '&redirect=' +
window.location.href = res.data; (this.redirect || '/')
}); ); //
} // const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback';
}, // const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback';
/** ========== 以下为升级短信登录 ========== */ //
getSmsCode() { socialAuthRedirect(
if (this.mobileCodeTimer > 0) return; socialTypeEnum.type,
this.$refs.loginForm.validate(valid => { encodeURIComponent(redirectUri)
if (!valid) return; ).then((res) => {
sendSmsCode(this.loginForm.mobile, this.scene, this.loginForm.uuid, this.loginForm.code).then(res => { // console.log(res.url);
this.$modal.msgSuccess("获取验证码成功") window.location.href = res.data;
this.mobileCodeTimer = 60; });
let msgTimer = setInterval(() => { }
this.mobileCodeTimer = this.mobileCodeTimer - 1; },
if (this.mobileCodeTimer <= 0) { /** ========== 以下为升级短信登录 ========== */
clearInterval(msgTimer); getSmsCode() {
} if (this.mobileCodeTimer > 0) return;
}, 1000); this.$refs.loginForm.validate((valid) => {
}); 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>