登录页,忘记密码

This commit is contained in:
姚亚男
2021-09-14 18:17:07 +08:00
parent df61c30adc
commit ecfaaaf1ab
6 changed files with 373 additions and 385 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 922 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

+9 -164
View File
@@ -1,29 +1,7 @@
<template>
<div id="userLayout" :class="['user-layout-wrapper',device]">
<div :class="!mobile ? 'container' : 'container-mobile'">
<div class="top" id="top" v-if="!mobile">
<div class="logo">
<img id="logo" src="~@/assets/logo.png" alt="">
</div>
<div id="company">
<span id="c-company">合众未来</span>
<span id="p-company">HEZHONGWEILAI</span>
</div>
</div>
<div v-if="mobile">
<span class="top-bg"><img src="~/@assets/mobileBg.png" alt=""></span>
<span class="btm-bg"><img src="~/@assets/mobileHome.png" alt=""></span>
</div>
<div v-if="mobile" class="mobile">
<div class="logo">
<img src="~@/assets/logo.png" alt="">
</div>
<div class="company">
<span>合众未来</span>
<span>HEZHONGWEILAI</span>
</div>
</div>
<div class="illustration" v-if="!mobile">
<div class="container">
<div class="illustration">
<img src="@/assets/home.png" alt="">
</div>
<route-view></route-view>
@@ -40,9 +18,7 @@
components: { RouteView },
mixins: [mixinDevice],
data () {
return {
mobile:isMobile() //是否是mobile
}
return {}
},
mounted () {
document.body.classList.add('userLayout')
@@ -51,158 +27,27 @@
document.body.classList.remove('userLayout')
},
}
// 判断当前设备
function isMobile() {
var userAgentInfo = navigator.userAgent;
var mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
var mobile_flag = false;
//根据userAgent判断是否是手机
for (var v = 0; v < mobileAgents.length; v++) {
if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
mobile_flag = true;
break;
}
}
var screen_width = window.screen.width;
var screen_height = window.screen.height;
//根据屏幕分辨率判断是否是手机
if (screen_width < 500 && screen_height < 800) {
mobile_flag = true;
}
return mobile_flag;
}
</script>
<style lang="less" >
#userLayout.user-layout-wrapper{
height: 100%;
background: #4daaff;
background: #fff;
overflow: auto;
.container {
width: 100%;
min-width: 770px;
min-height: 500px;
min-width: 1366px;
min-height: 768px;
height: 100%;
overflow: hidden;
position: relative;
.top {
position: absolute;
left: 2%;
top: 3%;
min-width: 100px;
max-height: 50px;
z-index: 9;
.logo {
width: 100%;
display: flex;
align-items: center;
position: absolute;
overflow: hidden;
img {
display: block;
max-width: 100%;
min-height: 30px;
}
}
#company {
position: absolute;
max-height: 62px;
left: 5.5rem;
min-height: 61px;
color: #000;
white-space: nowrap;
display: flex;
flex-direction: column;
justify-content: flex-end;
span {
display: block;
&:first-child {
font-size: 1.8rem;
font-weight: 700;
letter-spacing: 0.3rem;
}
&:last-child {
font-size: 0.9rem;
line-height: 0.9rem;
letter-spacing: 0.06rem;
font-weight: 700;
}
}
}
}
.illustration{
position: absolute;
max-width: 50%;
max-height: 100%;
height: 100%;
min-width: 400px;
display: flex;
justify-content: center;
align-items: center;
min-width: 50%;
img{
max-width: 70%;
}
}
}
.container-mobile{
/*移动端的logo样式*/
.top-bg{
width: 100%;
position: absolute;
top: -3.5rem;
img{
width: 100%;
}
}
.btm-bg{
position: absolute;
bottom: 0;
left: 0;
max-width: 75%;
overflow: hidden;
img{
margin-left: -5rem;
max-width: 100%;
margin-bottom: -3rem;
}
}
background: #f0f2f5;
width: 100%;
height: 100%;
.mobile{
position: absolute;
top: 6rem;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.logo{
max-width: 4rem;
img{
max-width: 100%;
margin-bottom: 0.5rem;
}
}
.company{
display: flex;
flex-direction: column;
justify-content: flex-end;
span:first-child{
color: #000;
font-size: 1.6rem;
font-weight: bold;
letter-spacing: 0.3rem;
}
span:last-child{
color: #000;
font-size: 0.8rem;
line-height: 1.2rem;
font-weight: bold;
}
height: 100%;
}
}
}
+73 -176
View File
@@ -1,11 +1,13 @@
<template>
<div class="main">
<a-form v-if="!mobile" :form="form" class="user-layout-login" ref="formLogin" id="formLogin">
<a-form :form="form" class="user-layout-login" ref="formLogin" id="formLogin">
<div class="user-box">
<span class="title">用户登录</span>
<span class="title">
<img src='../../assets/userLogin.png' alt=''>
</span>
<a-row>
<a-col :span="3"></a-col>
<a-col :span="18">
<a-col :span="6"></a-col>
<a-col :span="12">
<a-form-item>
<a-input
size="large"
@@ -16,11 +18,11 @@
</a-input>
</a-form-item>
</a-col>
<a-col :span="3"></a-col>
<a-col :span="6"></a-col>
</a-row>
<a-row>
<a-col :span="3"></a-col>
<a-col :span="18">
<a-col :span="6"></a-col>
<a-col :span="12">
<a-form-item>
<a-input
v-decorator="['password',{initialValue:'', rules: validatorRules.password.rules,validateTrigger: 'blur'}]"
@@ -33,11 +35,11 @@
</a-input>
</a-form-item>
</a-col>
<a-col :span="3"></a-col>
<a-col :span="6"></a-col>
</a-row>
<a-row style="margin-bottom: 0%;">
<a-col :span="3"></a-col>
<a-col :span="12">
<a-col :span="6"></a-col>
<a-col :span="7">
<a-form-item>
<a-input
v-decorator="['inputCode',validatorRules.inputCode]"
@@ -50,124 +52,39 @@
</a-input>
</a-form-item>
</a-col>
<a-col :span="6" style="text-align: right">
<img v-if="requestCodeSuccess" style="margin-top: 2px;" :src="randCodeImage" @click="handleChangeCheckCode"/>
<a-col :span="5" class='code' style='text-align: right'>
<img v-if="requestCodeSuccess" :src="randCodeImage" @click="handleChangeCheckCode"/>
<img v-else style="margin-top: 2px;" src="../../assets/checkcode.png" @click="handleChangeCheckCode"/>
</a-col>
<a-col :span="3"></a-col>
<a-col :span="4"></a-col>
</a-row>
<a-row style="margin-bottom: 2%;">
<a-col :span="3"></a-col>
<a-col :span="7">
<a-row class="login-btn">
<a-col :span="6"></a-col>
<a-col :span="12">
<a-form-item>
<a-checkbox v-decorator="['rememberMe', {initialValue: true, valuePropName: 'checked'}]">自动登录</a-checkbox>
<a-button
block
size="large"
type="primary"
htmlType="submit"
:loading="loginBtn"
@click.stop.prevent="handleSubmit"
:disabled="loginBtn">
{{ loginBtn ? "登录中" : "登录" }}
</a-button>
</a-form-item>
</a-col>
<a-col :span="6"></a-col>
<a-col :span="5" style="text-align: right;color: #1891FF;">
<a-form-item>
<router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">
忘记密码
</router-link>
</a-form-item>
</a-col>
</a-row>
<a-row class="login-btn">
<a-row style="margin-bottom: 2%;">
<a-col :span="3"></a-col>
<a-col :span="18">
<a-form-item>
<a-button
block
size="large"
type="primary"
htmlType="submit"
:loading="loginBtn"
@click.stop.prevent="handleSubmit"
:disabled="loginBtn">
{{ loginBtn ? "登录中" : "登录" }}
</a-button>
</a-form-item>
</a-col>
<a-col :span="3"></a-col>
</a-row>
</div>
</a-form>
<a-form v-if="mobile" :form="form" class="user-layout-login user-layout-login-mobile" ref="formLogin" id="formLogin">
<div class="user-box user-box-mobile">
<a-row>
<a-col :span="24">
<a-form-item>
<a-input
size="large"
v-decorator="['username',{initialValue:'', rules: validatorRules.username.rules,validateTrigger: 'blur'}]"
type="text"
placeholder="请输入帐号">
<a-icon slot="prefix" type="user" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
</a-input>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-item>
<a-input
v-decorator="['password',{initialValue:'', rules: validatorRules.password.rules,validateTrigger: 'blur'}]"
size="large"
type="password"
autocomplete="false"
placeholder="请输入密码"
>
<a-icon slot="prefix" type="lock" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
</a-input>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="14">
<a-form-item>
<a-input
v-decorator="['inputCode',validatorRules.inputCode]"
size="large"
type="text"
@change="inputCodeChange"
placeholder="请输入验证码">
<a-icon slot="prefix" type="safety" :style="{ color: '#B3B7C2',fontSize:'20px'}"/>
</a-input>
</a-form-item>
</a-col>
<a-col :span="10" style="text-align: right">
<img v-if="requestCodeSuccess" style="margin-top: 2px;" :src="randCodeImage" @click="handleChangeCheckCode"/>
<img v-else style="margin-top: 2px;" src="../../assets/checkcode.png" @click="handleChangeCheckCode"/>
</a-col>
</a-row>
<a-row>
<a-col :span="10">
<a-form-item>
<a-checkbox v-decorator="['rememberMe', {initialValue: true, valuePropName: 'checked'}]">自动登录</a-checkbox>
</a-form-item>
</a-col>
<a-col :span="4"></a-col>
<a-col :span="9" style="text-align: right;color: #1891FF;">
<a-col :span="6"></a-col>
<a-col :span="5" style="text-align: right;">
<a-form-item>
<router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">
忘记密码
</router-link>
</a-form-item>
</a-col>
</a-row>
<a-row class="login-btn">
<a-col :span="24">
<a-form-item>
<a-button
block
size="large"
type="primary"
htmlType="submit"
:loading="loginBtn"
@click.stop.prevent="handleSubmit"
:disabled="loginBtn">
{{ loginBtn ? "登录中" : "登录" }}
</a-button>
<span @click='forgetPassword' class="forget-password" style="float: right;color: #BFBFBF;">
忘记密码 <img style='height: 14px' src='../../assets/wenhao.png' alt=''>
</span>
</a-form-item>
</a-col>
</a-row>
@@ -179,11 +96,9 @@
import { mapActions } from "vuex"
import { timeFix } from "@/utils/util"
import Vue from 'vue'
import { ACCESS_TOKEN ,ENCRYPTED_STRING} from "@/store/mutation-types"
import { putAction,postAction,getAction } from '@/api/manage'
import { USER_INFO } from "@/store/mutation-types"
import { ACCESS_TOKEN } from "@/store/mutation-types"
import { postAction,getAction } from '@/api/manage'
import {getRSAPublicKey} from '@/api/login.js'
const Base64 = require('js-base64').Base64
import {JSEncrypt} from 'jsencrypt'
export default {
@@ -191,8 +106,6 @@
data () {
return {
loginBtn: false,
mobile:isMobile(),
// login type: 0 email, 1 username, 2 telephone
loginType: 0,
stepCaptchaVisible: false,
form: this.$form.createForm(this),
@@ -306,6 +219,10 @@
}
);
},
// 忘记密码
forgetPassword() {
this.$router.push({ name: 'alteration' })
},
handleChangeCheckCode(){
this.currdatetime = new Date().getTime();
getAction(`/sys/randomImage/${this.currdatetime}`).then(res=>{
@@ -383,30 +300,6 @@
},
}
}
// 判断当前设备
function isMobile() {
var userAgentInfo = navigator.userAgent;
var mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
var mobile_flag = false;
//根据userAgent判断是否是手机
for (var v = 0; v < mobileAgents.length; v++) {
if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
mobile_flag = true;
break;
}
}
var screen_width = window.screen.width;
var screen_height = window.screen.height;
//根据屏幕分辨率判断是否是手机
if (screen_width < 500 && screen_height < 800) {
mobile_flag = true;
}
return mobile_flag;
}
</script>
<style lang="less" scoped>
@@ -420,15 +313,11 @@
height: 100%;
.user-layout-login{
z-index: 99;
width: 24%;
height: 56%;
padding: 3% 0 3% 0;
min-width: 332px;
min-height: 460px;
background: #fff;
border-radius: 20px;
width: 50%;
box-sizing: border-box;
height: 60%;
position: absolute;
right: 8%;
right: 0;
top: 50%;
transform: translateY(-50%);
.user-box{
@@ -439,34 +328,42 @@
justify-content: space-between;
flex-direction: column;
.title{
display: block;
color: #1891FF;
font-size: 28px;
font-weight: 500;
margin: 0 0 5% 0;
text-align: center;
display: flex;
justify-content: center;
img{
width: 395px;
height: 124px;
}
}
.code{
img{
height: 60px;
border-radius: 30px;
}
}
.login-btn{
margin-top: 20px;
margin-bottom: 0;
font-size: 10px;
/deep/.ant-btn-primary{
height: 60px;
background: #069F99;
border: none;
border-radius: 30px;
}
}
}
}
.user-layout-login-mobile{
right: 0;
width: 100%;
min-width: 0 !important;
height: 46% !important;
background: transparent;
min-height: 0;
padding: 0 2rem 0 2rem;
position: absolute;
top: 50%;
margin-top: 6rem;
transform: translateY(-50%);
.ant-row{
margin-bottom: 0;
}
/deep/.ant-row{
margin-bottom: 0 !important;
}
/deep/.ant-input-affix-wrapper .ant-input{
border-radius: 30px;
height: 60px;
border: 1px solid #E6E3E3;
}
.forget-password{
cursor: pointer;
}
}
</style>
+291 -45
View File
@@ -1,69 +1,315 @@
<template>
<a-card :bordered="false" style="width: 100%;text-align: center;">
<a-steps class="steps" :current="currentTab">
<a-step title="手机验证"/>
<a-step title="密码"/>
<a-step title="完成"/>
</a-steps>
<div class="content">
<step2 v-if="currentTab === 0" @nextStep="nextStep"/>
<step3 v-if="currentTab === 1" @nextStep="nextStep" @prevStep="prevStep" :userList="userList"/>
<step4 v-if="currentTab === 2" @prevStep="prevStep" @finish="finish" :userList="userList"/>
<a-card :bordered="false" style="width: 100%;height: 100%;text-align: left;">
<div class='alteration-head'></div>
<div class='alteration-center'>
<div class='alteration-content'>
<a-form :form="form">
<span class='setPassword'>设置密码</span>
<a-row>
<a-col :span='22'>
<a-form-item
label="手机"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}"
>
<a-input
type="text"
v-decorator="['phone',{ rules: validatorRules.phone.rules}]"
placeholder="请输入手机号">
</a-input>
</a-form-item>
</a-col>
<a-col :span='6'></a-col>
</a-row>
<a-row>
<a-col :span='22'>
<a-form-item
class='captcha'
label="验证码"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}">
<a-input
v-decorator="['captcha', { rules: validatorRules.captcha.rules}]"
type="text"
placeholder="验证码">
</a-input>
<a-button
tabindex="-1"
size="default"
:disabled="state.smsSendBtn"
@click.stop.prevent="getCaptcha"
v-text="!state.smsSendBtn && '获取验证码' || (state.time+' s')"></a-button>
</a-form-item>
</a-col>
<a-col :span='6'></a-col>
</a-row>
<a-row>
<a-col :span='22'>
<a-form-item
label="新密码"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}">
<a-input
placeholder="新密码"
v-decorator="['password', { rules: validatorRules.password.rules}]"
type="password">
</a-input>
</a-form-item>
</a-col>
<a-col :span='6'></a-col>
</a-row>
<a-row>
<a-col :span='22'>
<a-form-item
label="确认密码"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}">
<a-input
placeholder="确认密码"
v-decorator="['confirmPassword', { rules: validatorRules.confirmPassword.rules}]"
type="password"
autocomplete="false">
</a-input>
</a-form-item>
</a-col>
<a-col :span='6'></a-col>
</a-row>
<a-row>
<a-col :span='8'></a-col>
<a-col :span='14'>
<a-form-item class='btn'>
<a-button :loading="loading" type="primary" @click="submit" style="margin-left:20px">提交</a-button>
<a-button @click='cancel'>取消</a-button>
</a-form-item>
</a-col>
<a-col :span='2'></a-col>
</a-row>
</a-form>
</div>
</div>
</a-card>
</template>
<script>
import Step1 from './Step1'
import Step2 from './Step2'
import Step3 from './Step3'
import Step4 from './Step4'
import { getAction, postAction } from '@/api/manage'
export default {
export default {
name: "Alteration",
components: {
Step1,
Step2,
Step3,
Step4
},
components: {},
data() {
return {
description: '将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。',
currentTab: 0,
userList: {},
// form
form: null,
form: this.$form.createForm(this),
loading: false,
validatorRules: {
phone: {
rules: [
{required: true, message: '请输入手机号码!'},{validator: this.validatePhone}],
validateTrigger: 'blur'
},
captcha: {
rules: [{required: true, message: '请输入短信验证码!'}],
validateTrigger: 'blur'
},
password: {
rules: [
{
required: true,
pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{8,}$/,
message: '密码由8位数字、大小写字母和特殊符号组成!!'
}
],
validateTrigger: 'blur'
},
confirmPassword: {
rules: [
{required: true, message: '密码不能为空!'},
{validator: this.handlePasswordCheck}
],
validateTrigger: 'blur'
},
},
state: {
time: 60,
smsSendBtn: false,
},
userList: {}
}
},
methods: {
submit() {
let that = this
that.loading = true
this.form.validateFields((err, values) => {
if (!err) {
var params = {}
console.log(values, '======values')
params.username = this.userList.username;
params.password = values.password;
params.smscode = this.userList.smscode;
params.phone = this.userList.phone;
getAction("/sys/user/passwordChange", params).then((res) => {
if (res.success) {
that.loading = false
that.$router.go(-1)
} else {
this.passwordFailed(res.message);
that.loading = false
}
})
} else {
that.loading = false
}
})
},
cancel() {
this.$router.go(-1)
},
passwordFailed(err) {
this.$notification[ 'error' ]({
message: "更改密码失败",
description:err,
duration: 4,
});
},
validatePhone(rule,value,callback){
if(value){
var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
if(!myreg.test(value)){
callback("请输入正确的手机号")
}else{
callback();
}
}else{
callback()
}
},
handlePasswordCheck (rule, value, callback) {
let password = this.form.getFieldValue('password')
if (value && password && value.trim() !== password.trim()) {
callback(new Error('两次密码不一致'))
}
callback()
},
getCaptcha(e) {
e.preventDefault();
let that = this;
let phone=that.form.getFieldValue("phone")
if(!phone){
this.cmsFailed("手机号不能为空!");
return;
}
this.state.smsSendBtn = true;
let interval = window.setInterval(() => {
if (that.state.time-- <= 0) {
that.state.time = 60;
that.state.smsSendBtn = false;
window.clearInterval(interval);
}
}, 1000);
// handler
nextStep(data) {
this.userList = data;
if (this.currentTab < 4) {
this.currentTab += 1
}
const hide = this.$message.loading('验证码发送中..', 0);
let smsParams = {
mobile: phone,
smsmode: "2"
};
postAction("/sys/sms", smsParams).then(res => {
if (!res.success) {
setTimeout(hide, 1);
this.cmsFailed(res.message);
}
setTimeout(hide, 500);
})
},
prevStep(data) {
this.userList = data;
if (this.currentTab > 0) {
this.currentTab -= 1
}
},
finish() {
this.currentTab = 0
cmsFailed(err) {
this.$notification['error']({
message: "验证错误",
description: err,
duration: 4,
});
}
}
}
</script>
<style lang="less" scoped>
.steps {
max-width: 750px;
margin: 16px auto;
/deep/.ant-card{
width: 100%;
}
/deep/.ant-card-body{
padding: 0 !important;
height: 100%;
background: #F0F2F5;
}
.alteration-center{
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: #F0F2F5;
}
.alteration-content{
margin: auto;
width: 1000px;
display: flex;
justify-content: center;
align-items: center;
background: #fff;
.setPassword{
font-size: 26px;
display: block;
background: #fff;
height: 60px;
text-align: center !important;
margin-top: 30px;
}
.ant-steps-item{
overflow: hidden;
}
/deep/.ant-form{
width: 500px;
height: 500px;
}
.alteration-head{
position: absolute;
top: 0;
width: 100%;
background: #069F99;
height: 60px;
}
.alteration-content{
}
/deep/.ant-row{
margin-bottom: 20px !important;
height: 60px;
}
/deep/.ant-form-item-label{
height: 50px;
line-height: 50px;
}
/deep/.ant-input{
border-radius: 30px;
height: 50px;
border: 1px solid #E6E3E3;
}
.btn{
/deep/button{
border-radius: 30px;
margin: 0 20px;
}
.ant-btn-primary{
background: #069F99;
border: none;
}
}
.captcha{
position: relative;
/deep/button{
border: none;
color: #069F99;
position: absolute;
right: 10px;
top: -6px;
box-shadow: none;
background: none;
}
}
</style>