...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
* 拦截跳转, 在这里给将要打开的页面设置一下 header 样式
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
const $ = require('jquery');
|
|
|
const yoho = require('yoho');
|
|
|
const parse = require('yoho-qs/parse'); // 提供解析函数
|
|
|
|
...
|
...
|
@@ -17,7 +18,7 @@ const origin = location.origin; |
|
|
* 文档 http://git.yoho.cn/mobile/AppJSBridge/blob/master/HeaderType.md
|
|
|
* @type {Object}
|
|
|
*/
|
|
|
const titleMap = {
|
|
|
const defaultTitleMap = {
|
|
|
1: {
|
|
|
headerid: '1',
|
|
|
left: {
|
...
|
...
|
@@ -95,11 +96,10 @@ const titleMap = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
const matchHeader = (url) => {
|
|
|
const matchHeader = (path, qs, titleMap) => {
|
|
|
let header = {
|
|
|
headerid: '-1'
|
|
|
};
|
|
|
let path = url.split('?')[0];
|
|
|
|
|
|
if (/\/cate-all$/.test(path)) {
|
|
|
header = titleMap[1];
|
...
|
...
|
@@ -115,16 +115,14 @@ const matchHeader = (url) => { |
|
|
|
|
|
if (/\/me\/order$/.test(path)) {
|
|
|
let des = '';
|
|
|
let u = url.split('?')[1];
|
|
|
|
|
|
u = parse(u);
|
|
|
if (u.type === '1') {
|
|
|
if (qs.type === '1') {
|
|
|
des = '我的订单';
|
|
|
} else if (u.type === '2') {
|
|
|
} else if (qs.type === '2') {
|
|
|
des = '待付款';
|
|
|
} else if (u.type === '3') {
|
|
|
} else if (qs.type === '3') {
|
|
|
des = '待发货';
|
|
|
} else if (u.type === '4') {
|
|
|
} else if (qs.type === '4') {
|
|
|
des = '待收货';
|
|
|
}
|
|
|
header = titleMap[1];
|
...
|
...
|
@@ -182,11 +180,8 @@ const matchHeader = (url) => { |
|
|
}
|
|
|
|
|
|
if (/\/me\/help-detail$/.test(path)) {
|
|
|
let u = url.split('?')[1];
|
|
|
|
|
|
u = parse(u);
|
|
|
header = titleMap[1];
|
|
|
header.title.des = u.title; // 帮助中心详细
|
|
|
header.title.des = qs.title; // 帮助中心详细
|
|
|
return header;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -217,6 +212,7 @@ const matchHeader = (url) => { |
|
|
|
|
|
const intercept = (url) => {
|
|
|
if (yoho.isApp) {
|
|
|
let titleMap = $.extend({}, defaultTitleMap);
|
|
|
let [path, qs] = url.split('?');
|
|
|
|
|
|
qs = parse(qs);
|
...
|
...
|
@@ -265,7 +261,7 @@ const intercept = (url) => { |
|
|
}
|
|
|
|
|
|
yoho.goNewPage({
|
|
|
header: matchHeader(url),
|
|
|
header: matchHeader(path, qs, titleMap),
|
|
|
url: /^(https?:)?\/\//i.test(url) ? url : origin + url
|
|
|
});
|
|
|
} else {
|
...
|
...
|
@@ -274,6 +270,6 @@ const intercept = (url) => { |
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
titleMap: titleMap,
|
|
|
defaultTitleMap: defaultTitleMap,
|
|
|
intercept: intercept
|
|
|
}; |
...
|
...
|
|