|
@@ -51,10 +51,13 @@
|
|
|
import * as LoginApi from '@/api/login'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
import { useAppStore } from '@/store/modules/app'
|
|
|
+import * as authUtil from '@/utils/auth'
|
|
|
defineOptions({ name: 'OALogin' })
|
|
|
const appStore = useAppStore()
|
|
|
const oaLoginTitle = ref(appStore.title)
|
|
|
const dingCodeLogin = ref()
|
|
|
+const loading = ref()
|
|
|
+const loginLoading = ref(false)
|
|
|
const redirect = ref<string>('')
|
|
|
const { currentRoute, push } = useRouter()
|
|
|
import { usePermissionStore } from '@/store/modules/permission'
|
|
@@ -68,13 +71,42 @@ const init = async (type) => {
|
|
|
dingCodeLogin.value = res
|
|
|
}
|
|
|
}
|
|
|
-const handleMessage = (event) => {
|
|
|
- var origin = event.origin
|
|
|
- let loginBox: any = document.querySelector('.loginBox')
|
|
|
- if (loginBox) {
|
|
|
- loginBox.style = 'width:100%;height:100%;top:0;right:0;margin:0'
|
|
|
- let iframe: any = document.querySelector('#iframe')
|
|
|
- iframe.style = 'height:100%'
|
|
|
+const handleMessage = async (event) => {
|
|
|
+ try {
|
|
|
+ var origin = event.origin
|
|
|
+ const res = await LoginApi.socialLogin({
|
|
|
+ type: 20,
|
|
|
+ code: event.data.code,
|
|
|
+ state: event.data.state
|
|
|
+ })
|
|
|
+ if (!res) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // socialLoading.value = ElLoading.service({
|
|
|
+ // lock: true,
|
|
|
+ // text: '正在加载系统中...',
|
|
|
+ // background: 'rgba(0, 0, 0, 0.7)'
|
|
|
+ // })
|
|
|
+ authUtil.setToken(res)
|
|
|
+ if (!redirect.value) {
|
|
|
+ redirect.value = '/'
|
|
|
+ }
|
|
|
+ // 判断是否为SSO登录
|
|
|
+ if (redirect.value.indexOf('sso') !== -1) {
|
|
|
+ window.location.href = window.location.href.replace('/login?redirect=', '')
|
|
|
+ } else {
|
|
|
+ // push({ path: redirect.value || permissionStore.addRouters[0].path })
|
|
|
+ window.parent.pushWin() //触发iframe父页面的方法
|
|
|
+ }
|
|
|
+ // let loginBox: any = document.querySelector('.qr_login')
|
|
|
+ // if (loginBox) {
|
|
|
+ // loginBox.style = 'width:100%;height:100%;top:0;right:0;margin:0'
|
|
|
+ // let iframe: any = document.querySelector('#iframe')
|
|
|
+ // iframe.style = 'height:100%'
|
|
|
+ // }
|
|
|
+ } finally {
|
|
|
+ loginLoading.value = false
|
|
|
+ loading.value.close()
|
|
|
}
|
|
|
}
|
|
|
onMounted(() => {
|
|
@@ -201,7 +233,7 @@ onMounted(() => {
|
|
|
&.qr_login {
|
|
|
flex: 1;
|
|
|
> .qr_box {
|
|
|
- height: 200px;
|
|
|
+ height: 300px;
|
|
|
iframe {
|
|
|
height: 100%;
|
|
|
}
|