1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| <template>
| <div/>
| </template>
|
| <script>
| import request from '@/router/axios'
| import { getQueryString } from '@/util/util'
| import { mapGetters } from 'vuex'
|
| export default {
| name: 'Authredirect',
| computed: {
| ...mapGetters(['tagWel'])
| },
| created() {
| const url = window.location.href.replace('#/authredirect', '')
| const code = getQueryString(url, 'code')
| let state = getQueryString(url, 'state')
| const type = state.split('-')[1]
| state = state.split('-')[0]
| // 登录请求
| if (type === 'LOGIN') {
| window.opener.location.href = `${window.location.origin}/#/login?state=${state}&code=${code}&time=` + new Date().getTime()
| window.close()
| } else {
| this.bind(state, code)
| }
| },
| methods: {
| bind: function(state, code) {
| request({
| url: '/admin/social/bind',
| method: 'post',
| params: { state, code }
| }).then(() => {
| this.$alert('社交账号绑定成功', '成功', {
| confirmButtonText: '确定',
| callback: () => {
| window.close()
| }
| })
| })
| }
| }
| }
| </script>
|
| <style>
| </style>
|
|