|
@@ -0,0 +1,130 @@
|
|
|
+<template>
|
|
|
+ <div class="home">
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ // @ is an alias to /src
|
|
|
+
|
|
|
+ import Trend from '@/components/Trend'
|
|
|
+ import { axios } from '@/utils/request'
|
|
|
+ // import axios from 'axios'
|
|
|
+ import { postAction } from '@/api/manage'
|
|
|
+
|
|
|
+ import { mapActions } from 'vuex'
|
|
|
+ import Vue from 'vue'
|
|
|
+ import { ACCESS_TOKEN, ENCRYPTED_STRING, USER_INFO } from '@/store/mutation-types'
|
|
|
+ import store from '@/store/'
|
|
|
+ import { timeFix } from '@/utils/util'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: 'Redirect',
|
|
|
+ components: {
|
|
|
+ Trend,
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ code: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created(){
|
|
|
+ this.getCode();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions(['redirectLogin']),
|
|
|
+ getCode() {
|
|
|
+
|
|
|
+ var url = window.location.href ; //获取当前url
|
|
|
+
|
|
|
+ var dz_url = url.split('#')[0]; //获取#/之前的字符串
|
|
|
+
|
|
|
+ var cs = dz_url.split('?')[1]; //获取?之后的参数字符串
|
|
|
+
|
|
|
+ var cs_arr = cs.split('&'); //参数字符串分割为数组
|
|
|
+
|
|
|
+ var cs={};
|
|
|
+
|
|
|
+ for(var i=0;i<cs_arr.length;i++){ //遍历数组,拿到json对象
|
|
|
+
|
|
|
+ cs[cs_arr[i].split('=')[0]] = cs_arr[i].split('=')[1]
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.code = cs.code;
|
|
|
+ this.redirectLogin({'code':this.code}).then(res=>{
|
|
|
+
|
|
|
+ this.departConfirm(res)
|
|
|
+ }).catch(err=>{
|
|
|
+ this.requestFailed(err)
|
|
|
+ })
|
|
|
+ // var params = {
|
|
|
+ // "client_id":"OAManager",
|
|
|
+ // "client_secret":"Password123",
|
|
|
+ // "grant_type":"authorization_code",
|
|
|
+ // "code":this.code,
|
|
|
+ // "redirect_uri":"http://localhost:8083/"
|
|
|
+ // }
|
|
|
+ // axios.post("/sso/oauth/token", params)
|
|
|
+ },
|
|
|
+ requestFailed (err) {
|
|
|
+ this.$notification['error']({
|
|
|
+ message: '登录失败',
|
|
|
+ description: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
|
|
|
+ duration: 4
|
|
|
+ })
|
|
|
+ this.loginBtn = false
|
|
|
+ },
|
|
|
+ departConfirm (res) {
|
|
|
+ if (res.success) {
|
|
|
+ console.log('用户信息', res)
|
|
|
+ let multi_depart = res.result.multi_depart
|
|
|
+ // 0:无部门 1:一个部门 2:多个部门
|
|
|
+ if (multi_depart == 0) {
|
|
|
+ this.loginSuccess()
|
|
|
+ this.$notification.warn({
|
|
|
+ message: '提示',
|
|
|
+ // description: `您尚未归属部门,请确认账号信息`,
|
|
|
+ description: `您尚未归属公司,请确认账号信息`,
|
|
|
+ duration: 3
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('登录')
|
|
|
+ const userInfo = res.result.userInfo
|
|
|
+ Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
|
|
|
+ store.commit('SET_INFO', userInfo)
|
|
|
+ this.loginSuccess()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.requestFailed(res)
|
|
|
+ setTimeout(()=>{
|
|
|
+ window.location.href="http://172.18.91.12:8888/sso"
|
|
|
+ },3000)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ loginSuccess () {
|
|
|
+ this.$router.push({ name: 'dashboard' })
|
|
|
+ this.$notification.success({
|
|
|
+ message: '欢迎',
|
|
|
+ description: `${timeFix()},欢迎回来`
|
|
|
+ })
|
|
|
+ // this.$store.dispatch('delVisitedViews',this.$route)
|
|
|
+ // this.$router.go(-1)
|
|
|
+ // this.$store.state.tagsView.visitedViews.splice(this.$store.state.tagsView.visitedViews.findIndex(item => item.path === this.$route.path), 1)
|
|
|
+ // this.$router.push(this.$store.state.tagsView.visitedViews[this.$store.state.tagsView.visitedViews.length-1].path)
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .home {
|
|
|
+ width: 900px;
|
|
|
+ margin: 0 auto;
|
|
|
+ padding: 25px 0;
|
|
|
+ }
|
|
|
+ .home > .banner {
|
|
|
+ text-align: center;
|
|
|
+ padding: 25px 0;
|
|
|
+ margin: 25px 0;
|
|
|
+ }
|
|
|
+</style>
|