Commit 02e6308a authored by xiaoye's avatar xiaoye

fix 通过url储存id

parent 0407444e
...@@ -231,7 +231,7 @@ ...@@ -231,7 +231,7 @@
</uni-pagination> </uni-pagination>
</transition> </transition>
<transition name = 'switch'> <transition name = 'switch'>
<PageTournament v-show = 'page.tournament'/> <PageTournament v-if = 'page.tournament'/>
</transition> </transition>
</view> </view>
</transition> </transition>
...@@ -247,10 +247,8 @@ ...@@ -247,10 +247,8 @@
import Mycard from '../script/mycard.ts'; import Mycard from '../script/mycard.ts';
import emitter from '../script/emitter.ts' import emitter from '../script/emitter.ts'
import { import {
selectTournament,
updateTournament , updateTournament ,
tournamentInfo, tournamentInfo,
tournamentExit,
tournamentReload tournamentReload
} from '../script/const.ts' } from '../script/const.ts'
import PageTournament from './tournament.vue'; import PageTournament from './tournament.vue';
...@@ -276,8 +274,8 @@ ...@@ -276,8 +274,8 @@
page.menu = false; page.menu = false;
await (new Promise(resolve => setTimeout(resolve, 500))); await (new Promise(resolve => setTimeout(resolve, 500)));
page.tournament = true; page.tournament = true;
emitter.emit(selectTournament, search.result.tournaments[v]); const url = window.location.href.split('/?');
tournament.init(search.result.tournaments[v]); window.location.replace(`${url[0]}/tournament/${search.result.tournaments[v].id}/?${url[1] ?? ''}`)
}, },
menu : async(): Promise<void> => { menu : async(): Promise<void> => {
page.tournament = false; page.tournament = false;
...@@ -530,20 +528,25 @@ ...@@ -530,20 +528,25 @@
} }
}); });
onBeforeMount(() => { onBeforeMount(() : void => {
Uniapp.chkScreen(size.get); Uniapp.chkScreen(size.get);
search.on();
document.addEventListener("click", page.show.clear); document.addEventListener("click", page.show.clear);
emitter.on(tournamentInfo, page.show.drawer); emitter.on(tournamentInfo, page.show.drawer);
emitter.on(tournamentExit, page.show.menu);
// @ts-ignore // @ts-ignore
emitter.on(tournamentReload, tournament.init); emitter.on(tournamentReload, tournament.init);
const url = window.location.href.match(/tournament\/(\d+)[^\/]*\/\?/);
if (url && !isNaN(parseInt(url[1]))) {
page.menu = false;
page.tournament = true;
} else {
search.on();
}
}); });
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener("click", page.show.clear); document.removeEventListener("click", page.show.clear);
emitter.off(tournamentInfo, page.show.drawer); emitter.off(tournamentInfo, page.show.drawer);
emitter.off(tournamentExit, page.show.menu);
// @ts-ignore // @ts-ignore
emitter.off(tournamentReload, tournament.init); emitter.off(tournamentReload, tournament.init);
}); });
......
This diff is collapsed.
...@@ -6,9 +6,7 @@ const tournamentExit = 'tournamentExit'; ...@@ -6,9 +6,7 @@ const tournamentExit = 'tournamentExit';
const tournamentReload = 'tournamentReload' const tournamentReload = 'tournamentReload'
export { export {
selectTournament,
updateTournament , updateTournament ,
tournamentInfo, tournamentInfo,
tournamentExit,
tournamentReload tournamentReload
}; };
\ No newline at end of file
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