添加手机登录方式密码重置添加提醒
This commit is contained in:
parent
e1cadf9a74
commit
67aa47adb8
|
@ -23,6 +23,13 @@ export default {
|
|||
return await http.post(this.url, data);
|
||||
}
|
||||
},
|
||||
login_sms_code: {
|
||||
url: `${config.API_URL}/auth/login_sms_code/`,
|
||||
name: "手机验证码登录",
|
||||
req: async function(data={}){
|
||||
return await http.post(this.url, data);
|
||||
}
|
||||
},
|
||||
reset_password: {
|
||||
url: `${config.API_URL}/auth/reset_password/`,
|
||||
name: "重置密码",
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
<template>
|
||||
<el-form ref="loginForm" :model="form" :rules="rules" label-width="0" size="large" @keyup.enter="login">
|
||||
<el-form-item prop="phone">
|
||||
<el-form-item prop="phone" style="margin-bottom: 25px;">
|
||||
<el-input v-model="form.phone" prefix-icon="el-icon-iphone" clearable :placeholder="$t('login.mobilePlaceholder')">
|
||||
<template #prepend>+86</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="yzm" style="margin-bottom: 35px;">
|
||||
<el-form-item prop="code" style="margin-bottom: 35px;">
|
||||
<div class="login-msg-yzm">
|
||||
<el-input v-model="form.yzm" prefix-icon="el-icon-unlock" clearable :placeholder="$t('login.smsPlaceholder')"></el-input>
|
||||
<el-input v-model="form.code" prefix-icon="el-icon-unlock" clearable :placeholder="$t('login.smsPlaceholder')"></el-input>
|
||||
<el-button @click="getYzm" :disabled="disabled">{{this.$t('login.smsGet')}}<span v-if="disabled"> ({{time}})</span></el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" style="width: 100%;" :loading="islogin" round @click="login">{{ $t('login.signIn') }}</el-button>
|
||||
</el-form-item>
|
||||
<div class="login-reg">
|
||||
<!-- <div class="login-reg">
|
||||
{{$t('login.noAccount')}} <router-link to="/user_register">{{$t('login.createAccount')}}</router-link>
|
||||
</div>
|
||||
</div> -->
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
|
@ -26,14 +26,23 @@
|
|||
return {
|
||||
form: {
|
||||
phone: "",
|
||||
yzm: "",
|
||||
code: "",
|
||||
},
|
||||
rules: {
|
||||
phone: [
|
||||
{required: true, message: this.$t('login.mobileError')}
|
||||
{required: true, message: this.$t('login.mobileError')},
|
||||
{validator: (rule, value, callback) => {
|
||||
let reg = /^1[3456789]\d{9}$/;
|
||||
if (reg.test(value)) {
|
||||
callback();
|
||||
}else{
|
||||
callback(new Error('请输入正确的手机号'));
|
||||
}
|
||||
}}
|
||||
|
||||
],
|
||||
yzm: [
|
||||
{required: true, message: this.$t('login.smsError')}
|
||||
code: [
|
||||
{ required: true, message: "请输入验证码" }
|
||||
]
|
||||
},
|
||||
disabled: false,
|
||||
|
@ -42,28 +51,77 @@
|
|||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
async getYzm(){
|
||||
let that = this;
|
||||
var validate = await this.$refs.loginForm.validateField("phone").catch(()=>{})
|
||||
if(!validate){ return false }
|
||||
|
||||
this.$message.success(this.$t('login.smsSent'))
|
||||
this.disabled = true
|
||||
this.time = 60
|
||||
var t = setInterval(() => {
|
||||
this.time -= 1
|
||||
if(this.time < 1){
|
||||
clearInterval(t)
|
||||
this.disabled = false
|
||||
this.time = 0
|
||||
}
|
||||
},1000)
|
||||
this.$API.auth.sms_code.req({phone:that.form.phone}).then(res=>{
|
||||
this.$message.success(this.$t('login.smsSent'))
|
||||
this.disabled = true;
|
||||
this.time = 60
|
||||
var t = setInterval(() => {
|
||||
this.time -= 1
|
||||
if(this.time < 1){
|
||||
clearInterval(t)
|
||||
this.disabled = false
|
||||
this.time = 0
|
||||
}
|
||||
},1000)
|
||||
}).catch(err=>{
|
||||
this.disabled = false;
|
||||
this.$message.warning(err)
|
||||
})
|
||||
},
|
||||
async login(){
|
||||
var validate = await this.$refs.loginForm.validate().catch(()=>{})
|
||||
if(!validate){ return false }
|
||||
let that = this;
|
||||
this.$refs.loginForm.validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.$API.auth.login_sms_code.req(that.form).then(res=>{
|
||||
that.$TOOL.cookie.set("TOKEN", res.access, {
|
||||
expires: that.form.autologin ? 24 * 60 * 60 : 0,
|
||||
});
|
||||
that.$TOOL.data.set("TOKEN", res.access);
|
||||
that.$TOOL.data.set("TOKEN_REFRESH", res.refresh);
|
||||
that.$TOOL.cookie.set("TOKEN_REFRESH", res.refresh);
|
||||
that.$TOOL.data.set("TOKEN_TIME", new Date().getTime());
|
||||
that.$API.auth.info.get().then(res1=>{
|
||||
that.$TOOL.data.set("USER_INFO", res1);
|
||||
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
|
||||
if(this.$TOOL.data.get('BASE_INFO').base.base_name_short=='托克逊能管'){//托克逊
|
||||
this.$router.replace({
|
||||
path: "/dashboard_enm",
|
||||
});
|
||||
}else{//曲阳金隅
|
||||
that.$API.am.area.list.req({page_size:999}).then(res => {
|
||||
if (res.err_msg) {
|
||||
} else {
|
||||
debugger;
|
||||
let areaList = res.results;
|
||||
that.$TOOL.data.set("qyjyAreaList", areaList);
|
||||
if(res1.type==='employee'){
|
||||
this.$router.replace({
|
||||
path: "/",
|
||||
});
|
||||
}else{
|
||||
this.$router.replace({
|
||||
path: "/rpm/rpj",
|
||||
});
|
||||
}
|
||||
that.$message.success("Login Success 登录成功");
|
||||
that.islogin = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(err=>{
|
||||
this.disabled = false;
|
||||
this.$message.warning(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
<el-tab-pane :label="$t('login.accountLogin')" lazy>
|
||||
<password-form></password-form>
|
||||
</el-tab-pane>
|
||||
<!-- 手机号登陆
|
||||
<!-- 手机号登陆 -->
|
||||
<el-tab-pane :label="$t('login.mobileLogin')" lazy>
|
||||
<phone-form></phone-form>
|
||||
</el-tab-pane>
|
||||
-->
|
||||
|
||||
</el-tabs>
|
||||
<!-- 微信登陆
|
||||
<el-divider>{{ $t('login.signInOther') }}</el-divider>
|
||||
|
@ -69,7 +69,7 @@
|
|||
|
||||
<script>
|
||||
import { Monitor } from '@element-plus/icons-vue'
|
||||
import passwordForm from './components/passwordForm'
|
||||
import passwordForm from './components/passwordForm'
|
||||
import phoneForm from './components/phoneForm'
|
||||
|
||||
export default {
|
||||
|
|
|
@ -362,11 +362,17 @@ export default {
|
|||
},
|
||||
//重置密码
|
||||
formReset(row){
|
||||
this.$API.system.user.rPassword.req(row.id).then(res=>{
|
||||
this.$message.success("重置成功");
|
||||
}).catch(err=>{
|
||||
|
||||
})
|
||||
this.$confirm(`确认重置密码吗?`,'提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '重置',
|
||||
confirmButtonClass: 'el-button--danger'
|
||||
}).then(() => {
|
||||
this.$API.system.user.rPassword.req(row.id).then(res=>{
|
||||
this.$message.success("重置成功");
|
||||
}).catch(err=>{
|
||||
this.$message.danger(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
//编辑
|
||||
formEdit(row, index) {
|
||||
|
|
Loading…
Reference in New Issue