|
@@ -13,13 +13,11 @@
|
|
|
<template v-if="loginType == 1">
|
|
|
<div>
|
|
|
<el-form-item prop="phoneNum">
|
|
|
- <el-input v-model="form.phoneNum" placeholder="请输入手机号" maxlength="11">
|
|
|
- <i slot="prefix" class="el-icon-phone icon"></i>
|
|
|
+ <el-input v-model="form.phoneNum" prefix-icon="el-icon-phone" placeholder="请输入手机号" maxlength="11">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="phoneCode">
|
|
|
- <el-input v-model="form.phoneCode" placeholder="请输入验证码">
|
|
|
- <i slot="prefix" class="iconfont icon-yanzhengma icon"></i>
|
|
|
+ <el-input v-model="form.phoneCode" prefix-icon="el-icon-position" placeholder="请输入验证码">
|
|
|
<el-button slot="append" class="phoneCode" :disabled="phoneCodeText.indexOf('秒')!=-1" @click="getPhoneCode">{{phoneCodeText}}</el-button>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
@@ -28,8 +26,7 @@
|
|
|
<template v-if="loginType == 2">
|
|
|
<div>
|
|
|
<el-form-item prop="username" >
|
|
|
- <el-input v-model="form.username" placeholder="请输入账号" @keyup.enter.native="submit">
|
|
|
- <i slot="prefix" class="iconfont icon-tianjiazhanghao icon"></i>
|
|
|
+ <el-input prefix-icon="el-icon-user" v-model="form.username" placeholder="请输入账号" @keyup.enter.native="submit">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="password" >
|
|
@@ -57,7 +54,7 @@
|
|
|
<span class="forget_btn" @click="changeLoginType">切换{{loginType==1?'账号密码':'手机号'}}登录</span>
|
|
|
</div>
|
|
|
<div class="btn">
|
|
|
- <el-button round style="width:100%;background:var(--color);color:white;height:50px;" @click="submit">登录</el-button>
|
|
|
+ <el-button round style="width:100%;background:var(--color);color:white;height:50px;" :loading="btnLoading" @click="submit">登录</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -74,8 +71,13 @@ export default {
|
|
|
props: {},
|
|
|
data() {
|
|
|
return {
|
|
|
+ btnLoading:false,
|
|
|
loginType:1,
|
|
|
- form:{},
|
|
|
+ form:{
|
|
|
+ username:Storage.getStr('username') || '',
|
|
|
+ password:Storage.getStr('password') || '',
|
|
|
+ phoneNum:Storage.getStr('phoneNum') || ''
|
|
|
+ },
|
|
|
phoneCodeText:'获取验证码',
|
|
|
rules:{
|
|
|
phoneNum: [
|
|
@@ -106,9 +108,6 @@ export default {
|
|
|
methods: {
|
|
|
forget(){
|
|
|
this.btnLoading = true;
|
|
|
- this.$api.adminLogin(this.ruleForm).then(async response => {
|
|
|
-
|
|
|
- })
|
|
|
},
|
|
|
//切换登录方式
|
|
|
changeLoginType(){
|
|
@@ -151,51 +150,37 @@ export default {
|
|
|
|
|
|
})
|
|
|
},
|
|
|
- backAccountLogin(){
|
|
|
- this.$api.backAccountLogin(this.form).then(response=>{
|
|
|
+ //提交信息
|
|
|
+ submit(){
|
|
|
+ this.$refs.ruleForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ var api = ''
|
|
|
+ if(this.loginType==2){
|
|
|
+ api = 'backAccountLogin'
|
|
|
+ }else{
|
|
|
+ api = 'backPhoneLogin'
|
|
|
+ }
|
|
|
+ this.btnLoading = true
|
|
|
+ this.$api[api](this.form).then(response=>{
|
|
|
if(response.code == 200){
|
|
|
+ this.btnLoading = false
|
|
|
this.$cookie.set('token',response.data.token)
|
|
|
Storage.setStr('username', this.form.username)
|
|
|
Storage.setStr('password', this.form.password)
|
|
|
- this.$message.success('登录成功')
|
|
|
- this.$router.replace(
|
|
|
- {
|
|
|
- path:'/administrator/home',
|
|
|
- }
|
|
|
- )
|
|
|
- }else{
|
|
|
- this.$message.error(response.message)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- backPhoneLogin(){
|
|
|
- this.$api.backPhoneLogin(this.form).then(response=>{
|
|
|
- if(response.code == 200){
|
|
|
- this.$cookie.set('token',response.data.token)
|
|
|
Storage.setStr('phoneNum', this.form.phoneNum)
|
|
|
- Storage.setStr('phoneCode', this.form.phoneCode)
|
|
|
this.$message.success('登录成功')
|
|
|
this.$router.replace(
|
|
|
{
|
|
|
path:'/administrator/home',
|
|
|
}
|
|
|
)
|
|
|
- }else{
|
|
|
- this.$message.error(response.message)
|
|
|
}
|
|
|
+ }).catch(error=>{
|
|
|
+ this.btnLoading = false
|
|
|
})
|
|
|
- },
|
|
|
- //提交信息
|
|
|
- submit(){
|
|
|
- this.$refs.ruleForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- if(this.loginType==2)
|
|
|
- {
|
|
|
- this.backAccountLogin();
|
|
|
- }
|
|
|
- else{this.backPhoneLogin();}
|
|
|
+
|
|
|
}else {
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|
|
|
})
|
|
|
|