Commit 726b2fc7 authored by 毛线's avatar 毛线

三方跳转im登录问题处理

parent bd770735
import { Message } from 'element-ui' import { Message } from 'element-ui'
import { getToken } from '@/utils/auth' // 验权 import { getToken } from '@/utils/auth' // 验权
const whiteList = ['/loading', '/loading/', '/login', '/login/', '/test', '/index/test', '/goToGame/'] // 不重定向白名单 const whiteList = ['/loading', '/loading/', '/login', '/login/', '/test', '/index/test', '/goToGame/', '/goToGame'] // 不重定向白名单
export default ({ app, redirect, route }) => { export default ({ app, redirect, route }) => {
const { fullPath, path } = route const { fullPath, path } = route
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
</template> </template>
<script> <script>
import { mapMutations } from 'vuex'
import { setToken, setImToken, setUserData, } from '@/utils/auth' // 验权 import { setToken, setImToken, setUserData, } from '@/utils/auth' // 验权
export default { export default {
data() { data() {
...@@ -16,6 +17,9 @@ export default { ...@@ -16,6 +17,9 @@ export default {
} }
}, },
methods: { methods: {
...mapMutations([
'SetImToken',
]),
network() { network() {
return { return {
getInfo: (ticket) => { getInfo: (ticket) => {
...@@ -29,6 +33,7 @@ export default { ...@@ -29,6 +33,7 @@ export default {
}).then(({ data }) => { }).then(({ data }) => {
const { deviceId, imToken, redirectUrl, token } = data const { deviceId, imToken, redirectUrl, token } = data
setUserData({ token, openImToken: imToken }) setUserData({ token, openImToken: imToken })
this.SetImToken(imToken)
const query = { const query = {
redirectUrl, redirectUrl,
deviceId, deviceId,
...@@ -44,7 +49,9 @@ export default { ...@@ -44,7 +49,9 @@ export default {
method: 'get', method: 'get',
}).then(({ data }) => { }).then(({ data }) => {
const { deviceId, redirectUrl } = query const { deviceId, redirectUrl } = query
console.log('判断是否在其他设备')
if (!data) { // 没有在其他设备 if (!data) { // 没有在其他设备
console.log('没有在其他设备')
// 加入设备 // 加入设备
this.$request({ this.$request({
url: '/api/gaming', url: '/api/gaming',
...@@ -59,7 +66,9 @@ export default { ...@@ -59,7 +66,9 @@ export default {
} }
const { id } = data const { id } = data
if (id) { if (id) {
console.log('进入设备')
if (this.$route.name !== 'index-game') { if (this.$route.name !== 'index-game') {
console.log('重定向')
this.$router.replace(`/game?id=${id}&redirectUrl=${redirectUrl}`) this.$router.replace(`/game?id=${id}&redirectUrl=${redirectUrl}`)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment