Authored by 郭成尧

格式化代码

... ... @@ -16,9 +16,9 @@ exports.index = (req, res) => {
detail({
id: id
}, (result) => {
}).then((result) => {
res.render('detail', {
result: result,
result: JSON.stringify(result, null, 4),
devEnv: true
});
});
... ...
... ... @@ -241,13 +241,11 @@ const detailDataPkg = (origin, uid, vipLevel) => {
// 品牌信息
if (origin.brand !== null && origin.brand !== undefined) {
dest.enterStore = {};
dest.enterStore[0] = {};
dest.enterStore[0].img =
helpers.getImageUrl(origin.brand.brandIco, 47, 47);
dest.enterStore[0].storeName = origin.brand.brandName;
dest.enterStore[0].url = helpers.url('', null, origin.brand.brandDomain);
// dest.enterStore[0] = {};
// dest.enterStore[0].img =
// helpers.getImageUrl(origin.brand.brandIco, 47, 47);
// dest.enterStore[0].storeName = origin.brand.brandName;
// dest.enterStore[0].url = helpers.url('', null, origin.brand.brandDomain);
// 为你优选的链接
let params = {};
... ... @@ -461,18 +459,43 @@ const detailDataPkg = (origin, uid, vipLevel) => {
// 底部简介的URL链接
dest.introUrl = helpers.url('/product/intro_' + origin.erpProductId + '/' + origin.cnAlphabet + '.html', null, '');
dest.id = origin.id;
console.log('data:' + JSON.stringify(dest));
return dest;
};
module.exports = (data, cb) => {
console.log('data:' + JSON.stringify(data));
api.get('', sign.apiSign({
module.exports = (data) => {
var finalResult;
return api.get('', sign.apiSign({
productId: data.id,
method: 'h5.product.data'
})).then(result => {
var dJson = JSON.parse(result);
cb(detailDataPkg(dJson, null, 0)); // 待处理 缺少 VIP 等级参数,暂时补充为 0
finalResult = detailDataPkg(result, null, 0);
return api.get('', sign.apiSign({
method: 'app.shop.queryShopsByBrandId',
brand_id: result.brand.id
})).then(shops => {
if (shops.code === 200) {
finalResult.enterStore = {};
_.forEach(shops.data, function(value, key) {
finalResult.enterStore[key] = {};
finalResult.enterStore[key].img = helpers.getImageUrl(value.brand_ico, 47, 47);
finalResult.enterStore[key].storeName = value.brand_name;
if (value.shop_id !== null && value.shop_id !== undefined) {
let params = {};
params.shop_id = value.shop_id;
finalResult.enterStore[key].url =
helpers.url('/product/index/brand', params);
} else {
finalResult.enterStore[key].url =
helpers.url('', null, value.brand_domain);
}
});
}
return finalResult;
});
});
};
... ...
... ... @@ -58,7 +58,8 @@ class API {
let options = {
url: `${ApiUrl}${url}`,
qs: data
qs: data,
json: true
};
let requestPromise = rp(options);
... ...