代码调整

This commit is contained in:
joylink_cuiweidong 2022-10-12 15:18:36 +08:00
parent c6af3c8027
commit 75ee144894
9 changed files with 1457 additions and 1630 deletions

View File

@ -7,7 +7,6 @@ Vue.use(Router);
/* Layout */
const Layout = () => import('@/layout');
const Login = () => import('@/views/login/index');
const LoginNew = () => import('@/views/login_new/index');
const Authorization = () => import('@/views/authorization/index');
const AuthorApply = () => import('@/views/authorization/apply');
@ -294,12 +293,6 @@ export const constantRoutes = [
component: Login,
hidden: true
},
// 新版平台登录页面
{
path: '/loginNew',
component: LoginNew,
hidden: true
},
// 设计平台登录
{
path: '/design',

View File

@ -1,34 +0,0 @@
<template>
<div class="content_box">
<span>本产品基于长安玖琏</span><span v-if="!project.startsWith('design')">城市轨道交通实训云平台设计开发</span><span v-else>城市轨道交通设计云平台设计开发</span>
<br><span>实训平台网址</span><a target="_blank" href="https://joylink.club/cbtc/login" style="color: #33F;text-decoration:underline;">https://joylink.club/cbtc/login</a>
<br><span>设计平台网址</span><a target="_blank" href="https://joylink.club/cbtc/design/login" style="color: #33F;text-decoration:underline;">https://joylink.club/cbtc/design/login</a>
</div>
</template>
<script>
export default {
name: 'FloatPart',
data() {
return {
};
},
computed: {
project() {
return this.$route.path.split('/')[1];
}
},
mounted() {
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.content_box{
position: absolute;
bottom: 10%;
right: 2%;
line-height: 20px;
font-size: 14px;
}
</style>

View File

@ -1,262 +0,0 @@
<template>
<el-dialog
:title="title"
:visible.sync="dialogShow"
width="500px"
:before-close="doClose"
:z-index="9000"
:show-close="false"
:close-on-click-modal="false"
top="25vh"
>
<el-form ref="ruleForm" :model="form" :rules="rules" label-width="110px" class="demo-ruleForm">
<el-form-item prop="type">
<template slot="label">
<span>找回途径</span>
</template>
<el-radio-group v-model="form.type" size="small">
<el-radio label="phone" border>手机号找回</el-radio>
<el-radio label="email" border>邮箱找回</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="form.type === 'email'" prop="email">
<template slot="label">
<span>&emsp;&emsp;</span>
</template>
<el-input v-model="form.email" size="small" style="width: 200px;" />
</el-form-item>
<el-form-item v-if="form.type === 'phone'" prop="phone">
<template slot="label">
<span>手机号</span>
</template>
<el-input v-model="form.phone" size="small" style="width: 200px;" />
</el-form-item>
<el-form-item label="密码:" prop="password">
<template slot="label">
<span>&emsp;&emsp;</span>
</template>
<el-input v-model="form.password" size="small" autocomplete="new-password" show-password style="width: 200px;" />
</el-form-item>
<el-form-item label="密码确认:" prop="repeatPassword">
<el-input v-model="form.repeatPassword" size="small" autocomplete="new-password" show-password style="width: 200px;" />
</el-form-item>
<el-form-item prop="vfCode">
<template slot="label">
<span>验证码</span>
</template>
<el-input v-model="form.vfCode" size="small" style="display: inline-block;width: 200px" />
<el-button
size="small"
type="primary"
style="margin-top: 10px; margin-right: 10px;"
:disabled="passWordCodeTime != 0"
@click="sendVfcode"
>
{{ $t('global.sendCode') }}
<span
v-if="passWordCodeTime"
>{{ passWordCodeTime }}</span>
</el-button>
</el-form-item>
<div style="display: flex;justify-content: space-around;">
<el-button type="primary" size="small" @click="submitForm()">找回</el-button>
<el-button size="small" @click="doClose()">返回登录</el-button>
</div>
</el-form>
</el-dialog>
</template>
<script>
import { findPassword, sendPhoneVfcode, sendEmailVfcode } from '@/api/management/user';
import md5 from 'js-md5';
import {clearInterval, setInterval} from 'timers';
export default {
name: 'ForgetPassword',
data() {
var validateEmail = (rule, value, callback) => {
const regu = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
const re = new RegExp(regu);
if (!re.test(value) ) {
callback(new Error('邮箱格式不正确'));
} else {
callback();
}
};
var validatePhone = (rule, value, callback) => {
const regu = /^1(3[0-9]|4[5,7]|5[0,1,2,3,5,6,7,8,9]|6[2,5,6,7]|7[0,1,7,8]|8[0-9]|9[1,8,9])\d{8}$/;
const re = new RegExp(regu);
if (!re.test(value)) {
callback(new Error('手机号格式不正确'));
} else {
callback();
}
};
var validatePassword = (rule, value, callback) => {
if (this.form.repeatPassword) {
this.$refs.ruleForm.validateField('repeatPassword');
}
callback();
};
var validateRepeatPassword = (rule, value, callback) => {
if (value !== this.form.password) {
callback(new Error('两次密码不相同,请确认密码'));
} else {
callback();
}
};
var validateVfCode = (rule, value, callback) => {
if (this.form.vfCode.length !== 4) {
callback(new Error('验证码长度错误'));
} else {
callback();
}
};
return {
dialogShow: false,
message: '',
operation: '',
title: '密码找回',
passWordTime: null,
form: {
type: 'phone',
phone: '',
email: '',
password: '',
repeatPassword: '',
vfCode: ''
},
passWordCodeTime: 0,
rules: {
phone: [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{ validator: validatePhone, trigger: 'blur' }
],
email: [
{ required: true, message: '请输入邮箱', trigger: 'blur' },
{ validator: validateEmail, trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
{ validator: validatePassword, trigger: 'blur' },
{ min: 5, max: 20, message: '长度在 5 到 20 个字符', trigger: 'blur' }
],
repeatPassword: [
{ required: true, message: '请重复输入密码', trigger: 'blur' },
{ validator: validateRepeatPassword, trigger: 'blur' },
{ min: 5, max: 20, message: '长度在 5 到 20 个字符', trigger: 'blur' }
],
vfCode: [
{ required: true, message: '请输入验证码', trigger: 'blur' },
{ validator: validateVfCode, trigger: 'blur' }
]
}
};
},
computed: {
},
mounted() {
},
methods: {
doShow() {
this.form = {
type: 'phone',
phone: '',
email: '',
password: '',
repeatPassword: '',
vfCode: ''
};
this.dialogShow = true;
},
doClose() {
this.dialogShow = false;
this.form = {
type: 'phone',
phone: '',
email: '',
password: '',
repeatPassword: '',
vfCode: ''
};
this.$refs.ruleForm.clearValidate();
},
async sendVfcode() {
const reguEmail = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
const reguPhone = /^1(3[0-9]|4[5,7]|5[0,1,2,3,5,6,7,8,9]|6[2,5,6,7]|7[0,1,7,8]|8[0-9]|9[1,8,9])\d{8}$/;
const rePhone = new RegExp(reguPhone);
const reEmail = new RegExp(reguEmail);
if (this.form.type === 'phone' && this.form.phone && rePhone.test(this.form.phone)) {
const random = Math.floor(Math.random() * 10000 + 1);
const timeCount = Date.parse(new Date()) / 1000;
const pass = `${timeCount}86${this.form.phone}${random}`;
const param = {
mobile: this.form.phone,
nationCode: '86',
rd: random + '',
time: timeCount + '',
token: md5(pass)
};
try {
this.passWordCodeTime = 60;
this.passWordTime = setInterval(() => {
this.passWordCodeTime--;
if (this.passWordCodeTime <= 0) {
this.passWordCodeTime = 0;
clearInterval(this.mobileTime);
this.passWordTime = null;
}
}, 1000);
await sendPhoneVfcode(param);
} catch (error) {
this.$message.info(this.$t('global.codeFaile'));
}
} else if (this.form.type === 'email' && this.form.email && reEmail.test(this.form.email)) {
const param = { email: this.form.email };
try {
this.passWordCodeTime = 60;
this.passWordTime = setInterval(() => {
this.passWordCodeTime--;
if (this.passWordCodeTime <= 0) {
this.passWordCodeTime = 0;
clearInterval(this.mobileTime);
this.passWordTime = null;
}
}, 1000);
await sendEmailVfcode(param);
} catch (error) {
this.$message.info(this.$t('global.codeFaile'));
}
} else {
this.$refs.ruleForm.validateField('email');
this.$refs.ruleForm.validateField('phone');
}
},
submitForm() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
const data = { email: this.form.email, mobile: this.form.phone, newPwd: md5(this.form.password), vfCode: this.form.vfCode };
findPassword(data).then(resp => {
this.$message.success('设置密码成功!' );
this.doClose();
}).catch(error => {
this.$message.error('设置密码失败:' + error.message);
});
}
});
}
}
};
</script>
<style scoped>
.confirm-control-speed .context {
padding-bottom: 40px !important;
border: 1px solid lightgray;
}
.ningbo-01__systerm .el-dialog .el-button{
display: block;
margin: 0 auto;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,315 @@
<template>
<el-form
ref="loginForm"
v-loading="loading"
class="login-form"
:model="loginForm"
:rules="loginRules"
label-position="left"
>
<el-form-item prop="username" class="item_form_box">
<span class="svg-container svg-container_login">
<svg-icon icon-class="user" />
</span>
<el-input
v-model="loginForm.username"
name="username"
type="text"
:placeholder="this.$t('login.mobilePhoneNumberOrEmail')"
@keyup.enter.native="goToNext"
/>
</el-form-item>
<el-form-item prop="password" class="item_form_box item_form_password">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
ref="password"
v-model="loginForm.password"
name="password"
:type="pwdType"
:placeholder="this.$t('login.password')"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon v-if="pwdDisplay" icon-class="eye" />
<svg-icon v-else icon-class="eye-open" />
</span>
</el-form-item>
<div class="tip-message">{{ tipsMsg }}</div>
<div style="display: inline-block;width: 100%;margin-bottom: 10px;">
<div style="display:inline-block">
<el-checkbox v-model="isAutoLogin">{{ $t('login.autoLogin') }}</el-checkbox>
<!-- <el-checkbox v-if="project === 'cgy'" v-model="teacherLogin">教师登录</el-checkbox> -->
</div>
<el-popover
placement="right"
title=""
width="200"
trigger="hover"
class="popover_box"
>
<div>
<img :src="QCode" alt="" style="width: 100px; height: 100px; display: block; margin:0 auto;">
<div style="margin-top: 10px; word-break: break-word;text-align: center;">
{{ $t('login.perfectInformation') }}
</div>
</div>
<div slot="reference">
{{ $t('login.unableToLogin') }}
</div>
</el-popover>
<!-- <div v-if="registerCodeList.includes(project)" class="popover_box active" @click="registerUser">
注册账号
</div> -->
</div>
<el-form-item>
<el-button type="primary" style="width:100%;" @click.native.prevent="handleLogin">
{{ $t('login.login') }}
</el-button>
</el-form-item>
<!-- <div style="display: inline-block;width: 100%;">
<div class="popover_box active" style="bottom: 50px;" @click="forgetPassword">
忘记密码
</div>
</div> -->
</el-form>
</template>
<script>
// export const RegisterCodeList = ['cgy', 'designcgy'];
import QCode from '@/assets/erCode.jpg';
import md5 from 'js-md5';
import Cookies from 'js-cookie';
// getLoginWmurl, checkLoginStatus, getLoginInfo,
import { getOrgList, selectOrgnization } from '@/api/login';
// import ForgetPassword from './forgetPassword';
export default {
name:'NormalLogin',
// Register,
// components: { ForgetPassword },
props: {
project: {
type: String,
default: () => {
return '';
}
}
// syncLogin:{
// type: Boolean,
// default: () => {
// return false;
// }
// }
},
data() {
const validateName = (rule, value, callback) => {
if (value) {
callback();
} else {
callback(new Error('请输入用户名'));
}
};
const validatePass = (rule, value, callback) => {
if (value.length < 5) {
callback(new Error(this.$t('login.passwordHint')));
} else {
callback();
}
};
return {
QCode: QCode,
loading:false,
pwdDisplay: true,
pwdType: 'password',
cookiesName: 'UserName',
cookiesToken: 'UserToken',
isAutoLogin: false,
tipsMsg: '',
// teacherLogin: false,
loginForm: {
username: '',
password: ''
},
loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateName }],
password: [{ required: true, trigger: 'blur', validator: validatePass }]
}
};
},
// created() {
// },
watch: {
'project': function(val) {
if (Cookies.get(this.cookiesName) && Cookies.get(this.cookiesToken)) {
const model = {
username: Cookies.get(this.cookiesName),
password: Cookies.get(this.cookiesToken),
project: this.project
};
model.type = 'class';
this.loginAction(model);
}
}
},
methods:{
showPwd() {
if (this.pwdType === 'password') {
this.pwdDisplay = false;
this.pwdType = '';
} else {
this.pwdType = 'password';
this.pwdDisplay = true;
}
},
loginAction(model) {
this.$store
.dispatch('Login', model)
.then(() => {
this.$store.dispatch('SetAccount', model.username);
// this.handleLoginSucessRoute();
this.checkOrgnizationInfo();
})
.catch(error => {
console.log(error);
// if (error.code === '30001') {
// this.tipsMsg = this.$t('login.accountOrPasswordIsIncorrect');
// } else if (error.code == '10001') {
// this.tipsMsg = '';
// } else if (error.code == '10013' || error.code == '10014') {
// this.tipsMsg = '';
// } else {
// this.tipsMsg = error.message;
// }
this.tipsMsg = error.message;
this.loading = false;
setTimeout(() => {
this.tipsMsg = '';
}, 5000);
});
},
checkOrgnizationInfo() {
getOrgList().then(resp => {
const orgList = resp.data;
let orgId = '';
if (orgList.length < 2) {
if (orgList.length === 1) {
orgId = orgList[0].orgId;
selectOrgnization(orgId);
}
this.handleLoginSucessRoute();
} else {
// this.showOrgSelect(orgList).then(this.handleLoginSucessRoute());
}
});
},
handleLoginSucessRoute() {
this.loading = false;
this.tipsMsg = '';
console.log(this.path, '00000000000');
// path: '/trainingPlatform',
const path = '/simulation/simulationIndex';
// if()
this.$router.push({ path: path });
},
//
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
const model = Object.assign({}, this.loginForm);
model.password = md5(model.password);
model.type = 'class';
model.project = this.project;
this.loading = true;
if (this.isAutoLogin) {
Cookies.set(this.cookiesName, model.username, { expires: 2 });
Cookies.set(this.cookiesToken, model.password, { expires: 2 });
}
this.loginAction(model);
} else {
console.log('error submit!!');
return false;
}
});
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss">
$bg: #fff;
$dark_gray: #889aa4;
.el-form-item {
background: #fff !important;
border: 1px solid rgba(0, 0, 0, 0.1) !important;
.el-input {
height: 40px;
width: 85%;
background: #fff;
input {
background: #fff !important;
border: 0px;
-webkit-appearance: none;
border-radius: 0px;
padding: 8px 9px 7px 5px;
color: #000;
height: 100%;
&:-webkit-autofill {
box-shadow: 0 0 0px 1000px $bg inset !important;
-webkit-text-fill-color: #000 !important;
}
}
}
}
.login-form {
width: 440px;
padding: 0 50px;
}
.item_form_box {
border: 1px solid #ccc;
border-radius: 5px;
color: #454545;
}
.item_form_password {
margin-bottom: 10px;
}
.tip-message {
color: #f56c61;
padding: 5px;
font-size: 12px;
height: 23px;
margin-bottom: 10px;
}
.svg-container {
padding-left: 14px;
color: $dark_gray;
vertical-align: middle;
width: 30px;
display: inline-block;
&_login {
font-size: 16px;
}
}
.popover_box {
position: absolute;
right: 80px;
bottom: 124px;
cursor: pointer;
color: #225592;
font-size: 14px;
}
.active:hover {
color: #409eff;
}
.show-pwd {
position: absolute;
right: 10px;
top: 3px;
font-size: 16px;
color: $dark_gray;
cursor: pointer;
user-select: none;
}
</style>

