【开发】企业管理员登录

This commit is contained in:
fengachen
2022-08-03 12:03:06 +08:00
parent b8445b3f5a
commit 6a3c9e86a6
3 changed files with 76 additions and 15 deletions
+4 -4
View File
@@ -29,17 +29,17 @@ export function phoneLogin(parameter) {
}
// 管理员账号密码登录
export function conpanyAdminLogin(parameter) {
export function companyAdminLogin(parameter) {
return axios({
url: '/company/smsLogin',
url: '/companyManager/login',
method: 'post',
data: parameter
})
}
// 管理员手机号登录
export function conpanyAdminPhoneLogin(parameter) {
export function companyAdminPhoneLogin(parameter) {
return axios({
url: '/company/smsLogin',
url: '/companyManager/smsLogin',
method: 'post',
data: parameter
})
+55 -5
View File
@@ -1,5 +1,5 @@
import Vue from 'vue'
import { login, logout, phoneLogin, thirdLogin,conpanyAdminLogin,conpanyAdminPhoneLogin } from '@/api/login'
import { login, logout, phoneLogin, thirdLogin,companyAdminLogin,companyAdminPhoneLogin } from '@/api/login'
import {
ACCESS_TOKEN,
USER_NAME,
@@ -128,12 +128,62 @@ const user = {
})
},
// 管理员账号密码登录
CompanyAdminLogin(){
CompanyAdminLogin({ commit }, userInfo){
return new Promise((resolve, reject) => {
companyAdminLogin(userInfo).then(response => {
if (response.code == '200') {
// 初次登录需要跳转至修改密码,不存用户信息
if (response.message === 'updatePassword') {
resolve(response)
} else {
const result = response.result
const userInfo = result.userInfo
Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(UI_CACHE_DB_DICT_DATA, result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000)
commit('SET_TOKEN', result.token)
commit('SET_INFO', userInfo)
commit('SET_NAME', { username: userInfo.username, realname: userInfo.realname, welcome: welcome() })
commit('SET_AVATAR', userInfo.avatar)
resolve(response)
}
} else {
reject(response)
}
}).catch(error => {
reject(error)
})
})
},
// 管理员手机验证码登录
CompanyAdminPhoneLogin() {
CompanyAdminPhoneLogin({ commit }, userInfo) {
return new Promise((resolve, reject) => {
companyAdminPhoneLogin(userInfo).then(response => {
if (response.code == '200') {
// 初次登录需要跳转至修改密码,不存用户信息
if (response.message === 'updatePassword') {
resolve(response)
} else {
const result = response.result
const userInfo = result.userInfo
Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(UI_CACHE_DB_DICT_DATA, result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000)
commit('SET_TOKEN', result.token)
commit('SET_INFO', userInfo)
commit('SET_NAME', { username: userInfo.username, realname: userInfo.realname, welcome: welcome() })
commit('SET_AVATAR', userInfo.avatar)
resolve(response)
}
} else {
reject(response)
}
}).catch(error => {
reject(error)
})
})
},
/**
* 初次手机号登录,修改密码后再存用户信息
+17 -6
View File
@@ -220,7 +220,7 @@ export default {
this.handleChangeCheckCode()
},
methods: {
...mapActions(['Login', 'Logout', 'PhoneLogin']),
...mapActions(['Login', 'Logout', 'PhoneLogin','CompanyAdminLogin','CompanyAdminPhoneLogin']),
/**
* 切换登录方式
* */
@@ -276,11 +276,18 @@ export default {
//登录
console.log(this.isVerificationCodeLogin)
let httpFunction = null
if (this.isVerificationCodeLogin) {
httpFunction = that.PhoneLogin
} else {
httpFunction = that.Login
const actionCollect = {
commonLogin: [that.Login,that.CompanyAdminLogin],
phoneLogin:[that.PhoneLogin,that.CompanyAdminPhoneLogin]
}
// userType 用户类型 0 是普通用户 1是企业管理员 loginType true 是短信登录 false 是账号登录
let actionFunc = function (userType,loginType){
return loginType ? actionCollect.phoneLogin[userType] : actionCollect.commonLogin[userType]
}
httpFunction = actionFunc(this.loginType,this.isVerificationCodeLogin)
httpFunction(loginParams).then((response) => {
if (response.message === 'updatePassword') {
this.$notification['error']({
@@ -323,7 +330,11 @@ export default {
// 登录--1
smsParams.codeType = 1
let interval
getAction('/company/sendVerificationCode', smsParams)
let sendCodeUrl = {
0:'/company/sendVerificationCode',
1:'/companyManager/sendVerificationCode'
}
getAction(sendCodeUrl[this.loginType], smsParams)
.then(res => {
// 验证码获取不成功就不倒计时
if (!res.success) {