Commit e8d223cd by 张立顺

fix:修改master build 报错问题

1 parent 8fa7c589
import util from '@/libs/util.js' import util from '@/libs/util.js'
import { AccountLogin, getAuths, getUserInfo } from '@api/sys.account' import { AccountLogin, getAuths, getUserInfo } from '@api/sys.account'
import { SUPPER_ADMIN } from '@/common/constants' // import { SUPPER_ADMIN } from '@/common/constants'
import { localRoutes } from '@/router/routes' import { localRoutes } from '@/router/routes'
import md5 from 'js-md5' import md5 from 'js-md5'
export default { export default {
...@@ -17,11 +17,12 @@ export default { ...@@ -17,11 +17,12 @@ export default {
// console.log(router.addRoutes); // console.log(router.addRoutes);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var params = { var params = {
userName: p.userName, userName: p.userName,
password: md5(p.password).toLowerCase() password: md5(p.password).toLowerCase()
} }
// 开始请求登录接口 // 开始请求登录接口
AccountLogin(params).then(async(accountInfo = {}) => { AccountLogin(params)
.then(async (accountInfo = {}) => {
// 设置 cookie 一定要存 uuid 和 token 两个 cookie // 设置 cookie 一定要存 uuid 和 token 两个 cookie
// 整个系统依赖这两个数据进行校验和存储 // 整个系统依赖这两个数据进行校验和存储
// uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复 // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
...@@ -29,7 +30,11 @@ export default { ...@@ -29,7 +30,11 @@ export default {
// 如有必要 token 需要定时更新,默认保存一天 // 如有必要 token 需要定时更新,默认保存一天
// util.cookies.set('uuid', accountInfo.loginName) // util.cookies.set('uuid', accountInfo.loginName)
if (accountInfo.accountList.length > 1) { if (accountInfo.accountList.length > 1) {
resolve({ isMutiAccount: true, accountInfo: accountInfo, userInfo: {} }) resolve({
isMutiAccount: true,
accountInfo: accountInfo,
userInfo: {}
})
} else { } else {
util.cookies.set('token', accountInfo.sessionId) util.cookies.set('token', accountInfo.sessionId)
getUserInfo({}).then(async userInfo => { getUserInfo({}).then(async userInfo => {
...@@ -40,9 +45,17 @@ export default { ...@@ -40,9 +45,17 @@ export default {
userInfo.detail[item] = userInfo.loginAccount[item] userInfo.detail[item] = userInfo.loginAccount[item]
} }
}) })
userInfo.merchantAccountLevel = userInfo.detail.merchantAccountLevel userInfo.merchantAccountLevel =
await dispatch('getAuth', { userInfo: userInfo, accountInfo: accountInfo }) userInfo.detail.merchantAccountLevel
resolve({ isMutiAccount: false, accountInfo: accountInfo, userInfo: userInfo }) await dispatch('getAuth', {
userInfo: userInfo,
accountInfo: accountInfo
})
resolve({
isMutiAccount: false,
accountInfo: accountInfo,
userInfo: userInfo
})
}) })
} }
}) })
...@@ -54,8 +67,8 @@ export default { ...@@ -54,8 +67,8 @@ export default {
}, },
/** /**
* @description 获取用户权限 * @description 获取用户权限
* @param {*} param0 * @param {*} param0
* @param {*} param1 * @param {*} param1
*/ */
getAuth({ commit, dispatch }, { userInfo, accountInfo }) { getAuth({ commit, dispatch }, { userInfo, accountInfo }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -66,15 +79,18 @@ export default { ...@@ -66,15 +79,18 @@ export default {
routeAll.splice(routeAll.findIndex(item => item.authId === '907'), 1) routeAll.splice(routeAll.findIndex(item => item.authId === '907'), 1)
routeAll.unshift(indexPage) routeAll.unshift(indexPage)
if (userInfo.detail.accountType !== 7) { if (userInfo.detail.accountType !== 7) {
!res.map(i => i.authId).includes('907') && res.unshift({ !res.map(i => i.authId).includes('907') &&
authId: '907', res.unshift({
name: '总览', authId: '907',
parentId: '1' name: '总览',
}) parentId: '1'
})
} }
var tempAuths = [] var tempAuths = []
var targetRoutes = (res.beSuper) ? routeAll : res.map(i => i.authId) var targetRoutes = res.beSuper ? routeAll : res.map(i => i.authId)
routeAll.map(i => i.authId).forEach((item, index) => { routeAll
.map(i => i.authId)
.forEach((item, index) => {
targetRoutes.includes(item) && tempAuths.push(routeAll[index]) targetRoutes.includes(item) && tempAuths.push(routeAll[index])
if (routeAll[index].hasOwnProperty('addRoutePath')) { if (routeAll[index].hasOwnProperty('addRoutePath')) {
routeAll[index].addRoutePath.forEach(k => { routeAll[index].addRoutePath.forEach(k => {
...@@ -84,20 +100,24 @@ export default { ...@@ -84,20 +100,24 @@ export default {
}) })
} }
}) })
// const authes = (+accountInfo.roleType === SUPPER_ADMIN) ? // const authes = (+accountInfo.roleType === SUPPER_ADMIN) ?
// util.permision.flatten(Object.values(localRoutes)) // util.permision.flatten(Object.values(localRoutes))
// .map(obj => ({ authId: obj.authId, parentId: obj.parentId })) : // .map(obj => ({ authId: obj.authId, parentId: obj.parentId })) :
// tempAuths // tempAuths
const authes = tempAuths const authes = tempAuths
await dispatch('d2admin/auth/set', authes, { root: true }) await dispatch('d2admin/auth/set', authes, { root: true })
// delete accountInfo.authes // delete accountInfo.authes
// 初始化权限 // 初始化权限
await dispatch('d2admin/auth/init', null, { root: true }) await dispatch('d2admin/auth/init', null, { root: true })
// // 设置 vuex 用户信息 // // 设置 vuex 用户信息
await dispatch('d2admin/user/set', { info: userInfo, accountInfo }, { root: true }) await dispatch(
// // 用户登录后从持久化数据加载一系列的设置 'd2admin/user/set',
{ info: userInfo, accountInfo },
{ root: true }
)
// // 用户登录后从持久化数据加载一系列的设置
await dispatch('load') await dispatch('load')
// 结束 // 结束
resolve(userInfo) resolve(userInfo)
}) })
}) })
...@@ -116,8 +136,8 @@ export default { ...@@ -116,8 +136,8 @@ export default {
// util.cookies.remove('uuid') // util.cookies.remove('uuid')
await dispatch('d2admin/user/clear', null, { root: true }) await dispatch('d2admin/user/clear', null, { root: true })
await dispatch('d2admin/base/clear', null, { root: true }) await dispatch('d2admin/base/clear', null, { root: true })
// await commit('d2admin/page/setCurrent', null, { root: true }) // await commit('d2admin/page/setCurrent', null, { root: true })
// await commit('d2admin/auth/set', null, { root: true }) // await commit('d2admin/auth/set', null, { root: true })
resolve() resolve()
}) })
}, },
...@@ -129,23 +149,23 @@ export default { ...@@ -129,23 +149,23 @@ export default {
return new Promise(async resolve => { return new Promise(async resolve => {
// DB -> store 加载用户名 // DB -> store 加载用户名
await dispatch('d2admin/user/load', null, { root: true }) await dispatch('d2admin/user/load', null, { root: true })
// DB -> store 加载主题 // DB -> store 加载主题
await dispatch('d2admin/theme/load', null, { root: true }) await dispatch('d2admin/theme/load', null, { root: true })
// DB -> store 加载页面过渡效果设置 // DB -> store 加载页面过渡效果设置
await dispatch('d2admin/transition/load', null, { root: true }) await dispatch('d2admin/transition/load', null, { root: true })
// DB -> store 持久化数据加载上次退出时的多页列表 // DB -> store 持久化数据加载上次退出时的多页列表
await dispatch('d2admin/page/openedLoad', null, { root: true }) await dispatch('d2admin/page/openedLoad', null, { root: true })
// DB -> store 持久化数据加载侧边栏折叠状态 // DB -> store 持久化数据加载侧边栏折叠状态
await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true }) await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// DB -> store 持久化数据加载全局尺寸 // DB -> store 持久化数据加载全局尺寸
await dispatch('d2admin/size/load', null, { root: true }) await dispatch('d2admin/size/load', null, { root: true })
// DB - > 初始化 基础数据 // DB - > 初始化 基础数据
// await dispatch('d2admin/base/init', null, { root: true }) // await dispatch('d2admin/base/init', null, { root: true })
// 后台接口 -> store // 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true }) // await dispatch('d2admin/auth/init', null, { root: true })
// end // end
resolve() resolve()
}) })
} }
} }
}
\ No newline at end of file \ No newline at end of file
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!