View File

@ -1,42 +0,0 @@
<template>
<el-dialog center :visible.sync="show" :close-on-click-modal="false" :show-close="false" title="请选择要登录的组织">
<div class="formWrapper">
<el-select v-model="selected" placeholder="请选择">
<el-option v-for="option in orgList" :key="option.orgId" :label="option.name" :value="option.orgId" />
</el-select>
</div>
<el-button slot="footer" primary size="small" @click="confirmSelect">确认</el-button>
</el-dialog>
</template>
<script>
export default {
name: 'OrgSelect',
data() {
return {
show: false,
orgList: [],
selected: ''
}
},
methods: {
confirmSelect() {
this.$emit('select', this.selected)
},
doShow(orgList) {
this.orgList = orgList
this.show = true
},
doClose() {
this.show = false
}
}
}
</script>
<style lang="scss" scoped>
.formWrapper {
display: flex;
justify-content: center;
}
</style>

View File

@ -1,158 +0,0 @@
<template>
<el-dialog
:title="title"
:visible.sync="dialogShow"
width="500px"
:before-close="doClose"
:z-index="9000"
:show-close="false"
:close-on-click-modal="false"
top="25vh"
>
<el-form ref="ruleForm" :model="form" :rules="rules" label-width="110px" class="demo-ruleForm">
<el-form-item prop="nickname">
<template slot="label">
<span>&emsp;&emsp;</span>
</template>
<el-input v-model="form.nickname" autocomplete="new-password" />
</el-form-item>
<el-form-item prop="email">
<template slot="label">
<span>邮箱(账号)</span>
</template>
<el-input v-model="form.email" />
</el-form-item>
<el-form-item label="密码:" prop="password">
<template slot="label">
<span>&emsp;&emsp;</span>
</template>
<el-input v-model="form.password" autocomplete="new-password" show-password />
</el-form-item>
<el-form-item label="密码确认:" prop="repeatPassword">
<el-input v-model="form.repeatPassword" autocomplete="new-password" show-password />
</el-form-item>
<div style="display: flex;justify-content: space-around;">
<el-button type="primary" @click="submitForm()">立即创建</el-button>
<el-button @click="doClose()">返回登录</el-button>
</div>
</el-form>
</el-dialog>
</template>
<script>
import { registerUser } from '@/api/management/user';
import { ProjectCode } from '@/scripts/ProjectConfig';
import { getSessionStorage } from '@/utils/auth';
import md5 from 'js-md5';
export default {
name: 'Register',
data() {
var validateEmail = (rule, value, callback) => {
const regu = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
const re = new RegExp(regu);
if (!re.test(value) ) {
callback(new Error('邮箱格式不正确'));
} else {
callback();
}
};
var validatePassword = (rule, value, callback) => {
if (this.form.repeatPassword) {
this.$refs.ruleForm.validateField('repeatPassword');
}
callback();
};
var validateRepeatPassword = (rule, value, callback) => {
if (value !== this.form.password) {
callback(new Error('两次密码不相同,请确认密码'));
} else {
callback();
}
};
return {
dialogShow: false,
message: '',
operation: '',
title: '账号注册',
form: {
email: '',
nickname: '',
password: '',
repeatPassword: ''
},
rules: {
email: [
{ required: true, message: '请输入邮箱', trigger: 'blur' },
{ validator: validateEmail, trigger: 'blur' }
],
nickname: [
{ required: true, message: '请输入昵称', trigger: 'blur' },
{ min: 1, max: 32, message: '长度在 1 到 32 个字符', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
{ validator: validatePassword, trigger: 'blur' },
{ min: 5, max: 20, message: '长度在 5 到 20 个字符', trigger: 'blur' }
],
repeatPassword: [
{ required: true, message: '请重复输入密码', trigger: 'blur' },
{ validator: validateRepeatPassword, trigger: 'blur' },
{ min: 5, max: 20, message: '长度在 5 到 20 个字符', trigger: 'blur' }
]
}
};
},
computed: {
},
mounted() {
},
methods: {
doShow() {
this.form = {
email: '',
nickname: '',
password: '',
repeatPassword: ''
};
this.dialogShow = true;
},
doClose() {
this.dialogShow = false;
this.form = {
email: '',
nickname: '',
password: '',
repeatPassword: ''
};
this.$refs.ruleForm.clearValidate();
},
submitForm() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
const project = getSessionStorage('project');
const data = { email: this.form.email, nickname: this.form.nickname, password: md5(this.form.password), source: ProjectCode[project] || '' };
registerUser(data).then(resp => {
this.$message.success('账号注册成功!' );
this.doClose();
}).catch(error => {
this.$message.error('账号注册失败:' + error.message);
});
}
});
}
}
};
</script>
<style scoped>
.confirm-control-speed .context {
padding-bottom: 40px !important;
border: 1px solid lightgray;
}
.ningbo-01__systerm .el-dialog .el-button{
display: block;
margin: 0 auto;
}
</style>

View File

@ -59,7 +59,6 @@ export default {
sessionId: '',
checkLogin: null,
qrcodeClassName: 'login-qrcode',
modelType: 'class',
loginClient:'LianKeTang'
};
},
@ -110,7 +109,7 @@ export default {
//
debugger;
self.$store
.dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token, type: this.modelType })
.dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token, type: 'class' })
.then(() => {
//
self.clearTimer(self.checkLogin);
@ -172,4 +171,18 @@ $qrbg: #fff;
line-height: 30px;
}
}
.el-loading-spinner i {
font-size: 100px;
}
.el-loading-spinner .el-loading-text {
font-size: 24px;
}
.login-code-box {
.el-loading-spinner i {
font-size: 14px;
}
.el-loading-spinner .el-loading-text {
font-size: 14px;
}
}
</style>

File diff suppressed because it is too large Load Diff