1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <template>
- <div>
- </div>
- </template>
- <script>
- import { setToken,getToken } from '@/utils/auth'
- import { ehrLogin } from '@/api/sso/ssoLogin';
- export default {
- data () {
- return {
- }
- },
- created() {
- },
- mounted() {
- this.$nextTick(() => {
- this.jump()
- })
- },
- methods: {
- jump() {
- var code = this.GetQueryString('code')
- var jumpPath = this.GetQueryString('path')
- let str = jumpPath + window.location.search;
- if(getToken()){
- this.$router.push({ path: str});
- }else{
- ehrLogin(code).then(res => {
- if (res.code === 200) {
- let token = res.token
- setToken(token)
- this.$store.commit('SET_TOKEN', token)
- this.$store.dispatch("GetInfo").then(() => {})
- console.log("str", str)
- this.$store.dispatch("GenerateRoutes").then(
- this.$router.push({ path: str}).catch(()=>{})
- )
- }
- })
- }
- },
- GetQueryString(name) {
- var reg = new RegExp( "(^|&)" + name + "=([^&]*)(&|$)" );
- var r = window.location.search.substr(1).match(reg);
- if (r!= null ) return unescape(r[2]); return null ;
- }
- }
- }
- </script>
|