|
|
@@ -1,18 +1,18 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<a-form-model ref="form" :model="model" :rules="validatorRules">
|
|
|
- <a-form-model-item required prop="username">
|
|
|
+ <a-form-model-item required prop="username"v-if='isLogin'>
|
|
|
<a-input v-model="model.username" size="large" placeholder="请输入帐户名">
|
|
|
<a-icon slot="prefix" type="user" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
|
|
</a-input>
|
|
|
</a-form-model-item>
|
|
|
- <a-form-model-item required prop="password">
|
|
|
+ <a-form-model-item required prop="password" v-if='isLogin'>
|
|
|
<a-input v-model="model.password" size="large" type="password" autocomplete="false" placeholder="请输入密码">
|
|
|
<a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
|
|
</a-input>
|
|
|
</a-form-model-item>
|
|
|
|
|
|
- <a-row :gutter="0">
|
|
|
+ <a-row :gutter="0" v-if='isLogin'>
|
|
|
<a-col :span="16">
|
|
|
<a-form-model-item required prop="inputCode">
|
|
|
<a-input v-model="model.inputCode" size="large" type="text" placeholder="请输入验证码">
|
|
|
@@ -25,12 +25,28 @@
|
|
|
<img v-else style="margin-top: 2px;" src="../../assets/checkcode.png" @click="handleChangeCheckCode"/>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
+
|
|
|
+ <a-form-model-item required v-if='!isLogin' prop='passwordNew'>
|
|
|
+ <a-input v-model="model.passwordNew" size="large" type="password" placeholder="请输入新密码" >
|
|
|
+ <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
|
|
+ </a-input>
|
|
|
+ </a-form-model-item>
|
|
|
+ <a-form-model-item required v-if='!isLogin' prop='passwordNew' >
|
|
|
+ <a-input v-model="model.passwordNew2" size="large" type="password" placeholder="请确认新密码"
|
|
|
+ >
|
|
|
+ <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
|
|
+ </a-input>
|
|
|
+ </a-form-model-item>
|
|
|
+ <a-form-item style="margin-top:24px;width: 100px" v-if='!isLogin'>
|
|
|
+ <a-button size="large" type="primary" htmlType="submit" @click='updatePassword' class="login-button" >修改密码
|
|
|
+ </a-button>
|
|
|
+ </a-form-item>
|
|
|
</a-form-model>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { getAction } from '@/api/manage'
|
|
|
+import { getAction, postAction, putAction } from '@/api/manage'
|
|
|
import Vue from 'vue'
|
|
|
import { mapActions } from 'vuex'
|
|
|
|
|
|
@@ -38,16 +54,24 @@
|
|
|
name: 'LoginAccount',
|
|
|
data(){
|
|
|
return {
|
|
|
+ isLogin:true,
|
|
|
+ confirmDirty:false,
|
|
|
requestCodeSuccess: false,
|
|
|
randCodeImage: '',
|
|
|
currdatetime: '',
|
|
|
loginType: 0,
|
|
|
model:{
|
|
|
+ passwordNew: '',
|
|
|
+ passwordNew2: '',
|
|
|
username: '',
|
|
|
password: '',
|
|
|
inputCode: ''
|
|
|
},
|
|
|
validatorRules:{
|
|
|
+ passwordNew: [
|
|
|
+ { required: true, pattern:/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/, message: '密码由8位数字、大小写字母和特殊符号组成!' },
|
|
|
+ { validator: this.validateToNextPassword, }
|
|
|
+ ],
|
|
|
username: [
|
|
|
{ required: true, message: '请输入用户名!' },
|
|
|
{ validator: this.handleUsernameOrEmail }
|
|
|
@@ -57,8 +81,12 @@
|
|
|
}],
|
|
|
inputCode: [{
|
|
|
required: true, message: '请输入验证码!'
|
|
|
- }]
|
|
|
- }
|
|
|
+ }],
|
|
|
+ confirmpassword: [
|
|
|
+ { required: true, message: '请确认新密码!', },
|
|
|
+ {
|
|
|
+ validator: this.validateToNextPassword, }],
|
|
|
+ },
|
|
|
|
|
|
}
|
|
|
},
|
|
|
@@ -66,6 +94,47 @@
|
|
|
this.handleChangeCheckCode();
|
|
|
},
|
|
|
methods:{
|
|
|
+
|
|
|
+ updatePassword() {
|
|
|
+ const that = this;
|
|
|
+ that.confirmLoading = true;
|
|
|
+ //let params = Object.assign({username:this.model.username},values)
|
|
|
+ let params={
|
|
|
+ username:this.model.username,
|
|
|
+ oldpassword:this.model.password,
|
|
|
+ confirmpassword:this.model.passwordNew2,
|
|
|
+ password:this.model.passwordNew
|
|
|
+ }
|
|
|
+ console.log("修改密码提交数据",params)
|
|
|
+ putAction("sys/updatePassword",params).then((res)=>{
|
|
|
+ if(res.success){
|
|
|
+ console.log(res)
|
|
|
+ that.$message.success(res.message);
|
|
|
+ that.close();
|
|
|
+ }else{
|
|
|
+ that.$message.warning(res.message);
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ that.confirmLoading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ compareToFirstPassword (rule, value, callback) {
|
|
|
+ if (value && value !== this.model.passwordNew) {
|
|
|
+ callback('两次输入的密码不一样!');
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ validateToNextPassword (rule, value, callback) {
|
|
|
+ const confirmpassword=this.model.passwordNew2;
|
|
|
+ if (value && confirmpassword && value !== confirmpassword) {
|
|
|
+ callback('两次输入的密码不一样!');
|
|
|
+ }
|
|
|
+ if (value && this.confirmDirty) {
|
|
|
+ this.$refs.form.validateField(['confirmpassword']);
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ },
|
|
|
...mapActions(['Login']),
|
|
|
/**刷新验证码*/
|
|
|
handleChangeCheckCode(){
|
|
|
@@ -134,7 +203,16 @@
|
|
|
}
|
|
|
//console.log("登录参数", loginParams)
|
|
|
this.Login(loginParams).then((res) => {
|
|
|
- this.$emit('success', res.result)
|
|
|
+ //判断是否首次登录
|
|
|
+ let httpUrl = '/sys/loginFirst';
|
|
|
+ postAction(httpUrl, loginParams).then((resa) => {
|
|
|
+ if (!resa.success) {
|
|
|
+ this.$message.error( resa.message);
|
|
|
+ this.isLogin=false
|
|
|
+ }else {
|
|
|
+ this.$emit('success', res.result)
|
|
|
+ }
|
|
|
+ })
|
|
|
}).catch((err) => {
|
|
|
this.$emit('fail', err)
|
|
|
});
|
|
|
@@ -142,7 +220,23 @@
|
|
|
this.$emit('validateFail')
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ handleConfirmBlur (e) {
|
|
|
+ const value = e.target.value
|
|
|
+ this.confirmDirty = this.confirmDirty || !!value
|
|
|
+ },
|
|
|
+ getMesFirst(loginParams){
|
|
|
+ let info = false;
|
|
|
+ let httpUrl = '/sys/loginFirst';
|
|
|
+ postAction(httpUrl, loginParams).then((res) => {
|
|
|
+ if (!res.success) {
|
|
|
+ this.$message.error( res.message);
|
|
|
+ info=true;
|
|
|
+ return info
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return info;
|
|
|
+ },
|
|
|
|
|
|
|
|
|
}
|