UNPKG

press-next

Version:
47 lines (36 loc) 1.16 kB
import { getGpScheme, DEFAULT_OPEN_LINK } from './scheme-base'; function encodeQuery(obj) { const queryString = Object.keys(obj) .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`) .join('&'); // 把对象转换成 a=1&b=2&c=3&d=4 的字符串格式 const res = encodeURIComponent(queryString); return res; } export function getOpenLink(getUrlPara) { const { href } = window.location; const isChildPage = href.includes('views/match/single-match-detail'); const isMatchListPage = href.includes('views/match-list/match-list'); const childId = getUrlPara('childId'); const parentId = getUrlPara('parentId'); const siteId = getUrlPara('siteId'); let openLink = DEFAULT_OPEN_LINK; if (isChildPage && siteId && childId && parentId) { openLink = getGpScheme({ query: encodeQuery({ childId, siteId, parentId, }), path: 'views/match/single-match-detail', }); } if (isMatchListPage && siteId) { openLink = getGpScheme({ query: encodeQuery({ siteId, }), path: 'views/match-list/match-list', }); } return openLink; }