Parcourir la source

新增gisbim跳转

李顺 il y a 3 ans
Parent
commit
90f55acaf3

+ 7 - 0
src/api/user.ts

@@ -24,6 +24,13 @@ export function mydeskLogin(params) {
     params
   })
 }
+export function gisLogin(params) {
+  return request({
+    url: '/auth/token/mygisLogin',
+    method: 'get',
+    params
+  })
+}
 
 export function logout(data) {
   return request({

+ 1 - 1
src/permission.ts

@@ -10,7 +10,7 @@ import { ERROR } from '@/router/routes'
 
 NProgress.configure({ showSpinner: true, height: 50 }) // NProgress配置
 
-const whiteList = ['/login'] // 无重定向白名单
+const whiteList = ['/login','/gislogin'] // 无重定向白名单
 
 router.beforeEach(async (to, from, next) => {
   // 开始进度条

+ 9 - 0
src/router/routes.ts

@@ -8,6 +8,15 @@ export const constantRoutes = [
     component: () => import('@/views/login/index.vue'),
     hidden: true
   },
+  {
+    path: '/gislogin',
+    meta: { title: '登录' },
+    type: 'sys',
+    label: '',
+    icon: 'el-icon-star-on',
+    component: () => import('@/views/gislogin/index.vue'),
+    hidden: true
+  },
   {
     path: '/404',
     hidden: true,

+ 45 - 1
src/store/modules/user.ts

@@ -1,4 +1,4 @@
-import { login, logout, loginwithcode,mydeskLogin } from '@/api/user'
+import { login, logout, loginwithcode,gisLogin,mydeskLogin } from '@/api/user'
 import { getToken, setToken, removeToken, setSessionStorage, removeSessionStorage } from '@/utils/auth'
 import { getRemoteFile } from '@/api/ftp'
 import { resetRouter } from '@/router'
@@ -93,6 +93,7 @@ const actions = {
         })
     })
   },
+  //mydesk登录
   mydeskLogin({ commit, state, dispatch }, userInfo) {
     const { token } = userInfo
     // setSessionStorage('username', username)
@@ -135,6 +136,49 @@ const actions = {
         })
     })
   },
+  //gisbim跳转
+  gisLogin({ commit, state, dispatch }, userInfo) {
+    const { token } = userInfo
+    // setSessionStorage('username', username)
+    return new Promise((resolve, reject) => {
+      gisLogin(userInfo)
+        .then((response) => {
+          // console.log('2222', response)
+          // const data = {
+          //   accessToken: 1111111,
+          //   username: 'admin',
+          //   realName: '超级管理员'
+          // }
+          const { accessToken, username, avatar, realName, id, departmentId } = response.result.result;
+          // const { accessToken, username, avatar, realName } = data
+          // setToken(accessToken)
+          commit('SET_TOKEN', accessToken)
+          commit('SET_USERNAME', username)
+          commit('SET_REALNAME', realName)
+          commit('SET_USERID', id)
+          commit('SET_DEPTS', departmentId)
+          setSessionStorage('token', accessToken)
+          setSessionStorage('username', username)
+          setSessionStorage('realName', realName)
+          setSessionStorage('userId', id)
+          setSessionStorage('departmentId', departmentId)
+          if (avatar) {
+            // getRemoteFile(avatar).then(res => {
+            //   if (res.status === 200) {
+            //     commit('SET_AVATAR', res.config.url)
+            //     setSessionStorage('avatar', res.config.url)
+            //   }
+            // })
+            commit('SET_AVATAR', getRemoteFile(avatar))
+            setSessionStorage('avatar', getRemoteFile(avatar))
+          }
+          resolve(response)
+        })
+        .catch((error) => {
+          reject(error)
+        })
+    })
+  },
   // set name
   // setName({ commit }, userInfo) {
   //   commit('SET_NAME', userInfo)

BIN
src/views/gislogin/images/background (3).png


BIN
src/views/gislogin/images/background (5).png


BIN
src/views/gislogin/images/background.png


BIN
src/views/gislogin/images/background3.png


BIN
src/views/gislogin/images/background_inpurt.png


BIN
src/views/gislogin/images/password.png


+ 221 - 0
src/views/gislogin/index.vue

