Commit c909f4ea authored by Xuguangxing's avatar Xuguangxing

feat: 处理导航跳转链接的问题

parent ad6794a0
...@@ -160,7 +160,10 @@ export default { ...@@ -160,7 +160,10 @@ export default {
if (EASY_ENV_IS_NODE) return; if (EASY_ENV_IS_NODE) return;
const { coverImage, pageName, pageDescribe, shareCoverImage } = this.pageInfo; const { coverImage, pageName, pageDescribe, shareCoverImage } = this.pageInfo;
let link = `${window.location.origin}${window.location.pathname}?vccToken={token}&tenantId=${localStorage.get('tenantId') || ''}`; let link = `${window.location.origin}${window.location.pathname}?vccToken={token}&tenantId=${localStorage.get('tenantId') || ''}`;
if (this.getUrlParamsVal('navId') !== false && this.getUrlParamsVal('index') !== false) {
// 向分享URL中填充导航ID与位置索引
link += `&navId=${this.getUrlParamsVal("navId")}&index=${this.getUrlParamsVal('index')}`
}
this.link = link; this.link = link;
const defaultTitle = +localStorage.get('tenantId') === 560761 ? '羊小咩' : '活动页'; const defaultTitle = +localStorage.get('tenantId') === 560761 ? '羊小咩' : '活动页';
this.shareInfo = { this.shareInfo = {
...@@ -210,6 +213,15 @@ export default { ...@@ -210,6 +213,15 @@ export default {
this.$refs.crBackTop.$forceUpdate(); this.$refs.crBackTop.$forceUpdate();
}); });
} }
},
getUrlParamsVal(name) {
let query = window.location.search.substring(1);
let vars = query.split('&');
for (let i = 0; i < vars.length; i++) {
let pair = vars[i].split("=");
if (pair[0] == name) return pair[1];
}
return false;
} }
}, },
} }
......
...@@ -16,6 +16,8 @@ import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus'; ...@@ -16,6 +16,8 @@ import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import { home, shopcart, user } from '@/config/nav.config'; import { home, shopcart, user } from '@/config/nav.config';
import { isWxMp, isApp } from '@/service/utils.service'; import { isWxMp, isApp } from '@/service/utils.service';
import Bridge from '@qg/js-bridge';
import MpBridge from '@qg/citrus-ui/src/helper/service/mp';
@Component({ components: { FreedomContainer, GridLayout, GridItem, PageBottomTip, BackTop, EmptyState }, name: 'Activity'}) @Component({ components: { FreedomContainer, GridLayout, GridItem, PageBottomTip, BackTop, EmptyState }, name: 'Activity'})
export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyleMixin, SaMixin, DisableTouchMixin) { export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyleMixin, SaMixin, DisableTouchMixin) {
...@@ -270,13 +272,104 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle ...@@ -270,13 +272,104 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
} }
} }
handleNavUrl(nav, isCurrent) { handleNavUrl(nav, isCurrent) {
console.log(nav);
if (isCurrent) { return; } if (isCurrent) { return; }
const { pageType } = nav; const { pageType, pageUrl } = nav;
if (pageType == 1) { let nativeBridge;
// 功能页面 let mpBridge;
if (+pageType === 1) { // 功能页面
if (pageUrl === 'home') {
if (isApp) {
nativeBridge = new Bridge();
nativeBridge.openNewUrl({
data: {
// 需要打开的新链接
newUrl: home.app,
},
});
nativeBridge = null;
} else if (isWxMp) {
mpBridge = new MpBridge();
const jumpConfig = {
// 需要打开的新链接
newUrl: home.wxmp,
type: 'switchTab'
};
mpBridge.openNewUrl(jumpConfig);
mpBridge = null;
} else {
window.location.href = home.h5;
}
}
if (pageUrl === 'shopcart') {
if (isApp) {
nativeBridge = new Bridge();
nativeBridge.openNewUrl({
data: {
// 需要打开的新链接
newUrl: shopcart.app,
},
});
nativeBridge = null;
} else if (isWxMp) {
mpBridge = new MpBridge();
const jumpConfig = {
// 需要打开的新链接
newUrl: shopcart.wxmp,
type: 'switchTab'
};
mpBridge.openNewUrl(jumpConfig);
mpBridge = null;
} else {
window.location.href = shopcart.h5;
}
}
if (pageUrl === 'user') {
if (isApp) {
nativeBridge = new Bridge();
nativeBridge.openNewUrl({
data: {
// 需要打开的新链接
newUrl: user.app,
},
});
nativeBridge = null;
} else if (isWxMp) {
mpBridge = new MpBridge();
const jumpConfig = {
// 需要打开的新链接
newUrl: user.wxmp,
type: 'switchTab'
};
mpBridge.openNewUrl(jumpConfig);
mpBridge = null;
} else {
window.location.href = user.h5;
}
}
return; return;
} else { } else {
console.log(isApp, isWxMp);
if (isApp) {
nativeBridge = new Bridge();
nativeBridge.openNewUrl({
data: {
// 需要打开的新链接
newUrl: `xyqb://openHttp?jumpUrl=${pageUrl}`
},
});
nativeBridge = null;
} else if (isWxMp) {
mpBridge = new MpBridge();
const jumpConfig = {
// 需要打开的新链接
newUrl: pageUrl,
type: 'switchTab'
};
mpBridge.openNewUrl(jumpConfig);
mpBridge = null;
} else {
window.location.href = pageUrl;
}
// 活动页面及导航页面 // 活动页面及导航页面
} }
......
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