UNPKG

press-plus

Version:
73 lines (59 loc) 1.38 kB
const APP_ID_MAP = { GAME_LIFE: 'wx94057b049312ffec', GUANDAN: 'wx2f60a7b40f3828a9', }; const MATCH_ID_MAP = { INNER: 520300, RELEASE: 520400, }; export function launchGuandanGame({ schemeLink, seriesId, gameId, matchId = MATCH_ID_MAP.RELEASE, name = '腾讯掼蛋', logo = '-', }: { schemeLink: string; seriesId: string | number; gameId: string | number; matchId?: string | number; name?: string; logo?: string; }) { const isWebview = navigator.userAgent.toLowerCase().includes('miniprogram'); if (isWebview) { const outerPath = generatePath({ seriesId, gameId, matchId, name, logo, }); console.info('[outerPath]', outerPath); if (typeof wx !== 'undefined' && (wx as any).miniProgram?.navigateTo) { (wx as any).miniProgram.navigateTo({ url: outerPath, }); } return; } window.location.href = schemeLink; } export function generatePath({ seriesId, gameId, matchId, name, logo, }: { seriesId: string | number; gameId: string | number; matchId?: string | number; name?: string; logo?: string; }) { const basePath = '/pages/jumppage/jumppage'; const path = encodeURIComponent(`?seriesid=${seriesId}&gameid=${gameId}&matchid=${matchId}`); return `${basePath}?appid=${APP_ID_MAP.GUANDAN}&name=${name}&path=${path}&logo=${logo}`; }