Commit cc8adcc1 authored by 毛线's avatar 毛线

退出游戏逻辑优化

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