Authored by 毕凯

Merge remote-tracking branch 'origin/feature/miniPath' into release/6.4

/**
* 连接内容返回
* @author: xiaoxiao<xiaoxiao.hao@yoho.cn>
* @date: 2018/01/4
*/
'use strict';
const request = require('request-promise');
const miniapp = (req, res) => {
return request({
baseUrl: global.yoho.config.domains.api,
uri: 'wechat/miniapp/img-check.jpg',
qs: req.query,
headers: {
'X-request-ID': req.reqID || '',
'X-YOHO-IP': req.yoho.clientIp || '',
'X-Forwarded-For': req.yoho.clientIp || '',
'User-Agent': 'yoho/nodejs'
}
}).pipe(res); // eslint-disable-line
};
module.exports = {
miniapp
};
... ...
... ... @@ -16,6 +16,7 @@ const uploadApi = require(cRoot + '/upload.js');
const hotfix = require(`${cRoot}/hotfix`);
const apple = require(`${cRoot}/apple`);
const rn = require(`${cRoot}/rn`);
const forward = require(`${cRoot}/forward`);
// routers
router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg);
... ... @@ -23,5 +24,6 @@ router.post('/hf/v1', hotfix.v1);
router.post('/rn/v1', rn.v1);
router.get('/.well-known/apple-app-site-association', apple.appSiteAssociation);
router.get('/wechat/miniapp.jpg', forward.miniapp);
module.exports = router;
... ...
... ... @@ -73,9 +73,6 @@ const newDetail = {
let description = result.goodsName + ' 有货网仅售' + result.goodsPrice.currentPrice + '元,购买' +
result.brandName + result.sortName + ',了解' + result.brandName + result.sortName + '商品信息就上有货网!';
// param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力
let miniPath = `${global.yoho.config.domains.api}wechat/miniapp/img-check.jpg?miniapp_type=0&param=${result.productSkn}&miniQrType=1`.replace(/http:|https:/, ''); // eslint-disable-line
res.render('detail/new/detail', {
pageHeader: headerData,
result: result,
... ... @@ -90,7 +87,6 @@ const newDetail = {
pageFooter: true,
localCss: true,
appPath: appPath,
miniPath: miniPath,
isMarsApp: req.yoho.isMarsApp, // 判断mars
showAnaJson: {
miptitle: title,
... ... @@ -98,7 +94,12 @@ const newDetail = {
mipPics: mipPics.slice(0, 5),
mipDes: description,
mipUrl: `${req.protocol}://m.yohobuy.com/product/${result.productSkn}.html`
}
},
miniPath: helpers.urlFormat('/wechat/miniapp.jpg', {
miniapp_type: 0,
param: result.productSkn,
miniQrType: 1
}) // param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力
});
}).catch(next);
},
... ...
... ... @@ -193,11 +193,14 @@ const shop = {
return {};
}
let brandId = _.get(brands, '[0].brand_id', 0);
let brandName = encodeURIComponent(_.get(brands, '[0].brand_name', ''));
// param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力
let miniPath = `${global.yoho.config.domains.api}wechat/miniapp/img-check.jpg?miniapp_type=0&param=${brandId}&name=${brandName}&miniQrType=2`.replace(/http:|https:/, ''); // eslint-disable-line
let miniPath = helpers.urlFormat('/wechat/miniapp.jpg', {
miniapp_type: 0,
param: _.get(brands, '[0].brand_id', 0),
name: encodeURIComponent(_.get(brands, '[0].brand_name', '')),
miniQrType: 2
});
return {miniPath};
},
... ...