Merge remote-tracking branch 'origin/feature/miniPath' into release/6.4
Showing
4 changed files
with
41 additions
and
9 deletions
apps/api/controllers/forward.js
0 → 100644
1 | +/** | ||
2 | + * 连接内容返回 | ||
3 | + * @author: xiaoxiao<xiaoxiao.hao@yoho.cn> | ||
4 | + * @date: 2018/01/4 | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | + | ||
8 | +const request = require('request-promise'); | ||
9 | + | ||
10 | +const miniapp = (req, res) => { | ||
11 | + return request({ | ||
12 | + baseUrl: global.yoho.config.domains.api, | ||
13 | + uri: 'wechat/miniapp/img-check.jpg', | ||
14 | + qs: req.query, | ||
15 | + headers: { | ||
16 | + 'X-request-ID': req.reqID || '', | ||
17 | + 'X-YOHO-IP': req.yoho.clientIp || '', | ||
18 | + 'X-Forwarded-For': req.yoho.clientIp || '', | ||
19 | + 'User-Agent': 'yoho/nodejs' | ||
20 | + } | ||
21 | + }).pipe(res); // eslint-disable-line | ||
22 | +}; | ||
23 | + | ||
24 | +module.exports = { | ||
25 | + miniapp | ||
26 | +}; |
@@ -16,6 +16,7 @@ const uploadApi = require(cRoot + '/upload.js'); | @@ -16,6 +16,7 @@ const uploadApi = require(cRoot + '/upload.js'); | ||
16 | const hotfix = require(`${cRoot}/hotfix`); | 16 | const hotfix = require(`${cRoot}/hotfix`); |
17 | const apple = require(`${cRoot}/apple`); | 17 | const apple = require(`${cRoot}/apple`); |
18 | const rn = require(`${cRoot}/rn`); | 18 | const rn = require(`${cRoot}/rn`); |
19 | +const forward = require(`${cRoot}/forward`); | ||
19 | 20 | ||
20 | // routers | 21 | // routers |
21 | router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg); | 22 | router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg); |
@@ -23,5 +24,6 @@ router.post('/hf/v1', hotfix.v1); | @@ -23,5 +24,6 @@ router.post('/hf/v1', hotfix.v1); | ||
23 | router.post('/rn/v1', rn.v1); | 24 | router.post('/rn/v1', rn.v1); |
24 | 25 | ||
25 | router.get('/.well-known/apple-app-site-association', apple.appSiteAssociation); | 26 | router.get('/.well-known/apple-app-site-association', apple.appSiteAssociation); |
27 | +router.get('/wechat/miniapp.jpg', forward.miniapp); | ||
26 | 28 | ||
27 | module.exports = router; | 29 | module.exports = router; |
@@ -73,9 +73,6 @@ const newDetail = { | @@ -73,9 +73,6 @@ const newDetail = { | ||
73 | let description = result.goodsName + ' 有货网仅售' + result.goodsPrice.currentPrice + '元,购买' + | 73 | let description = result.goodsName + ' 有货网仅售' + result.goodsPrice.currentPrice + '元,购买' + |
74 | result.brandName + result.sortName + ',了解' + result.brandName + result.sortName + '商品信息就上有货网!'; | 74 | result.brandName + result.sortName + ',了解' + result.brandName + result.sortName + '商品信息就上有货网!'; |
75 | 75 | ||
76 | - // param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力 | ||
77 | - let miniPath = `${global.yoho.config.domains.api}wechat/miniapp/img-check.jpg?miniapp_type=0¶m=${result.productSkn}&miniQrType=1`.replace(/http:|https:/, ''); // eslint-disable-line | ||
78 | - | ||
79 | res.render('detail/new/detail', { | 76 | res.render('detail/new/detail', { |
80 | pageHeader: headerData, | 77 | pageHeader: headerData, |
81 | result: result, | 78 | result: result, |
@@ -90,7 +87,6 @@ const newDetail = { | @@ -90,7 +87,6 @@ const newDetail = { | ||
90 | pageFooter: true, | 87 | pageFooter: true, |
91 | localCss: true, | 88 | localCss: true, |
92 | appPath: appPath, | 89 | appPath: appPath, |
93 | - miniPath: miniPath, | ||
94 | isMarsApp: req.yoho.isMarsApp, // 判断mars | 90 | isMarsApp: req.yoho.isMarsApp, // 判断mars |
95 | showAnaJson: { | 91 | showAnaJson: { |
96 | miptitle: title, | 92 | miptitle: title, |
@@ -98,7 +94,12 @@ const newDetail = { | @@ -98,7 +94,12 @@ const newDetail = { | ||
98 | mipPics: mipPics.slice(0, 5), | 94 | mipPics: mipPics.slice(0, 5), |
99 | mipDes: description, | 95 | mipDes: description, |
100 | mipUrl: `${req.protocol}://m.yohobuy.com/product/${result.productSkn}.html` | 96 | mipUrl: `${req.protocol}://m.yohobuy.com/product/${result.productSkn}.html` |
101 | - } | 97 | + }, |
98 | + miniPath: helpers.urlFormat('/wechat/miniapp.jpg', { | ||
99 | + miniapp_type: 0, | ||
100 | + param: result.productSkn, | ||
101 | + miniQrType: 1 | ||
102 | + }) // param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力 | ||
102 | }); | 103 | }); |
103 | }).catch(next); | 104 | }).catch(next); |
104 | }, | 105 | }, |
@@ -193,11 +193,14 @@ const shop = { | @@ -193,11 +193,14 @@ const shop = { | ||
193 | return {}; | 193 | return {}; |
194 | } | 194 | } |
195 | 195 | ||
196 | - let brandId = _.get(brands, '[0].brand_id', 0); | ||
197 | - let brandName = encodeURIComponent(_.get(brands, '[0].brand_name', '')); | ||
198 | - | ||
199 | // param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力 | 196 | // param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力 |
200 | - let miniPath = `${global.yoho.config.domains.api}wechat/miniapp/img-check.jpg?miniapp_type=0¶m=${brandId}&name=${brandName}&miniQrType=2`.replace(/http:|https:/, ''); // eslint-disable-line | 197 | + let miniPath = helpers.urlFormat('/wechat/miniapp.jpg', { |
198 | + miniapp_type: 0, | ||
199 | + param: _.get(brands, '[0].brand_id', 0), | ||
200 | + name: encodeURIComponent(_.get(brands, '[0].brand_name', '')), | ||
201 | + miniQrType: 2 | ||
202 | + }); | ||
203 | + | ||
201 | return {miniPath}; | 204 | return {miniPath}; |
202 | }, | 205 | }, |
203 | 206 |
-
Please register or login to post a comment