diff --git a/package.json b/package.json index 096b8eb..360e836 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,8 @@ "element-ui": "2.13.0", "ezuikit-js": "^0.6.1", "jquery": "3.4.1", + "js-cookie": "^2.2.1", + "jsencrypt": "^3.0.0-rc.1", "ol": "6.1.1", "proj4": "2.5.0", "v-scale-screen": "^1.0.2", diff --git a/src/api/login.js b/src/api/login.js index df61db7..0020b19 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,10 +1,40 @@ import request from '@/utils/request'; - +import { encrypt } from '@/utils/jsencrypt' // 公钥,私钥都声明在里面 // 获取用户详细信息 export function getInfo () { return request({ - url: 'api/getInfo', + url: '/api/getInfo', method: 'get' }) +} +// 登录方法 +export function login (username, password, code, uuid) { + const data = { + username, + password, + code, + uuid + } + data.username = encrypt(username); + data.password = encrypt(password); + return request({ + url: 'api/login', + method: 'post', + data: data + }) +} +export function getCodeImg () { + return request({ + url: '/api/gkyzm', + method: 'get' + }) +} + +// 退出方法 +export function logout () { + return request({ + url: '/api/logout', + method: 'post' + }) } \ No newline at end of file diff --git a/src/permission.js b/src/permission.js index 733221d..c1767c2 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,18 +1,193 @@ -import router from './router'; -import store from './store'; -const whiteList = ['/login']; // 不重定向白名单 +import router from './router' +import store from './store' +import { Message } from 'element-ui' +import NProgress from 'nprogress' +import 'nprogress/nprogress.css' +import { getToken } from '@/utils/auth' +import { getDicts } from "@/api/system/dict/data"; +import Cookies from "js-cookie"; +NProgress.configure({ showSpinner: false }) + +const whiteList = [ + '/login', + '/login_index', + '/auth-redirect', + '/bind', + '/register', + '/login_deposit', + '/loginSingle', + '/login_enforce', + '/login_house', + '/login_trans', + '/login_finance', + '/login_society', + '/login_three', + '/login_land', + '/login_item', + '/login_company', + '/login_entity', + '/login_yinnong', + '/login_chungeng', + // '/login_test', +] + router.beforeEach((to, from, next) => { - if (store.getters.loginInfo) { + NProgress.start() + + if (store.getters.systemConfigList.length == 0) { + store.dispatch('systemTitle').then(() => { + document.title = store.getters.browserName == '' ? '农经综合信息管理平台' : store.getters.browserName + }) + } + if (getToken()) { + /* has token*/ if (to.path === '/login') { - next({ path: '/login' }); + next({ path: '/' }) + NProgress.done() } else { - next(); + if (store.getters.roles.length === 0) { + // 判断当前用户是否已拉取完user_info信息 + store.dispatch('GetInfo').then(res => { + if (res && res.code && res.code == 200) { + // 拉取user_info + + let businessOwnerList = res.user.businessOwnership; + + if (businessOwnerList != null) { + getDicts("business_ownership").then((response) => { + let businessOwnerArr = businessOwnerList.split(',') + let businessOwnerArrSort = businessOwnerArr.sort((a, b) => {//升序 + return a - b + }); + let arrLable = [] + response.data.forEach((v, i) => { + businessOwnerArr.forEach((data, length) => { + if (v.dictValue == data) { + arrLable.push({ + dictValue: v.dictValue, + dictLabel: v.dictLabel, + remark: v.remark, + dictSort: v.dictSort + }) + } + }) + }) + + let routerId = window.localStorage.getItem("routerId"); + let bookType = res.user.bookType; + let endDictValue; + const viewPagesProfileId = Cookies.get("viewPagesProfileId"); + if ( + viewPagesProfileId == undefined || + viewPagesProfileId == "" || + viewPagesProfileId == null + ) { + if (routerId == null || businessOwnerArrSort.includes(routerId) == false) { + if (businessOwnerArrSort.includes("1") || businessOwnerArrSort.includes("2") || businessOwnerArrSort.includes("3")) { + if (bookType == 1) { + endDictValue = 1; + } else if (bookType == 2) { + endDictValue = 2; + } else if (bookType == 3) { + endDictValue = 3; + } else if (bookType == 8) { + endDictValue = 8; + } else { + endDictValue = arrLable[0].dictValue + } + } else { + endDictValue = arrLable[0].dictValue + } + } else { + + if (businessOwnerArrSort.includes("1") || businessOwnerArrSort.includes("2") || businessOwnerArrSort.includes("3") || businessOwnerArrSort.includes("8")) { + if (bookType == 1) { + if (routerId == 2 || routerId == 3 || routerId == 8) { + endDictValue = 1; + } else { + endDictValue = routerId; + } + } else if (bookType == 2) { + if (routerId == 1 || routerId == 3 || routerId == 8) { + endDictValue = 2; + } else { + endDictValue = routerId; + + } + } else if (bookType == 3) { + if (routerId == 2 || routerId == 1 || routerId == 8) { + endDictValue = 3; + } else { + endDictValue = routerId; + + } + } else if (bookType == 8) { + if (routerId == 1 || routerId == 2 || routerId == 3) { + endDictValue = 8; + } else { + endDictValue = routerId; + } + } else { + endDictValue = routerId; + } + } else { + if (routerId) { + endDictValue = routerId; + } else { + endDictValue = arrLable[0].dictValue + } + } + } + } else { + endDictValue = viewPagesProfileId; + } + + store.dispatch('GenerateRoutes', endDictValue).then(accessRoutes => { + // 根据roles权限生成可访问的路由表 + router.addRoutes(accessRoutes) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 + }) + }) + } else { + store.dispatch('GenerateRoutes', 'no-router').then(accessRoutes => { + // 根据roles权限生成可访问的路由表 + router.addRoutes(accessRoutes) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 + }) + } + + } + }).catch(err => { + store.dispatch('LogOut').then(() => { + Message.error(err) + next({ path: '/' }) + }) + }) + } else { + next() + } } } else { + // 没有token if (whiteList.indexOf(to.path) !== -1) { - next(); + // 在免登录白名单,直接进入 + next() + } else if (to.path.indexOf('dataScreen') != -1) { + next() + } else if (to.path.indexOf('subcontract') != -1) { + next() } else { - next(`/login?redirect=${to.path}`); // 否则全部重定向到登录页 + if (to.query && to.query.code && to.query.exiturl) { + next(`/login?code=${to.query.code}&exiturl=${to.query.exiturl}`) + } else { + next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 + } + //next(`/zjdLogin?redirect=${to.fullPath}`) // 否则全部重定向到登录页 + NProgress.done() } } -}); +}) + +router.afterEach(() => { + NProgress.done() +}) diff --git a/src/router/index.js b/src/router/index.js index 714edfb..427cfcb 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -6,7 +6,13 @@ const routes = [ { path: '/', name: 'root', - redirect: '/capital' + redirect: '/login' + }, + // 资金 + { + path: '/nav', + name: 'nav', + component: () => import('@/views/nav/index.vue') }, // 资金 { @@ -14,6 +20,11 @@ const routes = [ name: 'capital', component: () => import('@/views/capital/index.vue') }, + { + path: '/login', + name: 'login', + component: () => import('@/views/login/index.vue') + }, // 资源 { path: '/resources', diff --git a/src/store/app/actions.js b/src/store/app/actions.js deleted file mode 100644 index 3436457..0000000 --- a/src/store/app/actions.js +++ /dev/null @@ -1,27 +0,0 @@ -import { login } from '@/api/login.js'; -import { setToken } from '@/utils/auth'; -import { Message } from 'element-ui'; - -export const actions = { - // 登录 - Login ({ commit }, params) { - return new Promise((resolve, reject) => { - login(params).then(response => { - if (response.code !== '0') { - Message({ - message: response.reason, - type: 'error', - duration: 2000 - }); - resolve(); - }; - const data = response.data; - commit('SET_LOGIN_INFO', data); - setToken(data.token); - resolve(); - }).catch(error => { - reject(error); - }); - }); - } -}; diff --git a/src/store/app/getters.js b/src/store/app/getters.js deleted file mode 100644 index 18925af..0000000 --- a/src/store/app/getters.js +++ /dev/null @@ -1,6 +0,0 @@ -export const getters = { - areaCode: state => state.areaCode, - loginInfo: state => state.loginInfo, - industrialSubjectOccupancy: state => state.industrialSubjectOccupancy, - currentLayerName: state => state.currentLayerName -}; diff --git a/src/store/app/index.js b/src/store/app/index.js deleted file mode 100644 index a4f4e09..0000000 --- a/src/store/app/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import { state } from './state'; -import { mutations } from './mutations'; -import { actions } from './actions'; -import { getters } from './getters'; - -export default { - state, - mutations, - actions, - getters -}; diff --git a/src/store/app/mutations.js b/src/store/app/mutations.js deleted file mode 100644 index e5da307..0000000 --- a/src/store/app/mutations.js +++ /dev/null @@ -1,14 +0,0 @@ -export const mutations = { - SET_CURRENT_AREACODE: (state, areaCode) => { // 当前地图层级信息 - state.areaCode = areaCode; - }, - SET_LOGIN_INFO: (state, item) => { - state.loginInfo = item; - }, - RESET_LOGIN_INFO: (state) => { - state.loginInfo = null; - }, - SET_CURRENT_LAYERNAME: (state, currentLayerName) => { - state.currentLayerName = currentLayerName; - }, -}; diff --git a/src/store/app/state.js b/src/store/app/state.js deleted file mode 100644 index cf702ef..0000000 --- a/src/store/app/state.js +++ /dev/null @@ -1,5 +0,0 @@ -export const state = { - areaCode: '', - loginInfo: null, - currentLayerName: '' // 当前操作的图层名 -}; diff --git a/src/store/getters.js b/src/store/getters.js new file mode 100644 index 0000000..3146bad --- /dev/null +++ b/src/store/getters.js @@ -0,0 +1,39 @@ +const getters = { + sidebar: state => state.app.sidebar, + size: state => state.app.size, + device: state => state.app.device, + visitedViews: state => state.tagsView.visitedViews, + cachedViews: state => state.tagsView.cachedViews, + token: state => state.user.token, + avatar: state => state.user.avatar, + name: state => state.user.name, + introduction: state => state.user.introduction, + roles: state => state.user.roles, + userRoles:state => state.user.userRoles, + permissions: state => state.user.permissions, + setUpModuleId: state => state.user.setUpModuleId, + permission_routes: state => state.permission.routes, + bookName: state => state.user.bookName, + sidebarRouters: state => state.permission.sidebarRouters, + nickName: state => state.user.nickName, + businessOwnership: state => state.user.businessOwnership, + deptLevel: state => state.user.deptLevel, + businessLevel: state => state.user.businessLevel, + bookType: state => state.user.bookType, + deptname: state => state.user.deptname, + leader: state => state.user.leader, + parentDeptName: state => state.user.parentDeptName, + deptName: state => state.user.deptName, + userType: state => state.user.userType, + allDeptName: state => state.user.allDeptName, + systemConfigList: state => state.user.systemConfigList, //获取登录页标题 + loginSystemName: state => state.user.loginSystemName, //系统名称 + browserName: state => state.user.browserName, //浏览器页签名称 + technicalSupport: state => state.user.technicalSupport, //技术支持 + noticeThree: state => state.user.noticeThree, //阅读须知 0 未阅读 + baseRoutingUrl: state => state.user.baseRoutingUrl, //资源文件访问前缀 + bigscreenUrl: state => state.user.bigscreenUrl, //大数据指挥舱 + globalLogo: state => state.user.globalLogo, //全局logo + screenLogo: state => state.user.screenLogo, //大屏logo + } +export default getters diff --git a/src/store/index.js b/src/store/index.js index f4c2cfa..eceb2cd 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,19 +1,23 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; -import VuexPersistence from 'vuex-persist'; +import Vue from 'vue' +import Vuex from 'vuex' +import app from './modules/app' +import user from './modules/user' +import tagsView from './modules/tagsView' +import permission from './modules/permission' +import settings from './modules/settings' +import getters from './getters' -import app from '@/store/app/index.js'; +Vue.use(Vuex) -Vue.use(Vuex); - -const vuexLocal = new VuexPersistence({ - key: 'rongxin.nongjing.expo', - modules: ['app'] -}); - -export default new Vuex.Store({ +const store = new Vuex.Store({ modules: { - app + app, + user, + tagsView, + permission, + settings }, - plugins: [vuexLocal.plugin] -}); + getters +}) + +export default store diff --git a/src/store/modules/app.js b/src/store/modules/app.js new file mode 100644 index 0000000..5043299 --- /dev/null +++ b/src/store/modules/app.js @@ -0,0 +1,54 @@ + +const state = { + sidebar: { + withoutAnimation: false + }, + device: 'desktop', +} + +const mutations = { + TOGGLE_SIDEBAR: state => { + state.sidebar.opened = !state.sidebar.opened + state.sidebar.withoutAnimation = false + }, + CLOSE_SIDEBAR: (state, withoutAnimation) => { + state.sidebar.opened = false + state.sidebar.withoutAnimation = withoutAnimation + }, + OPEN_SIDEBAR: state => { + state.sidebar.opened = true; + state.sidebar.withoutAnimation = false; + }, + + TOGGLE_DEVICE: (state, device) => { + state.device = device + }, + SET_SIZE: (state, size) => { + state.size = size + } +} + +const actions = { + toggleSideBar ({ commit }) { + commit('TOGGLE_SIDEBAR') + }, + closeSideBar ({ commit }, { withoutAnimation }) { + commit('CLOSE_SIDEBAR', withoutAnimation) + }, + openSideBar ({ commit }) { + commit('OPEN_SIDEBAR') + }, + toggleDevice ({ commit }, device) { + commit('TOGGLE_DEVICE', device) + }, + setSize ({ commit }, size) { + commit('SET_SIZE', size) + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js new file mode 100644 index 0000000..59fb1bb --- /dev/null +++ b/src/store/modules/permission.js @@ -0,0 +1,51 @@ +import { constantRoutes } from '@/router' + +const permission = { + state: { + routes: [], + addRoutes: [], + sidebarRouters: [] + }, + mutations: { + SET_ROUTES: (state, routes) => { + state.addRoutes = routes + state.routes = constantRoutes.concat(routes) + }, + SET_SIDEBAR_ROUTERS: (state, routers) => { + state.sidebarRouters = constantRoutes.concat(routers) + }, + }, + actions: { + } +} + + +function filterChildren (childrenMap) { + var children = [] + childrenMap.forEach((el, index) => { + if (el.children && el.children.length) { + if (el.component === 'ParentView') { + el.children.forEach(c => { + c.path = el.path + '/' + c.path + if (c.children && c.children.length) { + children = children.concat(filterChildren(c.children, c)) + return + } + children.push(c) + }) + return + } + } + children = children.concat(el) + }) + return children +} +export const loadView = (view) => { + if (process.env.NODE_ENV === 'development') { + return (resolve) => require([`@/views/${view}`], resolve) + } else { + // 使用 import 实现生产环境的路由懒加载 + return () => import(`@/views/${view}`) + } +} +export default permission diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js new file mode 100644 index 0000000..f1082c1 --- /dev/null +++ b/src/store/modules/settings.js @@ -0,0 +1,18 @@ + + +const state = { +} + +const mutations = { +} + +const actions = { +} + +export default { + namespaced: true, + state, + mutations, + actions +} + diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js new file mode 100644 index 0000000..abec622 --- /dev/null +++ b/src/store/modules/tagsView.js @@ -0,0 +1,159 @@ +const state = { + visitedViews: [], + cachedViews: [] +} + +const mutations = { + ADD_VISITED_VIEW: (state, view) => { + if (state.visitedViews.some(v => v.path === view.path)) return + state.visitedViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) + }, + ADD_CACHED_VIEW: (state, view) => { + if (state.cachedViews.includes(view.name)) return + if (!view.meta.noCache) { + state.cachedViews.push(view.name) + } + }, + + DEL_VISITED_VIEW: (state, view) => { + for (const [i, v] of state.visitedViews.entries()) { + if (v.path === view.path) { + state.visitedViews.splice(i, 1) + break + } + } + }, + DEL_CACHED_VIEW: (state, view) => { + const index = state.cachedViews.indexOf(view.name) + index > -1 && state.cachedViews.splice(index, 1) + }, + + DEL_OTHERS_VISITED_VIEWS: (state, view) => { + state.visitedViews = state.visitedViews.filter(v => { + return v.meta.affix || v.path === view.path + }) + }, + DEL_OTHERS_CACHED_VIEWS: (state, view) => { + const index = state.cachedViews.indexOf(view.name) + if (index > -1) { + state.cachedViews = state.cachedViews.slice(index, index + 1) + } else { + state.cachedViews = [] + } + }, + + DEL_ALL_VISITED_VIEWS: state => { + // keep affix tags + const affixTags = state.visitedViews.filter(tag => tag.meta.affix) + state.visitedViews = affixTags + }, + DEL_ALL_CACHED_VIEWS: state => { + state.cachedViews = [] + }, + + UPDATE_VISITED_VIEW: (state, view) => { + for (let v of state.visitedViews) { + if (v.path === view.path) { + v = Object.assign(v, view) + break + } + } + } +} + +const actions = { + addView({ dispatch }, view) { + dispatch('addVisitedView', view) + dispatch('addCachedView', view) + }, + addVisitedView({ commit }, view) { + commit('ADD_VISITED_VIEW', view) + }, + addCachedView({ commit }, view) { + commit('ADD_CACHED_VIEW', view) + }, + + delView({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delVisitedView', view) + dispatch('delCachedView', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delVisitedView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_VISITED_VIEW', view) + resolve([...state.visitedViews]) + }) + }, + delCachedView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_CACHED_VIEW', view) + resolve([...state.cachedViews]) + }) + }, + + delOthersViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delOthersVisitedViews', view) + dispatch('delOthersCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delOthersVisitedViews({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_OTHERS_VISITED_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, + delOthersCachedViews({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_OTHERS_CACHED_VIEWS', view) + resolve([...state.cachedViews]) + }) + }, + + delAllViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delAllVisitedViews', view) + dispatch('delAllCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delAllVisitedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_VISITED_VIEWS') + resolve([...state.visitedViews]) + }) + }, + delAllCachedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_CACHED_VIEWS') + resolve([...state.cachedViews]) + }) + }, + + updateVisitedView({ commit }, view) { + commit('UPDATE_VISITED_VIEW', view) + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/src/store/modules/user.js b/src/store/modules/user.js new file mode 100644 index 0000000..ed57960 --- /dev/null +++ b/src/store/modules/user.js @@ -0,0 +1,341 @@ +import { login, singleLogin, logout, getInfo, smsLogin, getConfig, systemConfig, chungengUserLogin } from '@/api/login' + +import { getToken, setToken, removeToken } from '@/utils/auth' + +const user = { + state: { + token: getToken(), + name: '', + avatar: '', + roles: [], + userRoles: [], + permissions: [], + bookName: '', + setUpModuleId: '', + //获取登录页相关标题 + systemConfigList: [], + //系统名称 + loginSystemName: '', + //浏览器页签名称 + browserName: '', + //技术支持 + technicalSupport: '', + //是否阅读须知 + noticeThree: '', + //界面logo + globalLogo: '', + //系统大屏logo + screenLogo: '' + }, + + mutations: { + SET_TOKEN: (state, token) => { + state.token = token + }, + SET_SETUPMODULE: (state, setUpModuleId) => { + state.setUpModuleId = setUpModuleId + }, + SET_NAME: (state, name) => { + state.name = name + }, + SET_USERID: (state, userId) => { + state.userId = userId + }, + SET_NICKNAME: (state, nickName) => { + state.nickName = nickName + }, + SET_AVATAR: (state, avatar) => { + state.avatar = avatar + }, + SET_ROLES: (state, roles) => { + state.roles = roles + }, + SET_USERROLES: (state, roles) => { + state.userRoles = roles + }, + SET_PERMISSIONS: (state, permissions) => { + state.permissions = permissions + }, + SET_LOGINDEPTID: (state, loginDeptId) => { + state.loginDeptId = loginDeptId + }, + SET_LOGINBOOKID: (state, loginBookId) => { + state.loginBookId = loginBookId + }, + SET_DEPTNAME: (state, deptName) => { + state.deptName = deptName + }, + SET_DEPT_NAME: (state, deptname) => { + state.deptname = deptname + }, + SET_LEADER: (state, leader) => { + state.leader = leader + }, + SET_DEPTID: (state, deptId) => { + state.deptId = deptId + }, + SET_BOOKNAME: (state, bookName) => { + state.bookName = bookName + }, + SET_BUSINESSOWNERSHIP: (state, businessOwnership) => { + state.businessOwnership = businessOwnership + }, + SET_OFFICIALSEAL: (state, officialSeal) => { + state.officialSeal = officialSeal + }, + SET_DEPTLEVEL: (state, deptLevel) => { + state.deptLevel = deptLevel + }, + SET_BASEROUTINGURL: (state, baseRoutingUrl) => { + state.baseRoutingUrl = baseRoutingUrl + }, + SET_BUSINESSLEVEL: (state, businessLevel) => { + state.businessLevel = businessLevel + }, + SET_BOOKTYPE: (state, bookType) => { + state.bookType = bookType + }, + SET_PARENTDEPTNAME: (state, parentDeptName) => { + state.parentDeptName = parentDeptName + }, + SET_USERTYPE: (state, userType) => { + state.userType = userType + }, + SET_ALLDEPTNAME: (state, allDeptName) => { + state.allDeptName = allDeptName + }, + SET_STSTEMCONFIGlIST: (state, systemConfigList) => { + state.systemConfigList = systemConfigList + }, + SET_LOGINSYSTEMNAME: (state, loginSystemName) => { + state.loginSystemName = loginSystemName + }, + SET_BORWSERNAME: (state, browserName) => { + state.browserName = browserName + }, + SET_TECHNICALSUPPORT: (state, technicalSupport) => { + state.technicalSupport = technicalSupport + }, + SET_BIGSCREENURL: (state, bigscreenUrl) => { + state.bigscreenUrl = bigscreenUrl + }, + SET_NOTICETHREE: (state, noticeThree) => { + state.noticeThree = noticeThree + }, + SET_GLOBALLOGO: (state, globalLogo) => { + state.globalLogo = globalLogo + }, + SET_SCREENLOGO: (state, screenLogo) => { + state.screenLogo = screenLogo + }, + }, + + actions: { + // 登录 + Login ({ commit }, userInfo) { + const username = userInfo.username.trim() + const password = userInfo.password + const code = userInfo.code + const uuid = userInfo.uuid + return new Promise((resolve, reject) => { + login(username, password, code, uuid).then(res => { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve(res) + }).catch(error => { + reject(error) + }) + }) + }, + + SingleLogin ({ commit }, userInfo) { + const code = userInfo.code + return new Promise((resolve, reject) => { + singleLogin(code).then(res => { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve() + }).catch(error => { + reject(error) + }) + }) + + }, + + + + //设置用户当前模块系统 + setUpModule ({ commit }, setUpModuleId) { + commit('SET_SETUPMODULE', setUpModuleId) + }, + + //短信验证码登录 + SmsLogin ({ commit }, userInfo) { + const mobile = userInfo.mobile.trim() + const smsCode = userInfo.smsCode + const uuid = userInfo.uuid + return new Promise((resolve, reject) => { + smsLogin(mobile, smsCode, uuid).then(res => { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve() + }).catch(error => { + reject(error) + }) + }) + + }, + + // 获取用户信息 + GetInfo ({ commit, state }) { + return new Promise((resolve, reject) => { + getInfo(state.token).then(res => { + if (res && res.code && res.code == 200) { + const user = res.user + // const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; + const avatar = user.avatar == "" ? "" : process.env.VUE_APP_BASE_API + user.avatar; + if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 + commit('SET_ROLES', res.roles) + commit('SET_PERMISSIONS', res.permissions) + } else { + commit('SET_ROLES', ['ROLE_DEFAULT']) + } + commit('SET_USERROLES', user.roles) + commit('SET_BOOKNAME', user.bookName) + commit('SET_NAME', user.userName) + commit('SET_USERID', user.userId) + commit('SET_NICKNAME', user.nickName) + commit('SET_LOGINDEPTID', user.loginDeptId) + commit('SET_LOGINBOOKID', user.loginBookId) + commit('SET_DEPTNAME', user.deptName) + commit('SET_DEPT_NAME', user.dept.deptName) + commit('SET_LEADER', user.dept.leader) + commit('SET_DEPTID', user.deptId) + commit('SET_AVATAR', avatar) + commit('SET_BUSINESSOWNERSHIP', user.businessOwnership) + commit('SET_BUSINESSLEVEL', user.businessLevel) + commit('SET_BOOKTYPE', user.bookType) + commit('SET_PARENTDEPTNAME', user.parentDeptName) + commit('SET_USERTYPE', user.userType) + commit('SET_ALLDEPTNAME', user.allDeptName) + commit('SET_NOTICETHREE', user.noticeThree) + commit('SET_OFFICIALSEAL', user.officialSeal) + } + + getConfig().then((num) => { + // console.log(res) + if (num && num.code == 200) { + let content = num.data; + commit('SET_DEPTLEVEL', content.deptLevel) + } + }) + systemConfig({ configKey: 'system.attachment' }).then((data) => { + if (data.code == 200) { + let content = data.rows; + if (content.length != 0) { + let baseRoutingUrl = content[0].configValue; + commit('SET_BASEROUTINGURL', baseRoutingUrl) + + } + } + }) + resolve(res) + }).catch(error => { + reject(error) + }) + }) + }, + + //获取登录页相关标题 + systemTitle ({ commit, state }) { + return new Promise((resolve, reject) => { + systemConfig({ configKey: 'system' }).then((data) => { + let content = data.rows; + commit('SET_STSTEMCONFIGlIST', content) + //系统名称 + let loginSystemName = ''; + //浏览器页签名称 + let browserName = ''; + //技术支持 + let technicalSupport = ''; + //大数据指挥舱 + let bigscreenUrl = ''; + //界面logo + let globalLogo = ''; + //系统大屏logo + let screenLogo = ''; + + content.forEach((v, i) => { + if (v.configKey == 'system.login.name') { + loginSystemName = v.configValue + } else if (v.configKey == 'system.browser.name') { + browserName = v.configValue + } else if (v.configKey == 'system.company.name') { + technicalSupport = v.configValue + } else if (v.configKey == 'system.bigscreen.url') { + bigscreenUrl = v.configValue + } else if (v.configKey == 'system.logo.pic') { + globalLogo = v.configValue + } else if (v.configKey == 'system.logo5.pic') { + screenLogo = v.configValue + } + }) + + commit('SET_LOGINSYSTEMNAME', loginSystemName) + commit('SET_BORWSERNAME', browserName) + commit('SET_TECHNICALSUPPORT', technicalSupport) + commit('SET_BIGSCREENURL', bigscreenUrl) + commit('SET_GLOBALLOGO', globalLogo) + commit('SET_SCREENLOGO', screenLogo) + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + // 退出系统 + LogOut ({ commit, state }) { + return new Promise((resolve, reject) => { + logout(state.token).then(() => { + commit('SET_TOKEN', '') + commit('SET_ROLES', []) + commit('SET_PERMISSIONS', []) + removeToken() + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + + // 前端 登出 + FedLogOut ({ commit }) { + return new Promise(resolve => { + commit('SET_TOKEN', '') + commit('SET_ROLES', []) + commit('SET_PERMISSIONS', []) + removeToken() + resolve() + }) + }, + + // 更新用户信息 + + + // 春耕App用户登录 + ChungengLogin ({ commit }, userInfo) { + const code = userInfo.code; + return new Promise((resolve, reject) => { + chungengUserLogin(code).then(res => { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve(res.data) + }).catch(error => { + reject(error) + }) + }) + }, + } +} + +export default user diff --git a/src/style/element-reset.scss b/src/style/element-reset.scss index ac1e954..1d2278a 100644 --- a/src/style/element-reset.scss +++ b/src/style/element-reset.scss @@ -9,11 +9,11 @@ $border_color: rgba(30, 56, 92, 1); display: block; .el-input__inner { - height: 60px; - line-height: 60px; - background: $bg_color; - border: 1px solid $border_color; - color: #FFFFFF; + // height: 60px; + // line-height: 60px; + // background: $bg_color; + // border: 1px solid $border_color; + // color: #FFFFFF; } .el-input__inner::-webkit-input-placeholder { @@ -84,11 +84,11 @@ $border_color: rgba(30, 56, 92, 1); } .el-input__inner { - width: 100% !important; - color: #DFF2FF; - border: 0; - border-radius: 0; - background: $bg_color; + // width: 100% !important; + // color: #DFF2FF; + // border: 0; + // border-radius: 0; + // background: $bg_color; } .el-range-input { diff --git a/src/utils/auth.js b/src/utils/auth.js index 77957f5..ce93fc8 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -2,7 +2,7 @@ const TokenKey = 'Admin-Token'; // 获取token export function getToken () { - return 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjNlMjYwNzA2LTQzZWEtNGJlMS1hZDBiLTQ1YTIzMzk1MmNiOSJ9._B3v74EZpYO8WspNmKtQU1t7AoxrFdRWuhUNojKDrk5gTakfdfS8rcD5USwwvRwDgRaR1DvmP6E2fhspkB-8kg'; // 将token保存在本地 + return localStorage.getItem(TokenKey); } // 保存token export function setToken (token) { diff --git a/src/utils/jsencrypt.js b/src/utils/jsencrypt.js new file mode 100644 index 0000000..3ddc6fa --- /dev/null +++ b/src/utils/jsencrypt.js @@ -0,0 +1,30 @@ +import JSEncrypt from 'jsencrypt/bin/jsencrypt.min.js' + +// 密钥对生成 http://web.chacuo.net/netrsakeypair + +const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' + + 'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==' + +const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' + + '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' + + 'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' + + 'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' + + 'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' + + 'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' + + 'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' + + 'UP8iWi1Qw0Y=' + +// 加密 +export function encrypt (txt) { + const encryptor = new JSEncrypt() + encryptor.setPublicKey(publicKey) // 设置公钥 + return encryptor.encrypt(txt) // 对数据进行加密 +} + +// 解密 +export function decrypt (txt) { + const encryptor = new JSEncrypt() + encryptor.setPrivateKey(privateKey) // 设置私钥 + return encryptor.decrypt(txt) // 对数据进行解密 +} + diff --git a/src/views/login/bk.png b/src/views/login/bk.png new file mode 100644 index 0000000..3ca2c21 Binary files /dev/null and b/src/views/login/bk.png differ diff --git a/src/views/login/index.html b/src/views/login/index.html new file mode 100644 index 0000000..bac9aa1 --- /dev/null +++ b/src/views/login/index.html @@ -0,0 +1,50 @@ +
Copyright @ 2022 中农融信 (北京)科技股份有限公司 京ICP备06068185号-8
+