【bug】企业管理员登录

This commit is contained in:
fengachen
2022-08-03 10:31:57 +08:00
parent 7d06524f86
commit b8445b3f5a
3 changed files with 100 additions and 38 deletions
+17
View File
@@ -28,6 +28,23 @@ export function phoneLogin(parameter) {
}) })
} }
// 管理员账号密码登录
export function conpanyAdminLogin(parameter) {
return axios({
url: '/company/smsLogin',
method: 'post',
data: parameter
})
}
// 管理员手机号登录
export function conpanyAdminPhoneLogin(parameter) {
return axios({
url: '/company/smsLogin',
method: 'post',
data: parameter
})
}
export function getSmsCaptcha(parameter) { export function getSmsCaptcha(parameter) {
return axios({ return axios({
url: api.SendSms, url: api.SendSms,
+9 -1
View File
@@ -1,5 +1,5 @@
import Vue from 'vue' import Vue from 'vue'
import { login, logout, phoneLogin, thirdLogin } from '@/api/login' import { login, logout, phoneLogin, thirdLogin,conpanyAdminLogin,conpanyAdminPhoneLogin } from '@/api/login'
import { import {
ACCESS_TOKEN, ACCESS_TOKEN,
USER_NAME, USER_NAME,
@@ -126,6 +126,14 @@ const user = {
reject(error) reject(error)
}) })
}) })
},
// 管理员账号密码登录
CompanyAdminLogin(){
},
// 管理员手机验证码登录
CompanyAdminPhoneLogin() {
}, },
/** /**
* 初次手机号登录,修改密码后再存用户信息 * 初次手机号登录,修改密码后再存用户信息
+74 -37
View File
@@ -126,8 +126,9 @@
<a-row style="margin-bottom: 2%;"> <a-row style="margin-bottom: 2%;">
<a-col :span="6"></a-col> <a-col :span="6"></a-col>
<!-- 切换登录方式--> <!-- 切换登录方式-->
<!-- 企业管理员 去掉注册 去掉忘记密码 -->
<a-col :span="4"> <a-col :span="4">
<a-form-item> <a-form-item v-if="loginType === 0">
<div @click="handleRegister" class="forget-password" style="margin-left: 5px;">注册</div> <div @click="handleRegister" class="forget-password" style="margin-left: 5px;">注册</div>
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -139,33 +140,45 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="4" style="text-align: right;"> <a-col :span="4" style="text-align: right;">
<a-form-item> <a-form-item v-if="loginType === 0">
<span @click='forgetPassword' class="forget-password" style="float: right;"> <span @click='forgetPassword' class="forget-password" style="float: right;">
忘记密码 <img style='height: 14px' src='../../assets/wenhao.png' alt=''> 忘记密码 <img style='height: 14px' src='../../assets/wenhao.png' alt=''>
</span> </span>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row>
<a-col :span="6"></a-col>
<a-col :span="10">
<div>
<span @click="toggleLoginType" class="company-admin-login">{{ loginTip }}</span>
</div>
</a-col>
</a-row>
</div> </div>
</a-form> </a-form>
</div> </div>
</template> </template>
<script> <script>
import { mapActions } from 'vuex' import {mapActions} from 'vuex'
import { timeFix } from '@/utils/util' import {timeFix} from '@/utils/util'
import Vue from 'vue' import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types' import {ACCESS_TOKEN} from '@/store/mutation-types'
import { getAction } from '@/api/manage' import {getAction} from '@/api/manage'
import { getRSAPublicKey } from '@/api/login.js' import {getRSAPublicKey} from '@/api/login.js'
import { JSEncrypt } from 'jsencrypt' import {JSEncrypt} from 'jsencrypt'
import { phoneReg } from '@/utils/validate' import {phoneReg} from '@/utils/validate'
export default { export default {
components: {}, components: {},
data() { data() {
return { return {
loginBtn: false, loginBtn: false,
loginType: 0, loginType: 0, // 登录方式 0 普通用户登录 1企业管理员登录
loginTipObj: {
1: '普通用户登录',
0: '企业管理员登录'
},
stepCaptchaVisible: false, stepCaptchaVisible: false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
state: { state: {
@@ -173,12 +186,12 @@ export default {
smsSendBtn: false smsSendBtn: false
}, },
validatorRules: { validatorRules: {
username: { rules: [{ required: true, message: '请输入手机号!' }, { validator: this.checkPhone }] }, username: {rules: [{required: true, message: '请输入手机号!'}, {validator: this.checkPhone}]},
password: { rules: [{ required: true, message: '请输入密码!' }] }, password: {rules: [{required: true, message: '请输入密码!'}]},
mobile: { rules: [{ validator: this.validateMobile }] }, mobile: {rules: [{validator: this.validateMobile}]},
captcha: { rules: [{ required: true, message: '请输入验证码!' }] }, captcha: {rules: [{required: true, message: '请输入验证码!'}]},
inputCode: { rules: [{ required: true, message: '请输入验证码!' }] }, inputCode: {rules: [{required: true, message: '请输入验证码!'}]},
phone: { rules: [{ required: true, message: '请输入手机号!' }, { validator: this.checkPhone }] } phone: {rules: [{required: true, message: '请输入手机号!'}, {validator: this.checkPhone}]}
}, },
velorifiedCode: '', velorifiedCode: '',
inputCodeContent: '', inputCodeContent: '',
@@ -192,6 +205,13 @@ export default {
needSetPassword: false // 是否需要设置密码 needSetPassword: false // 是否需要设置密码
} }
}, },
computed: {
// 底部提示的登录方式文字
loginTip() {
return this.loginTipObj[this.loginType]
}
},
created() { created() {
document.title = '汽车标准化工作平台' document.title = '汽车标准化工作平台'
this.currdatetime = new Date().getTime() this.currdatetime = new Date().getTime()
@@ -201,16 +221,20 @@ export default {
}, },
methods: { methods: {
...mapActions(['Login', 'Logout', 'PhoneLogin']), ...mapActions(['Login', 'Logout', 'PhoneLogin']),
handleUsernameOrEmail(rule, value, callback) { /**
const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/ * 切换登录方式
if (regex.test(value)) { * */
this.loginType = 0 toggleLoginType() {
} else {
this.loginType = 1
}
callback()
},
if (this.loginType === 0) {
this.loginType = 1
} else if (this.loginType === 1) {
this.loginType = 0
}
// 清空表单
this.form.resetFields()
},
/** /**
* 验证手机号 * 验证手机号
* @param rule * @param rule
@@ -232,7 +256,7 @@ export default {
let that = this let that = this
let loginParams = {} let loginParams = {}
that.loginBtn = true that.loginBtn = true
that.form.validateFields(['username', 'password', 'inputCode', 'captcha', 'rememberMe'], { force: true }, (err, values) => { that.form.validateFields(['username', 'password', 'inputCode', 'captcha', 'rememberMe'], {force: true}, (err, values) => {
if (!err) { if (!err) {
loginParams.remember_me = values.rememberMe loginParams.remember_me = values.rememberMe
// 手机登录验证码 // 手机登录验证码
@@ -289,7 +313,7 @@ export default {
getCaptcha(e) { getCaptcha(e) {
e.preventDefault() e.preventDefault()
let that = this let that = this
this.form.validateFields(['username'], { force: true }, (err, values) => { this.form.validateFields(['username'], {force: true}, (err, values) => {
if (!values.username) { if (!values.username) {
that.cmsFailed('请输入手机号') that.cmsFailed('请输入手机号')
} else if (!err) { } else if (!err) {
@@ -317,12 +341,12 @@ export default {
} }
setTimeout(hide, 500) setTimeout(hide, 500)
}).catch(err => { }).catch(err => {
setTimeout(hide, 1) setTimeout(hide, 1)
clearInterval(interval) clearInterval(interval)
that.state.time = 60 that.state.time = 60
that.state.smsSendBtn = false that.state.smsSendBtn = false
this.requestFailed(err) this.requestFailed(err)
}) })
} }
} }
) )
@@ -335,11 +359,11 @@ export default {
}, },
// 忘记密码 // 忘记密码
forgetPassword() { forgetPassword() {
this.$router.push({ name: 'alteration' }) this.$router.push({name: 'alteration'})
}, },
handleChangeCheckCode() { handleChangeCheckCode() {
this.currdatetime = new Date().getTime() this.currdatetime = new Date().getTime()
getAction(`/sys/randomImage/${ this.currdatetime }`).then(res => { getAction(`/sys/randomImage/${this.currdatetime}`).then(res => {
if (res.success) { if (res.success) {
this.randCodeImage = res.result this.randCodeImage = res.result
this.requestCodeSuccess = true this.requestCodeSuccess = true
@@ -362,11 +386,11 @@ export default {
loginSuccess() { loginSuccess() {
// this.$router.push({ path: "/dashboard/analysis" }).catch((res)=>{}) // this.$router.push({ path: "/dashboard/analysis" }).catch((res)=>{})
// 进入首页 // 进入首页
this.$router.push({ path: '/' }).catch(() => { this.$router.push({path: '/'}).catch(() => {
}) })
this.$notification.success({ this.$notification.success({
message: '欢迎', message: '欢迎',
description: `${ timeFix() },欢迎回来` description: `${timeFix()},欢迎回来`
}) })
}, },
cmsFailed(err) { cmsFailed(err) {
@@ -527,4 +551,17 @@ export default {
height: 60px; height: 60px;
border: 1px solid #E6E3E3; border: 1px solid #E6E3E3;
} }
// 企业管理员登录
.center {
display: flex;
justify-content: center;
align-items: center;
}
.company-admin-login {
user-select: none;
cursor: pointer;
color: #BFBFBF;
}
</style> </style>