Authored by 郭成尧

格式化输出结果

@@ -15,9 +15,11 @@ exports.index = (req, res) => { @@ -15,9 +15,11 @@ exports.index = (req, res) => {
15 var id = req.params.id; 15 var id = req.params.id;
16 16
17 detail({ 17 detail({
18 - id: id 18 + id: id,
  19 + ua: req.get('user-agent') || ''
19 }).then((result) => { 20 }).then((result) => {
20 res.render('detail', { 21 res.render('detail', {
  22 + resultShow: JSON.stringify(result, null, 4),
21 result: result, 23 result: result,
22 devEnv: true, 24 devEnv: true,
23 module: 'product', 25 module: 'product',
@@ -98,7 +98,7 @@ const procShowStatus = (data, showStatus, isBeginSale) => { @@ -98,7 +98,7 @@ const procShowStatus = (data, showStatus, isBeginSale) => {
98 * @param {[string]} skn 限购商品skn 98 * @param {[string]} skn 限购商品skn
99 * @return {[string]} 限购商品跳转url 99 * @return {[string]} 限购商品跳转url
100 */ 100 */
101 -const getLimitCodeUrl = (productCode, skn) => { 101 +const getLimitCodeUrl = (productCode, skn, ua) => {
102 var url = 'yohoapp://yoho.app/openwith?limit_product_code=' + productCode + '&product_skn=' + skn; 102 var url = 'yohoapp://yoho.app/openwith?limit_product_code=' + productCode + '&product_skn=' + skn;
103 103
104 return url; 104 return url;
@@ -109,7 +109,7 @@ const getLimitCodeUrl = (productCode, skn) => { @@ -109,7 +109,7 @@ const getLimitCodeUrl = (productCode, skn) => {
109 * @param origin Object 原始数据 109 * @param origin Object 原始数据
110 * @return dest Object 格式化数据 110 * @return dest Object 格式化数据
111 */ 111 */
112 -const detailDataPkg = (origin, uid, vipLevel) => { 112 +const detailDataPkg = (origin, uid, vipLevel, ua) => {
113 var dest = {}, // 结果输出 113 var dest = {}, // 结果输出
114 colorGroup = {}, 114 colorGroup = {},
115 thumbImageList = {}, 115 thumbImageList = {},
@@ -462,7 +462,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { @@ -462,7 +462,7 @@ const detailDataPkg = (origin, uid, vipLevel) => {
462 dest = procShowStatus(dest, showStatus, isBeginSale); 462 dest = procShowStatus(dest, showStatus, isBeginSale);
463 463
464 dest.cartInfo.limitProductCode = origin.limitProductCode; 464 dest.cartInfo.limitProductCode = origin.limitProductCode;
465 - dest.cartInfo.limitCodeUrl = getLimitCodeUrl(origin.limitProductCode, origin.erpProductId); 465 + dest.cartInfo.limitCodeUrl = getLimitCodeUrl(origin.limitProductCode, origin.erpProductId, ua);
466 dest.cartInfo.limitProductPay = helpers.url('/cart/index/orderEnsure'); 466 dest.cartInfo.limitProductPay = helpers.url('/cart/index/orderEnsure');
467 } else { 467 } else {
468 dest.cartInfo.addToCartUrl = helpers.url('/product/buy_' + origin.id + '_' + 468 dest.cartInfo.addToCartUrl = helpers.url('/product/buy_' + origin.id + '_' +
@@ -495,7 +495,7 @@ module.exports = (data) => { @@ -495,7 +495,7 @@ module.exports = (data) => {
495 productId: data.id, 495 productId: data.id,
496 method: 'h5.product.data' 496 method: 'h5.product.data'
497 })).then(result => { 497 })).then(result => {
498 - finalResult = detailDataPkg(result, null, 0); 498 + finalResult = detailDataPkg(result, null, 0, data.ua);
499 499
500 return api.get('', sign.apiSign({ 500 return api.get('', sign.apiSign({
501 method: 'app.shop.queryShopsByBrandId', 501 method: 'app.shop.queryShopsByBrandId',
1 hello, I am product hbs 1 hello, I am product hbs
  2 +<pre>
  3 +{{resultShow}}
  4 +</pre>
2 {{# result}} 5 {{# result}}
3 <div class="good-detail-page yoho-page"> 6 <div class="good-detail-page yoho-page">
4 <div class="banner-container"> 7 <div class="banner-container">