feature: 配置eslint
This commit is contained in:
+62
-64
@@ -1,23 +1,23 @@
|
||||
import { webLoginType, ssoLogin, ssoLogout } from '@/sysConfig'
|
||||
import { getMenu, loginIdm } from "@/api/process";
|
||||
import { getTokenToWeLink } from "@/api/phoneWeLink";
|
||||
import isMobile from "@/store/isMobile";
|
||||
import store from "@/store";
|
||||
import { getMenu, loginIdm } from '@/api/process'
|
||||
import { getTokenToWeLink } from '@/api/phoneWeLink'
|
||||
import isMobile from '@/store/isMobile'
|
||||
import store from '@/store'
|
||||
import router from '@/router'
|
||||
import hwh5 from '@/api/hwh5-cloudonline.js'
|
||||
import { Message, MessageBox, Loading } from "element-ui";
|
||||
import { Dialog } from 'vant';
|
||||
import { Message, MessageBox, Loading } from 'element-ui'
|
||||
import { Dialog } from 'vant'
|
||||
|
||||
function getCode () {
|
||||
function getCode() {
|
||||
let url = window.location.href
|
||||
if (url && url !== '') {
|
||||
if (url.split('code=').length > 1) {
|
||||
return url.split('code=')[1]
|
||||
return url.split('code=')[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toIdmLoginPage (url) {
|
||||
function toIdmLoginPage(url) {
|
||||
if (webLoginType === 'idm') {
|
||||
let href = url
|
||||
if (href.indexOf('localhost:9090' > -1)) {
|
||||
@@ -29,7 +29,7 @@ function toIdmLoginPage (url) {
|
||||
}
|
||||
|
||||
// 重新登录
|
||||
function loginAgain () {
|
||||
function loginAgain() {
|
||||
store.dispatch('logout').then(() => {
|
||||
if (webLoginType === 'idm') {
|
||||
if (isMobile()) {
|
||||
@@ -47,7 +47,7 @@ function loginAgain () {
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
function loginOut () {
|
||||
function loginOut() {
|
||||
store.dispatch('logout').then(() => {
|
||||
if (webLoginType === 'idm') {
|
||||
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
||||
@@ -64,20 +64,22 @@ function loginInIdm(code) {
|
||||
let loading = Loading.service({
|
||||
lock: true,
|
||||
text: '登录中...',
|
||||
spinner: 'el-icon-loading',
|
||||
spinner: 'el-icon-loading'
|
||||
})
|
||||
let _formData = new FormData()
|
||||
_formData.append('code', code)
|
||||
// 获取用户信息
|
||||
loginIdm(_formData).then(res => {
|
||||
if (res.ok) {
|
||||
loginNew(res).then(() => {
|
||||
resolve()
|
||||
}).finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
loginNew(res)
|
||||
.then(() => {
|
||||
resolve()
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
} else {
|
||||
if(res.respCode && res.respCode === 'r0011'){
|
||||
if (res.respCode && res.respCode === 'r0011') {
|
||||
quit()
|
||||
loading.close()
|
||||
}
|
||||
@@ -87,31 +89,33 @@ function loginInIdm(code) {
|
||||
}
|
||||
|
||||
// welink登录
|
||||
function loginInPhone () {
|
||||
function loginInPhone() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let loading = Loading.service({
|
||||
lock: true,
|
||||
text: '登录中...',
|
||||
spinner: 'el-icon-loading',
|
||||
spinner: 'el-icon-loading'
|
||||
})
|
||||
hwh5.getAuthCode().then(data => {
|
||||
console.log("获取到了welinkCode", data)
|
||||
console.log('获取到了welinkCode', data)
|
||||
if (data) {
|
||||
let code = data.code
|
||||
getTokenToWeLink({
|
||||
code: code,
|
||||
name: encodeURIComponent("standards"+"-"+"regulations"),
|
||||
type:"",
|
||||
corpCode:"",
|
||||
name: encodeURIComponent('standards' + '-' + 'regulations'),
|
||||
type: '',
|
||||
corpCode: ''
|
||||
}).then(res => {
|
||||
if (res.ok) {
|
||||
loginNew(res).then(() => {
|
||||
resolve()
|
||||
}).finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
loginNew(res)
|
||||
.then(() => {
|
||||
resolve()
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
} else {
|
||||
if(res.respCode && res.respCode === 'r0011'){
|
||||
if (res.respCode && res.respCode === 'r0011') {
|
||||
quit()
|
||||
loading.close()
|
||||
}
|
||||
@@ -124,7 +128,7 @@ function loginInPhone () {
|
||||
})
|
||||
}
|
||||
|
||||
function loginNew (res) {
|
||||
function loginNew(res) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (res.data.orgId === null || res.data.orgId === '') {
|
||||
Message.warning('未分配组织机构,请联系管理员分配后重新登录')
|
||||
@@ -138,45 +142,47 @@ function loginNew (res) {
|
||||
userInfo.userId = userInfo.usid
|
||||
store.commit('setToken', userInfo.token)
|
||||
store.commit('setUserInfo', JSON.stringify(userInfo))
|
||||
getMenu({ userId: store.getters.userInfo.userId }).then(menuRes => {
|
||||
if (menuRes.ok) {
|
||||
let hasHomeMenu = false
|
||||
const menuList = menuRes.data
|
||||
menuList.forEach(menu => {
|
||||
if (menu.id === 'asdfadf') {
|
||||
hasHomeMenu = true
|
||||
}
|
||||
})
|
||||
if (hasHomeMenu) {
|
||||
store.dispatch('setMenu', JSON.stringify(menuList)).then(() => {
|
||||
resolve()
|
||||
getMenu({ userId: store.getters.userInfo.userId })
|
||||
.then(menuRes => {
|
||||
if (menuRes.ok) {
|
||||
let hasHomeMenu = false
|
||||
const menuList = menuRes.data
|
||||
menuList.forEach(menu => {
|
||||
if (menu.id === 'asdfadf') {
|
||||
hasHomeMenu = true
|
||||
}
|
||||
})
|
||||
if (hasHomeMenu) {
|
||||
store.dispatch('setMenu', JSON.stringify(menuList)).then(() => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
reject(menuRes)
|
||||
}
|
||||
} else {
|
||||
reject(menuRes)
|
||||
}
|
||||
}).catch(e => {
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function quit () {
|
||||
function quit() {
|
||||
Message.warning('系统无权限访问')
|
||||
if(isMobile()) {
|
||||
if (isMobile()) {
|
||||
Dialog.confirm({
|
||||
message: '您没有系统访问权限,请联系管理员进行授权',
|
||||
message: '您没有系统访问权限,请联系管理员进行授权'
|
||||
}).then(() => {
|
||||
store.dispatch('logout').then(() => {
|
||||
close()
|
||||
})
|
||||
});
|
||||
})
|
||||
} else {
|
||||
MessageBox.confirm('您没有系统访问权限,请联系管理员进行授权', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
showClose: false,
|
||||
showCancelButton: false,
|
||||
showCancelButton: false
|
||||
}).then(() => {
|
||||
store.dispatch('logout').then(() => {
|
||||
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
||||
@@ -185,18 +191,10 @@ function quit () {
|
||||
}
|
||||
}
|
||||
|
||||
function close () {
|
||||
function close() {
|
||||
if (isMobile()) {
|
||||
hwh5.close()
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
toIdmLoginPage,
|
||||
getCode,
|
||||
loginInIdm,
|
||||
loginInPhone,
|
||||
loginAgain,
|
||||
loginOut,
|
||||
close
|
||||
}
|
||||
export { toIdmLoginPage, getCode, loginInIdm, loginInPhone, loginAgain, loginOut, close }
|
||||
|
||||
Reference in New Issue
Block a user