Index.vue 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="home">
  3. </div>
  4. </template>
  5. <script>
  6. // @ is an alias to /src
  7. import Trend from '@/components/Trend'
  8. import { WindowsFill } from '@ant-design/icons/lib/dist';
  9. import { mapActions } from 'vuex'
  10. import Vue from 'vue'
  11. import { ACCESS_TOKEN, ENCRYPTED_STRING, USER_INFO } from '@/store/mutation-types'
  12. import store from '@/store/'
  13. import { timeFix } from '@/utils/util'
  14. export default {
  15. name: 'Index',
  16. components: {
  17. Trend,
  18. },
  19. data () {
  20. return {
  21. }
  22. },
  23. created(){
  24. this.getUUID();
  25. },
  26. methods: {
  27. ...mapActions(['uuidLogin']),
  28. getUUID(){
  29. var url = window.location.href ;
  30. // var dz_url = url.split('#')[0]; //获取#/之前的字符串
  31. var cs = url.split('?')[1]; //获取?之后的参数字符串
  32. if(cs==undefined){
  33. window.location.href = window._CONFIG['ssoURL']+'/oauth/authorize?client_id=OAManager&response_type=code&redirect_url=https://oa.worldskillsmuseum.cn/#/redirect/login'
  34. }
  35. var cs_arr = cs.split('&'); //参数字符串分割为数组
  36. var cs={};
  37. for(var i=0;i<cs_arr.length;i++){ //遍历数组,拿到json对象
  38. cs[cs_arr[i].split('=')[0]] = cs_arr[i].split('=')[1]
  39. }
  40. this.uuid = cs.uuid;
  41. this.redirect = cs.redirect;
  42. if(this.uuid){
  43. this.uuidLogin({'uuid':this.uuid}).then(res=>{
  44. if (res.success) {
  45. console.log('用户信息', res)
  46. let multi_depart = res.result.multi_depart
  47. // 0:无部门 1:一个部门 2:多个部门
  48. if (multi_depart == 0) {
  49. this.$notification.warn({
  50. message: '提示',
  51. description: `您尚未归属公司,请确认OA账号信息`,
  52. duration: 3
  53. })
  54. } else {
  55. console.log('登录')
  56. const userInfo = res.result.userInfo
  57. Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
  58. store.commit('SET_INFO', userInfo)
  59. if(this.redirect){
  60. this.$router.push({ name: this.redirect })
  61. }else{
  62. this.$router.push({ name: 'dashboard' })
  63. }
  64. }
  65. }
  66. }).catch(err=>{
  67. this.$notification['error']({
  68. message: '认证失败',
  69. description: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
  70. duration: 4
  71. })
  72. })
  73. }else{
  74. window.location.href = window._CONFIG['ssoURL']+'/oauth/authorize?client_id=OAManager&response_type=code&redirect_url=https://oa.worldskillsmuseum.cn/#/redirect/login'
  75. }
  76. },
  77. }
  78. }
  79. </script>
  80. <style scoped>
  81. .home {
  82. width: 900px;
  83. margin: 0 auto;
  84. padding: 25px 0;
  85. }
  86. .home > .banner {
  87. text-align: center;
  88. padding: 25px 0;
  89. margin: 25px 0;
  90. }
  91. </style>