Browse Source

登录配置

xieqy 3 năm trước cách đây
mục cha
commit
87eda818c4

+ 14 - 7
src/api/user.ts

@@ -1,13 +1,20 @@
 import request from '@/utils/request'
 
-export function login(data) {
+// export function login(data) {
+//   return request({
+//     url: '/auth/oauth/login',
+//     method: 'post',
+//     data,
+//     headers: {
+//       'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
+//     }
+//   })
+// }
+export function login(params) {
   return request({
-    url: '/auth/oauth/login',
-    method: 'post',
-    data,
-    headers: {
-      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
-    }
+    url: `/auth/token/third/loginByEpc`,
+    method: 'get',
+    params
   })
 }
 

+ 1 - 1
src/settings.js

@@ -48,5 +48,5 @@ module.exports = {
   settings: true,
 
   // 系统名称
-  sysTitle: '城市排水系统动态监测评估系统'
+  sysTitle: '三峡发展智慧EPC综合决策分析中心'
 }

+ 64 - 60
src/store/modules/routeSetting.ts

@@ -110,67 +110,71 @@ const actions = {
   getRouter({ commit, dispatch }, data) {
     return new Promise((resolve, reject) => {
       const userId = sessionStorage.getItem('userId') || userx.state.userId
-      getUserMenu(userId)
-        .then((res) => {
-          if (res.result.length !== 0) {
-            const data = res.result.filter((item) => !disabledMenus.includes(item.type || ''))
-            const result = {}
-            for (const item of data) {
-              const obj = {}
-              obj[item.type] = packageRouter(item.childrens)
-              Object.assign(result, obj)
-            }
-            commit('SET_DYNAMICROUTES', result)
-            const exclude = ['map', 'dashboard', ...gisNames]
-            const autoLink = (type, arr) => {
-              if (!exclude.includes(type)) {
-                // return `${arr.childrens[0].path}/${arr.childrens[0].childrens[0].path}`
-                if (arr.childrens.length > 0 && arr.childrens[0].childrens.length > 0) {
-                  return `${arr.childrens[0].path}/${arr.childrens[0].childrens[0].path}`
-                } else {
-                  return ''
-                }
-              } else return ''
-            }
-            const menus = data.map((item) => {
-              return {
-                title: item.label,
-                name: item.type,
-                path: autoLink(item.type, item)
-              }
-            })
-            menus.some((item, i) => {if (item.name === 'prjSelection') menus.splice(i, 1)})
-            commit('SET_NAVMENUS', menus)
-            let routes = data.map((item) => item.childrens)
-            routes = routes.flat()
+      const addRouter = []
+      commit('SET_ROUTES', addRouter)
+      addRouter.unshift(groupPageRoutes)
+      resolve(addRouter)
+      // getUserMenu(userId)
+      //   .then((res) => {
+      //     if (res.result.length !== 0) {
+      //       const data = res.result.filter((item) => !disabledMenus.includes(item.type || ''))
+      //       const result = {}
+      //       for (const item of data) {
+      //         const obj = {}
+      //         obj[item.type] = packageRouter(item.childrens)
+      //         Object.assign(result, obj)
+      //       }
+      //       commit('SET_DYNAMICROUTES', result)
+      //       const exclude = ['map', 'dashboard', ...gisNames]
+      //       const autoLink = (type, arr) => {
+      //         if (!exclude.includes(type)) {
+      //           // return `${arr.childrens[0].path}/${arr.childrens[0].childrens[0].path}`
+      //           if (arr.childrens.length > 0 && arr.childrens[0].childrens.length > 0) {
+      //             return `${arr.childrens[0].path}/${arr.childrens[0].childrens[0].path}`
+      //           } else {
+      //             return ''
+      //           }
+      //         } else return ''
+      //       }
+      //       const menus = data.map((item) => {
+      //         return {
+      //           title: item.label,
+      //           name: item.type,
+      //           path: autoLink(item.type, item)
+      //         }
+      //       })
+      //       menus.some((item, i) => {if (item.name === 'prjSelection') menus.splice(i, 1)})
+      //       commit('SET_NAVMENUS', menus)
+      //       let routes = data.map((item) => item.childrens)
+      //       routes = routes.flat()
 
-            const addRouter = packageRouter(routes)
-            commit('SET_ROUTES', addRouter)
-            if (data.some((item) => item.type === 'groupPage')) addRouter.unshift(groupPageRoutes)
-            if (data.some((item) => item.type === 'prjSelection')) addRouter.unshift(prjSelectionRoutes)
-            if (data.some((item) => item.type === 'map' || gisNames.includes(item.type))) addRouter.unshift(mapRoute)
-            if (data.some((item) => item.type === 'dashboard')) addRouter.unshift(dashboardRoute)
-            else if (!data.some((item) => item.type === 'dashboard') && data.some((item) => item.type === 'map')) {
-              const redirectParent = state.addRoutes[0]
-              noDashboardRedict.redirect =
-                redirectParent.path !== '/map' ? `${redirectParent.path}/${redirectParent.children[0].path}` : '/map'
-              addRouter.unshift(noDashboardRedict)
-              const firstKey = Object.keys(state.dynamicRoutes)
-              if (redirectParent.path === '/map')
-                commit(
-                  'SET_ROUTES',
-                  firstKey[0] === 'sysSetting' ? state.dynamicRoutes[firstKey[1]] : state.dynamicRoutes[firstKey[0]]
-                )
-              else commit('SET_ROUTES', state.dynamicRoutes[data[0].type])
-            }
-            resolve(addRouter)
-          } else {
-            reject(res)
-          }
-        })
-        .catch((error) => {
-          reject(error)
-        })
+      //       const addRouter = packageRouter(routes)
+      //       commit('SET_ROUTES', addRouter)
+      //       if (data.some((item) => item.type === 'groupPage')) addRouter.unshift(groupPageRoutes)
+      //       if (data.some((item) => item.type === 'prjSelection')) addRouter.unshift(prjSelectionRoutes)
+      //       if (data.some((item) => item.type === 'map' || gisNames.includes(item.type))) addRouter.unshift(mapRoute)
+      //       if (data.some((item) => item.type === 'dashboard')) addRouter.unshift(dashboardRoute)
+      //       else if (!data.some((item) => item.type === 'dashboard') && data.some((item) => item.type === 'map')) {
+      //         const redirectParent = state.addRoutes[0]
+      //         noDashboardRedict.redirect =
+      //           redirectParent.path !== '/map' ? `${redirectParent.path}/${redirectParent.children[0].path}` : '/map'
+      //         addRouter.unshift(noDashboardRedict)
+      //         const firstKey = Object.keys(state.dynamicRoutes)
+      //         if (redirectParent.path === '/map')
+      //           commit(
+      //             'SET_ROUTES',
+      //             firstKey[0] === 'sysSetting' ? state.dynamicRoutes[firstKey[1]] : state.dynamicRoutes[firstKey[0]]
+      //           )
+      //         else commit('SET_ROUTES', state.dynamicRoutes[data[0].type])
+      //       }
+      //       resolve(addRouter)
+      //     } else {
+      //       reject(res)
+      //     }
+      //   })
+      //   .catch((error) => {
+      //     reject(error)
+      //   })
     })
   },
   // 退出清空

+ 3 - 2
src/store/modules/user.ts

@@ -55,7 +55,8 @@ const actions = {
     const { username, password } = userInfo
     // setSessionStorage('username', username)
     return new Promise((resolve, reject) => {
-      login({ username: username, password: sha1Hex(password) })
+      // login({ username: username, password: sha1Hex(password) })
+      login({ loginUser: 'zhgdlogin' })
         .then((response) => {
           // console.log('2222', response)
           // const data = {
@@ -63,7 +64,7 @@ const actions = {
           //   username: 'admin',
           //   realName: '超级管理员'
           // }
-          const { accessToken, username, avatar, realName, id, departmentId } = response.result
+          const { accessToken, username, avatar, realName, id, departmentId } = response.result.result.result
           // const { accessToken, username, avatar, realName } = data
           // setToken(accessToken)
           commit('SET_TOKEN', accessToken)

+ 2 - 1
src/utils/request.ts

@@ -29,7 +29,8 @@ declare module 'axios' {
 }
 
 // 创建axios实例
-export const IP = 'http://192.168.2.235:7081' // 开发2
+// export const IP = 'http://192.168.2.235:7081' // 开发2
+export const IP = 'https://yeepms.yeec.com.cn/gis-api' // 开发2
 
 // 暴露IP地址
 export const baseAddress = IP

+ 46 - 42
src/views/login/index.vue

@@ -20,7 +20,7 @@
           class="login-form middle"
           auto-complete="on"
           label-position="left"
-          style="position: relative;top: 200px; left: calc((100% - 320px)/2);top: 150px;"
+          style="position: relative; top: 200px; left: calc((100% - 320px) / 2); top: 150px"
         >
           <el-input
             ref="username"
@@ -201,48 +201,52 @@ export default class Login extends Vue {
           .then((res) => {
             const { id } = res.result
             // 判断是否首次登录或者重置过密码
-            userFirstLogin(id)
-              .then((res) => {
-                console.log(res)
-                // 先判断用户是否被禁用了 如果是申请的用户 还需要要判断是否同意申请了
-                const { auditstatus, enableFlag } = res.result
-                if (enableFlag === '0') {
-                  this.$message({
-                    message: '用户已被禁用,请先启用!',
-                    type: 'error'
-                  })
-                  this.loading = false
-                  sessionStorage.clear()
-                  return
-                }
-                if (auditstatus !== '2' && auditstatus !== null) {
-                  this.$message({
-                    message: auditstatus === 1 ? '账户还未审核通过!' : '账户审核未被通过!',
-                    type: 'error'
-                  })
-                  this.loading = false
-                  sessionStorage.clear()
-                  return
-                }
-                // 是首次登录 打开弹窗 修改密码
-                if (res.result.firstlog === '1' && this.loginForm.password === defaultPwd) {
-                  this.userId = id
-                  this.passwordDialog = true
-                  // 清除掉用户id 防止用户没有修改密码刷新进入页面
-                  sessionStorage.removeItem('userId')
-                  this.$store.state.user.userId = undefined
-                } else {
-                  this.loading = false
-                  setTimeout(() => {
-                    this.$router.push({ path: '/prjSelection' })
-                  }, 0)
-                }
-              })
-              .catch(() => {
-                sessionStorage.clear()
-                this.loading = false
-              })
+            // userFirstLogin(id)
+            //   .then((res) => {
+            //     console.log(res)
+            //     // 先判断用户是否被禁用了 如果是申请的用户 还需要要判断是否同意申请了
+            //     const { auditstatus, enableFlag } = res.result
+            //     if (enableFlag === '0') {
+            //       this.$message({
+            //         message: '用户已被禁用,请先启用!',
+            //         type: 'error'
+            //       })
+            //       this.loading = false
+            //       sessionStorage.clear()
+            //       return
+            //     }
+            //     if (auditstatus !== '2' && auditstatus !== null) {
+            //       this.$message({
+            //         message: auditstatus === 1 ? '账户还未审核通过!' : '账户审核未被通过!',
+            //         type: 'error'
+            //       })
+            //       this.loading = false
+            //       sessionStorage.clear()
+            //       return
+            //     }
+            //     // 是首次登录 打开弹窗 修改密码
+            //     if (res.result.firstlog === '1' && this.loginForm.password === defaultPwd) {
+            //       this.userId = id
+            //       this.passwordDialog = true
+            //       // 清除掉用户id 防止用户没有修改密码刷新进入页面
+            //       sessionStorage.removeItem('userId')
+            //       this.$store.state.user.userId = undefined
+            //     } else {
+            //       this.loading = false
+            //       setTimeout(() => {
+            //         this.$router.push({ path: '/groupPage' })
+            //       }, 0)
+            //     }
+            //   })
+            //   .catch(() => {
+            //     sessionStorage.clear()
+            //     this.loading = false
+            //   })
             // this.$router.push({ path: '/' })
+            this.loading = false
+            setTimeout(() => {
+              this.$router.push({ path: '/groupPage' })
+            }, 0)
           })
           .catch(() => {
             this.loading = false