@@ -0,0 +1,221 @@
+<template>
+  <div class="login-container">
+    <div class="company-name">
+      {{ title }}
+      <!-- <img src="./images/logo.png" /> -->
+    </div>
+  </div>
+</template>
+
+<script lang="ts">
+import { Vue, Component, Watch } from 'vue-property-decorator'
+import { userFirstLogin, getMsgCode } from '@/api/user'
+import { changePassword } from '@/api/base'
+import { regNewPassword } from '@/utils/reg'
+import { ElForm } from 'element-ui/types/form'
+const sha1Hex = require('sha1-hex')
+const defaultPwd = '000000'
+import { sysTitle } from '@/settings'
+
+import { getUserMenu } from '@/api/user'
+@Component
+export default class Login extends Vue {
+  name = 'Login'
+  url = '@/assets/images/login/logo.png'
+  title = sysTitle
+  loginForm = {
+    username: '',
+    password: '',
+    msg: ''
+  }
+  btnTitle = '发送验证码'
+  btnDisabled = false
+  time = 60
+  loginRules = {
+    username: [{ required: true, trigger: 'blur', message: '请输入账号' }],
+    password: [{ required: true, trigger: 'blur', message: '请输入密码' }],
+    msg: [{ required: true, trigger: 'blur', message: '请输入短信验证码' }]
+  }
+  loading = false
+  passwordType = 'password'
+  redirect = undefined
+  error = 1
+  // warning: true,
+  msg = ''
+  passwordDialog = false // 重置密码用弹窗显隐控制
+  changePwd = {
+    pass: '', // 重置密码用新密码
+    checkPass: '' // 重置密码用确认密码
+  }
+  pwdRules = {}
+  userId = ''
+  get sysTitle() {
+    return this.$store.state.settings.sysTitle
+  }
+  /**mydesk登录验证 */
+  beforeMount() {
+    const search = window.location.hash.split('?')[1]
+    if (search) {
+      //const codeIndex = search.indexOf('prjcode')
+      const tokenIndex = search.indexOf('token')
+      // if (codeIndex > -1 && tokenIndex > -1) {
+      //   const token = this.getSearchString('token', search)
+      //   const prjcode=this.getSearchString('prjcode', search)
+      //   this.loginWithTokenCheck(token,prjcode)
+      // }else{
+      //   this.$message.error('登录失败')
+      // }
+      if (tokenIndex > -1) {
+        const token = this.getSearchString('token', search)
+        this.loginWithTokenCheck(token, '')
+      } else {
+        this.$message.error('登录口令缺失')
+      }
+    }
+  }
+  mounted() {}
+  getSearchString(key, Url) {
+    var str = Url
+    //str = str.substring(1, str.length) // 获取URL中?之后的字符(去掉第一位的问号)
+    // 以&分隔字符串,获得类似name=xiaoli这样的元素数组
+    var arr = str.split('&')
+    var obj = new Object()
+    // 将每一个数组元素以=分隔并赋给obj对象
+    for (var i = 0; i < arr.length; i++) {
+      var tmp_arr = arr[i].split('=')
+      obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1])
+    }
+    return obj[key]
+  }
+  /**
+   * 根据mydesk token登录
+   * @param {*} token
+   */
+  loginWithTokenCheck(token, prjcode) {
+    this.$store.dispatch('user/gisLogin', { token: token }).then((result) => {
+      if (result.code === 1) {
+        setTimeout(() => {
+          //this.$router.push({ path: '/prjSelection' })
+          this.$router.push({ path: '/' })
+        }, 0)
+      }
+    }).catch(err=>{
+      console.error(err);
+    })
+  }
+  @Watch('$route', { immediate: true })
+  changeValue(route, oldvalue) {
+    this.redirect = route.query && route.query.redirect
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.login-container {
+  width: 100%;
+  height: 100%;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+  background: url('./images/background.png') no-repeat fixed center/100%;
+  background-size: cover;
+  .company-name {
+    position: absolute;
+    font-size: 40px;
+    color: white;
+    font-weight: 500;
+    letter-spacing: 4px;
+    width: 100%;
+    text-align: center;
+    top: calc((100% - 534px) / 2);
+    -webkit-box-reflect: below 1px -webkit-gradient(linear, 0 0, 0 50%, from(transparent), color-stop(0.2, transparent), to(rgba(3, 3, 3, 0.1)));
+  }
+  img {
+    user-select: none;
+    height: 100%;
+  }
+  .fill-container {
+    position: relative;
+    width: 926px;
+    height: 434px;
+    border-radius: 10px;
+    background-color: rgb(228, 242, 255);
+    left: calc((100% - 926px) / 2);
+    top: calc((100% - 334px) / 2);
+    .left {
+      position: relative;
+      float: left;
+      width: 538px;
+      overflow: hidden;
+    }
+    .right {
+      width: 388px;
+      width: 388px;
+      position: relative;
+      float: left;
+      .top {
+        font-size: 25px;
+        font-weight: 700;
+        color: rgb(45, 116, 231);
+        text-align: center;
+        width: 100%;
+        top: 50px;
+        position: relative;
+        float: left;
+        > span {
+          line-height: 30px;
+          &:nth-of-type(2) {
+            margin-top: 16px;
+          }
+        }
+      }
+      /deep/ input.el-input__inner {
+        padding-left: 40px !important;
+      }
+      /deep/ i.el-input__icon.el-icon-user,
+      /deep/ i.el-input__icon.el-icon-lock,
+      /deep/ i.el-input__icon.el-icon-tickets {
+        font-size: 20px;
+        color: #2d74e7;
+        top: -2.25px;
+        position: relative;
+      }
+      .middle {
+        width: 320px;
+        height: 106px;
+        margin-bottom: 80px;
+        > .form-input {
+          height: 36px;
+          line-height: 36px;
+          /deep/ input {
+            height: 36px;
+          }
+          &:nth-of-type(2) {
+            margin-top: 15px;
+          }
+          &:nth-of-type(3) {
+            margin-top: 15px;
+          }
+        }
+      }
+      .login-btn {
+        width: 320px;
+        height: 44px;
+        border-radius: 22px;
+        position: relative;
+        float: left;
+        left: calc((100% - 320px) / 2);
+        top: 120px;
+        overflow: hidden;
+        font-size: 16px;
+        background: #2d74e7;
+        transition: background 0.3s linear;
+        color: #ffffff;
+        &:hover {
+          background: #2467d3;
+        }
+      }
+    }
+  }
+}
+</style>