Authored by 郭成尧

performance-better

@@ -168,7 +168,17 @@ const index = (req, res, next) => { @@ -168,7 +168,17 @@ const index = (req, res, next) => {
168 isShare = isWeixin || isqq || isWeibo ? true : false; 168 isShare = isWeixin || isqq || isWeibo ? true : false;
169 169
170 co(function* () { 170 co(function* () {
171 - let ret = yield tdk('article', id, req); 171 + let [ret, detail, commentsTotal, praise, wxFooter] = yield Promise.all([
  172 + tdk('article', id, req),
  173 + req.ctx(DetailModel).packageData(id, isApp, isWeixin, channel, isShare),
  174 + req.ctx(DetailModel).commentsTotal({ article_id: id, udid: udid }),
  175 + req.ctx(DetailModel).getArticlePraiseAndFavor({
  176 + uid: uid,
  177 + id: id,
  178 + udid: udid
  179 + }),
  180 + req.ctx(aboutModel).about(req.yoho.isApp)
  181 + ]);
172 182
173 if (ret[0]) { 183 if (ret[0]) {
174 req.tdk = { 184 req.tdk = {
@@ -177,13 +187,7 @@ const index = (req, res, next) => { @@ -177,13 +187,7 @@ const index = (req, res, next) => {
177 description: ret[3] 187 description: ret[3]
178 }; 188 };
179 } 189 }
180 - let detail = yield req.ctx(DetailModel).packageData(id, isApp, isWeixin, channel, isShare);  
181 - let commentsTotal = yield req.ctx(DetailModel).commentsTotal({article_id: id, udid: udid});  
182 - let praise = yield req.ctx(DetailModel).getArticlePraiseAndFavor({  
183 - uid: uid,  
184 - id: id,  
185 - udid: udid  
186 - }); 190 +
187 let data = { 191 let data = {
188 guangDetail: true, 192 guangDetail: true,
189 guang: {} 193 guang: {}
@@ -275,9 +279,7 @@ const index = (req, res, next) => { @@ -275,9 +279,7 @@ const index = (req, res, next) => {
275 // 标识有微信分享 279 // 标识有微信分享
276 data.hasWxShare = true; 280 data.hasWxShare = true;
277 281
278 - let resu = yield req.ctx(aboutModel).about(req.yoho.isApp);  
279 -  
280 - data.guang.wxFooter = resu; 282 + data.guang.wxFooter = wxFooter;
281 res.render('info/index', Object.assign({ 283 res.render('info/index', Object.assign({
282 page: 'info-index', 284 page: 'info-index',
283 gender: gender, 285 gender: gender,
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-05-18 11:42:11 3 * @Date: 2016-05-18 11:42:11
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-02-24 15:18:50  
6 */ 5 */
7 6
8 'use strict'; 7 'use strict';
@@ -24,7 +23,7 @@ module.exports = (data) => { @@ -24,7 +23,7 @@ module.exports = (data) => {
24 limit: data.limit || '20', 23 limit: data.limit || '20',
25 shopId: data.shopId, 24 shopId: data.shopId,
26 yh_channel: yhchannelMap[data.yhChannel] 25 yh_channel: yhchannelMap[data.yhChannel]
27 - }).then(result => { 26 + }, {cache: true}).then(result => {
28 let goodsContainer = $.load(result)('#goods-container'); 27 let goodsContainer = $.load(result)('#goods-container');
29 let goodThumb = goodsContainer.find('.good-thumb'); 28 let goodThumb = goodsContainer.find('.good-thumb');
30 29