|
@@ -0,0 +1,50 @@
|
|
|
+<template>
|
|
|
+ <div v-loading.fullscreen.lock="loading"></div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {setTitle} from "@/router";
|
|
|
+import {config} from "@/helper";
|
|
|
+
|
|
|
+export default {
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ loading: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ const params = new URLSearchParams(window.location.search)
|
|
|
+ const state = params.get('state')
|
|
|
+ const code = params.get('code')
|
|
|
+ if (state === 'WWLogin' && code) {
|
|
|
+ this.doLogin({code})
|
|
|
+ } else {
|
|
|
+ this.goHome()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ goHome () {
|
|
|
+ this.$router.replace(config('INDEX_URL'))
|
|
|
+ },
|
|
|
+ doLogin ({ code }) {
|
|
|
+ this.$request("/login").data({ wxCode: code }).success((r) => {
|
|
|
+ this.loading = false
|
|
|
+ // 设置登录
|
|
|
+ this.$store.dispatch('login', r.data);
|
|
|
+ // 重新初始化系统
|
|
|
+ this.$request("/load").success((r) => {
|
|
|
+ this.$store.dispatch('initialize', r.data)
|
|
|
+ setTitle(this.$route)
|
|
|
+ }).error(() => {
|
|
|
+ this.$Notice.error({title: '系统初始化发送异常', desc: r.info, duration: 5})
|
|
|
+ this.$store.dispatch('logout');
|
|
|
+ }).get();
|
|
|
+ this.goHome()
|
|
|
+ }).error(() => {
|
|
|
+ this.$Message.error({content: '企业微信登录异常'})
|
|
|
+ this.goHome()
|
|
|
+ }).post()
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|