Commit cc8adcc1 authored by 毛线's avatar 毛线

退出游戏逻辑优化

parent cfa4a516
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import screenfull from 'screenfull' import screenfull from 'screenfull'
import { mapState } from 'vuex' import { mapState, mapMutations, } from 'vuex'
import Confirm from '@/components/dialog/confirm' import Confirm from '@/components/dialog/confirm'
import CenterBox from './components/center-box' import CenterBox from './components/center-box'
import { redirectBDUrl } from '@/utils/tool' import { redirectBDUrl } from '@/utils/tool'
...@@ -96,12 +96,16 @@ export default { ...@@ -96,12 +96,16 @@ export default {
'device', 'device',
'hideHeader', 'hideHeader',
'device', 'device',
'homeRedirectUrl',
]), ]),
}, },
created() { created() {
this.initTime() this.initTime()
}, },
methods: { methods: {
...mapMutations([
'SetHomeRedirectUrl',
]),
initTime() { initTime() {
this.time = new Date() this.time = new Date()
setTimeout(() => { setTimeout(() => {
...@@ -144,14 +148,16 @@ export default { ...@@ -144,14 +148,16 @@ export default {
network() { network() {
return { return {
quitAccount: () => { quitAccount: () => {
const { redirectUrl } = this.$route.query
console.log('退出登录接口') console.log('退出登录接口')
const homeRedirectUrl = this.homeRedirectUrl
this.$request({ this.$request({
url: '/api/player/logout', url: '/api/player/logout',
method: 'post', method: 'post',
}).then(() => { }).then(() => {
if (redirectUrl) { console.log('homeRedirectUrl', this.homeRedirectUrl)
redirectBDUrl(this.$route.query.redirectUrl) if (this.homeRedirectUrl) {
this.SetHomeRedirectUrl('') // 清空回调缓存
redirectBDUrl(homeRedirectUrl)
} else { } else {
this.$router.replace({ path: '/login' }) this.$router.replace({ path: '/login' })
} }
......
...@@ -22,6 +22,7 @@ export default { ...@@ -22,6 +22,7 @@ export default {
...mapMutations([ ...mapMutations([
'SetImToken', 'SetImToken',
'SetShowSlot', 'SetShowSlot',
'SetHomeRedirectUrl',
]), ]),
network() { network() {
return { return {
...@@ -36,12 +37,12 @@ export default { ...@@ -36,12 +37,12 @@ export default {
}).then(({ data }) => { }).then(({ data }) => {
console.log('登录成功') console.log('登录成功')
const { imToken, redirectUrl, token } = data const { imToken, redirectUrl, token } = data
const query = {
redirectUrl,
}
setUserData({ token, openImToken: imToken }) setUserData({ token, openImToken: imToken })
this.SetImToken(imToken) this.SetImToken(imToken)
this.$router.replace({ path: '/loading', query, }) this.SetHomeRedirectUrl(redirectUrl)
console.log('设置redirectUrl', redirectUrl)
this.$router.replace({ path: '/loading', })
}) })
}, },
} }
......
...@@ -128,7 +128,7 @@ export default { ...@@ -128,7 +128,7 @@ export default {
const token = getToken() const token = getToken()
if (token) { if (token) {
this.GetBaseInfo().then(() => { this.GetBaseInfo().then(() => {
const { redirectUrl, deviceId } = this.$route.query const { redirectUrl, deviceId, homeRedirectUrl } = this.$route.query
if (deviceId) { if (deviceId) {
const query = { const query = {
redirectUrl, redirectUrl,
...@@ -137,7 +137,7 @@ export default { ...@@ -137,7 +137,7 @@ export default {
this.$router.replace({ path: `/game`, query }) this.$router.replace({ path: `/game`, query })
} else { } else {
const query = { const query = {
redirectUrl, homeRedirectUrl,
} }
this.$router.replace({ path: `/device`, query }) this.$router.replace({ path: `/device`, query })
} }
......
...@@ -54,6 +54,7 @@ export const state = () => ({ ...@@ -54,6 +54,7 @@ export const state = () => ({
}, // 阿里云配置 }, // 阿里云配置
jackpot: [], // jackpot信息 jackpot: [], // jackpot信息
showSlot: false, // 是否显示品牌logo等内容 showSlot: false, // 是否显示品牌logo等内容
homeRedirectUrl: '', // 大厅退出返回url
}) })
export const getters = { export const getters = {
...@@ -204,6 +205,9 @@ export const mutations = { ...@@ -204,6 +205,9 @@ export const mutations = {
SetShowSlot(state, data) { SetShowSlot(state, data) {
state.showSlot = data state.showSlot = data
}, },
SetHomeRedirectUrl(state, data) {
state.homeRedirectUrl = data
},
} }
export const actions = { export const actions = {
......
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