Authored by 郭成尧

Merge branch 'develop' of git.yoho.cn:fe/yohoblk-wap into develop

@@ -42,12 +42,12 @@ const titleMap = { @@ -42,12 +42,12 @@ const titleMap = {
42 action: '' 42 action: ''
43 }, 43 },
44 title: { 44 title: {
45 - des: '标题3', 45 + des: 'BLK',
46 action: '' 46 action: ''
47 }, 47 },
48 right: { 48 right: {
49 des: '提交', 49 des: '提交',
50 - action: '' 50 + action: 'submitForm'
51 } 51 }
52 }, 52 },
53 4: { 53 4: {
@@ -67,16 +67,16 @@ const titleMap = { @@ -67,16 +67,16 @@ const titleMap = {
67 action: '' 67 action: ''
68 }, 68 },
69 ltitle: { 69 ltitle: {
70 - des: '商品5',  
71 - action: '' 70 + des: '商品',
  71 + action: origin + '/favorite'
72 }, 72 },
73 rtitle: { 73 rtitle: {
74 - des: '品牌5',  
75 - action: '' 74 + des: '品牌',
  75 + action: origin + '/favorite?tab=brand'
76 }, 76 },
77 right: { 77 right: {
78 - des: '编辑5',  
79 - action: '' 78 + des: '编辑',
  79 + action: 'editModel'
80 } 80 }
81 }, 81 },
82 6: { 82 6: {
@@ -92,20 +92,15 @@ const matchHeader = (url) => { @@ -92,20 +92,15 @@ const matchHeader = (url) => {
92 let header = { 92 let header = {
93 headerid: '-1' // 默认不显示头部 93 headerid: '-1' // 默认不显示头部
94 }; 94 };
  95 + let path = url.split('?')[0];
95 96
96 - if (/\/brands/.test(url) || /\/cate/.test(url)) {  
97 - header = titleMap[2];  
98 - alert(JSON.stringify(header));  
99 - return header;  
100 - }  
101 -  
102 - if (/\/home\/mydetails/.test(url)) { 97 + if (/\/home\/mydetails$/.test(path)) {
103 header = titleMap[1]; 98 header = titleMap[1];
104 header.title.des = '个人信息'; 99 header.title.des = '个人信息';
105 return header; 100 return header;
106 } 101 }
107 102
108 - if (/\/home\/orders/.test(url)) { 103 + if (/\/home\/orders$/.test(path)) {
109 let des = ''; 104 let des = '';
110 let u = url.split('?')[1]; 105 let u = url.split('?')[1];
111 106
@@ -124,55 +119,38 @@ const matchHeader = (url) => { @@ -124,55 +119,38 @@ const matchHeader = (url) => {
124 return header; 119 return header;
125 } 120 }
126 121
127 - if (/\/home\/order-detail/.test(url)) { 122 + if (/\/home\/order-detail$/.test(path)) {
128 header = titleMap[2]; 123 header = titleMap[2];
129 header.title.des = '订单详情'; 124 header.title.des = '订单详情';
130 header.title.right.action = origin + '/home/service'; 125 header.title.right.action = origin + '/home/service';
131 return header; 126 return header;
132 } 127 }
133 128
134 - if (/\/home\/refund\/orders/.test(url)) { 129 + if (/\/home\/refund\/orders$/.test(path)) {
135 header = titleMap[1]; 130 header = titleMap[1];
136 header.title.des = '退/换货'; 131 header.title.des = '退/换货';
137 return header; 132 return header;
138 } 133 }
139 134
140 - if (/\/home\/favorite/.test(url)) {  
141 - header = titleMap[5];  
142 - header.ltitle = {  
143 - des: '商品',  
144 - action: origin + '/home/favorite'  
145 - };  
146 - header.rtitle = {  
147 - des: '品牌',  
148 - action: origin + '/home/favorite?tab=brand'  
149 - };  
150 - header.right = {  
151 - des: '编辑',  
152 - action: 'editModel'  
153 - };  
154 - return header;  
155 - }  
156 -  
157 - if (/\/home\/mycurrency/.test(url)) { 135 + if (/\/home\/mycurrency$/.test(path)) {
158 header = titleMap[1]; 136 header = titleMap[1];
159 header.title.des = '有货币'; 137 header.title.des = '有货币';
160 return header; 138 return header;
161 } 139 }
162 140
163 - if (/\/home\/help$/.test(url)) { 141 + if (/\/home\/help$/.test(path)) {
164 header = titleMap[1]; 142 header = titleMap[1];
165 header.title.des = '帮助中心'; 143 header.title.des = '帮助中心';
166 return header; 144 return header;
167 } 145 }
168 146
169 - if (/\/home\/service$/.test(url)) { 147 + if (/\/home\/service$/.test(path)) {
170 header = titleMap[1]; 148 header = titleMap[1];
171 header.title.des = 'Yoho!Blk在线客服'; 149 header.title.des = 'Yoho!Blk在线客服';
172 return header; 150 return header;
173 } 151 }
174 152
175 - if (/\/home\/feedback/.test(url)) { 153 + if (/\/home\/feedback$/.test(path)) {
176 header = titleMap[3]; 154 header = titleMap[3];
177 header.title.des = '意见反馈'; 155 header.title.des = '意见反馈';
178 header.right = { 156 header.right = {
@@ -182,7 +160,7 @@ const matchHeader = (url) => { @@ -182,7 +160,7 @@ const matchHeader = (url) => {
182 return header; 160 return header;
183 } 161 }
184 162
185 - if (/\/home\/about/.test(url)) { 163 + if (/\/home\/about$/.test(path)) {
186 header = titleMap[1]; 164 header = titleMap[1];
187 header.title.des = '关于'; 165 header.title.des = '关于';
188 return header; 166 return header;
@@ -194,16 +172,30 @@ const matchHeader = (url) => { @@ -194,16 +172,30 @@ const matchHeader = (url) => {
194 172
195 module.exports = (url) => { 173 module.exports = (url) => {
196 if (yoho.isApp) { 174 if (yoho.isApp) {
197 - // 品牌 品类  
198 - // if (/\/brands/.test(url) || /\/cate/.test(url)) {  
199 - // return yoho.goTab({index: 1});  
200 - // } 175 + let path = url.split('?')[0];
  176 +
  177 + // 个人中心收藏
  178 + if (/\/home\/favorite$/.test(path)) {
  179 + return yoho.goPageView({
  180 + header: titleMap[5]
  181 + });
  182 + }
201 183
202 // 个人中心首页 184 // 个人中心首页
203 - if (/\/home$/.test(url)) { 185 + if (/\/home$/.test(path)) {
204 return yoho.goTab({index: 4}); 186 return yoho.goTab({index: 4});
205 } 187 }
206 188
  189 + // 资讯
  190 + if (/\/news$/.test(path)) {
  191 + return yoho.goTab({index: 3});
  192 + }
  193 +
  194 + // 品牌 品类
  195 + if (/\/brands$/.test(path) || /\/cate$/.test(path)) {
  196 + return yoho.goTab({index: 1});
  197 + }
  198 +
207 yoho.goNewPage({ 199 yoho.goNewPage({
208 header: matchHeader(url), 200 header: matchHeader(url),
209 url: /^(https?:)?\/\//i.test(url) ? url : origin + url 201 url: /^(https?:)?\/\//i.test(url) ? url : origin + url
@@ -277,9 +277,12 @@ const yoho = { @@ -277,9 +277,12 @@ const yoho = {
277 * @param callback 回调 277 * @param callback 回调
278 */ 278 */
279 addNativeMethod(name, callback) { 279 addNativeMethod(name, callback) {
280 - if (window.yohoInterface) {  
281 - window.yohoInterface[name] = callback;  
282 - } 280 + // 延迟 500ms 注入
  281 + setTimeout(function() {
  282 + if (window.yohoInterface) {
  283 + window.yohoInterface[name] = callback;
  284 + }
  285 + }, 500);
283 } 286 }
284 }; 287 };
285 288