Merge branch 'master' into release/6.8.1
Showing
8 changed files
with
49 additions
and
15 deletions
@@ -4,6 +4,8 @@ const _ = require('lodash'); | @@ -4,6 +4,8 @@ const _ = require('lodash'); | ||
4 | const stringProcess = require('../../../utils/string-process'); | 4 | const stringProcess = require('../../../utils/string-process'); |
5 | 5 | ||
6 | exports.index = function(req, res, next) { | 6 | exports.index = function(req, res, next) { |
7 | + let qcdn = _.get(req.app.locals, 'wap.qcloud_cdn'); | ||
8 | + | ||
7 | req.ctx(model).index({ | 9 | req.ctx(model).index({ |
8 | code: req.params.code, | 10 | code: req.params.code, |
9 | type: stringProcess.paramsFilter(req.query.type) | 11 | type: stringProcess.paramsFilter(req.query.type) |
@@ -17,6 +19,8 @@ exports.index = function(req, res, next) { | @@ -17,6 +19,8 @@ exports.index = function(req, res, next) { | ||
17 | // 唤起 APP 的路径 | 19 | // 唤起 APP 的路径 |
18 | res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.h5","params":{"param":{"share_id":"${shareId}","title":"${title}"},"share":"/operations/api/v5/webshare/getShare","shareparam":{"share_id":"${shareId}"},"title":"${title}","url":"https://activity.yoho.cn/feature/${req.params.code}.html"}}`; | 20 | res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.h5","params":{"param":{"share_id":"${shareId}","title":"${title}"},"share":"/operations/api/v5/webshare/getShare","shareparam":{"share_id":"${shareId}"},"title":"${title}","url":"https://activity.yoho.cn/feature/${req.params.code}.html"}}`; |
19 | 21 | ||
22 | + let jsSdk = global.yoho.config.jsSdk; | ||
23 | + | ||
20 | res.render('feature/index', { | 24 | res.render('feature/index', { |
21 | module: 'activity', | 25 | module: 'activity', |
22 | page: 'feature', | 26 | page: 'feature', |
@@ -26,7 +30,7 @@ exports.index = function(req, res, next) { | @@ -26,7 +30,7 @@ exports.index = function(req, res, next) { | ||
26 | isFeature: true, | 30 | isFeature: true, |
27 | wechatShare: true, | 31 | wechatShare: true, |
28 | loadJs: [{ | 32 | loadJs: [{ |
29 | - src: global.yoho.config.jsSdk | 33 | + src: qcdn ? jsSdk.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn') : jsSdk |
30 | }] | 34 | }] |
31 | }); | 35 | }); |
32 | }).catch(next); | 36 | }).catch(next); |
@@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
28 | {{#isEqualOr type '' 'common_floor' 'fix'}} | 28 | {{#isEqualOr type '' 'common_floor' 'fix'}} |
29 | {{! 普通楼层 顶悬浮}} | 29 | {{! 普通楼层 顶悬浮}} |
30 | <div {{#if param.anchorname}} id="{{param.anchorname}}" {{/if}} {{#if param.tabname}} tabname="{{param.tabname}}" {{/if}} | 30 | <div {{#if param.anchorname}} id="{{param.anchorname}}" {{/if}} {{#if param.tabname}} tabname="{{param.tabname}}" {{/if}} |
31 | - {{#if id}} data-id="{{id}}" {{/if}} class="floor clearfix {{type}} {{#if hide}}hide{{/if}}" style="{{#if param.bgcolor}}background-color:{{param.bgcolor}};{{/if}}{{#if param._bgimgFill}}background-image: url({{param._bgimgFill}});{{/if}}"> | 31 | + {{#if id}} data-id="{{id}}" {{/if}} class="floor clearfix {{type}} {{#if hide}}hide{{/if}}" style="{{#if param.bgcolor}}background-color:{{param.bgcolor}};{{/if}}{{#if param._bgimgFill}}background-image: url({{imageslim param._bgimgFill}});{{/if}}"> |
32 | {{#if param.bgimg}} | 32 | {{#if param.bgimg}} |
33 | {{#isLazyLoad type @index}} | 33 | {{#isLazyLoad type @index}} |
34 | <img class="lazy" data-original="{{imageslim param.bgimg}}"> | 34 | <img class="lazy" data-original="{{imageslim param.bgimg}}"> |
@@ -124,7 +124,7 @@ | @@ -124,7 +124,7 @@ | ||
124 | <div class="product-container single-item3"> | 124 | <div class="product-container single-item3"> |
125 | <a class="shop-container" href="{{jumpUrl}}"> | 125 | <a class="shop-container" href="{{jumpUrl}}"> |
126 | <div class="feature-shop-info"> | 126 | <div class="feature-shop-info"> |
127 | - <image src="{{shopImge}}"></image> | 127 | + <image class="lazy" data-original="{{image2 shopImge q=80}}"></image> |
128 | </div> | 128 | </div> |
129 | </a> | 129 | </a> |
130 | </div> | 130 | </div> |
@@ -188,7 +188,8 @@ const newDetail = { | @@ -188,7 +188,8 @@ const newDetail = { | ||
188 | shoppingKey: shoppingKey, | 188 | shoppingKey: shoppingKey, |
189 | ua: req.get('user-agent') || '', | 189 | ua: req.get('user-agent') || '', |
190 | from: req.query.from, | 190 | from: req.query.from, |
191 | - closeBuyNowButton: closeBuyNowButton | 191 | + closeBuyNowButton: closeBuyNowButton, |
192 | + removeCartCount: _.get(req.app.locals, 'wap.common.removeCartCount') | ||
192 | }, req.__User__)).then((result) => { | 193 | }, req.__User__)).then((result) => { |
193 | if (_.isEmpty(result)) { | 194 | if (_.isEmpty(result)) { |
194 | return res.json({ | 195 | return res.json({ |
@@ -435,6 +435,10 @@ module.exports = class extends global.yoho.BaseModel { | @@ -435,6 +435,10 @@ module.exports = class extends global.yoho.BaseModel { | ||
435 | } | 435 | } |
436 | 436 | ||
437 | _cartCount(uid, shoppingKey) { | 437 | _cartCount(uid, shoppingKey) { |
438 | + if (!uid && !shoppingKey) { | ||
439 | + return Promise.resolve(0); | ||
440 | + } | ||
441 | + | ||
438 | return this.get({ | 442 | return this.get({ |
439 | data: { | 443 | data: { |
440 | method: 'app.Shopping.count', | 444 | method: 'app.Shopping.count', |
@@ -725,7 +729,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -725,7 +729,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
725 | result.goods_id = data.goodsId; | 729 | result.goods_id = data.goodsId; |
726 | 730 | ||
727 | let apiArray = [ | 731 | let apiArray = [ |
728 | - this._cartCount(data.uid, data.shoppingKey), | 732 | + data.removeCartCount ? Promise.resolve(0) : this._cartCount(data.uid, data.shoppingKey), |
729 | this._detailDataPkgAsync(_.assign(result, { | 733 | this._detailDataPkgAsync(_.assign(result, { |
730 | from: data.from, | 734 | from: data.from, |
731 | closeBuyNowButton: data.closeBuyNowButton | 735 | closeBuyNowButton: data.closeBuyNowButton |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * @date 2016/05/06 | 5 | * @date 2016/05/06 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | -const pkg = require('../package.json'); | 8 | +// const pkg = require('../package.json'); |
9 | const from = require('./from'); | 9 | const from = require('./from'); |
10 | 10 | ||
11 | const isProduction = process.env.NODE_ENV === 'production'; | 11 | const isProduction = process.env.NODE_ENV === 'production'; |
@@ -286,7 +286,7 @@ if (isProduction) { | @@ -286,7 +286,7 @@ if (isProduction) { | ||
286 | }); | 286 | }); |
287 | } else if (isTest) { | 287 | } else if (isTest) { |
288 | Object.assign(module.exports, { | 288 | Object.assign(module.exports, { |
289 | - assetUrl: `//cdn.yoho.cn/yohobuywap-node/${pkg.version}/`, | 289 | + assetUrl: '//cdn.yoho.cn/yohobuywap-node/', |
290 | domains: { | 290 | domains: { |
291 | api: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/', | 291 | api: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/', |
292 | service: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/', | 292 | service: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/', |
@@ -2,7 +2,10 @@ const _ = require('lodash'); | @@ -2,7 +2,10 @@ const _ = require('lodash'); | ||
2 | const config = global.yoho.config; | 2 | const config = global.yoho.config; |
3 | 3 | ||
4 | module.exports = (app) => { | 4 | module.exports = (app) => { |
5 | - let manifest; | 5 | + let manifest, |
6 | + manifestQcdn; | ||
7 | + let assetUrl = config.assetUrl, | ||
8 | + assetUrlQcdn = assetUrl.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn'); | ||
6 | 9 | ||
7 | if (!app.locals.devEnv) { | 10 | if (!app.locals.devEnv) { |
8 | let manifestPath = '../../manifest.json'; | 11 | let manifestPath = '../../manifest.json'; |
@@ -14,8 +17,20 @@ module.exports = (app) => { | @@ -14,8 +17,20 @@ module.exports = (app) => { | ||
14 | manifest = require(manifestPath); | 17 | manifest = require(manifestPath); |
15 | } | 18 | } |
16 | 19 | ||
17 | - function getStatic(path, def) { | ||
18 | - return _.get(manifest, path, `${config.assetUrl}${def}`); | 20 | + if (manifest) { |
21 | + try { | ||
22 | + let strManifest = JSON.stringify(manifest); | ||
23 | + | ||
24 | + strManifest = strManifest.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn'); | ||
25 | + | ||
26 | + manifestQcdn = JSON.parse(strManifest); | ||
27 | + } catch(e) { // eslint-disable-line | ||
28 | + manifestQcdn = manifest; | ||
29 | + } | ||
30 | + } | ||
31 | + | ||
32 | + function getStatic(path, def, qcdn) { | ||
33 | + return _.get(qcdn ? manifestQcdn : manifest, path, `${config.assetUrl}${def}`); | ||
19 | } | 34 | } |
20 | 35 | ||
21 | function getPreloads(list, type, cross) { | 36 | function getPreloads(list, type, cross) { |
@@ -31,30 +46,37 @@ module.exports = (app) => { | @@ -31,30 +46,37 @@ module.exports = (app) => { | ||
31 | return (req, res, next) => { | 46 | return (req, res, next) => { |
32 | res.on('beforeRender', (params) => { | 47 | res.on('beforeRender', (params) => { |
33 | if (params) { | 48 | if (params) { |
49 | + const qcdn = _.get(req.app.locals, 'wap.qcloud_cdn'); | ||
34 | const {data} = params; | 50 | const {data} = params; |
35 | const {module: moduleName, page, localCss, isFeature, vue} = Object.assign({}, res.locals, data); | 51 | const {module: moduleName, page, localCss, isFeature, vue} = Object.assign({}, res.locals, data); |
36 | 52 | ||
53 | + const getStaticWithCdn = (path, def) => { | ||
54 | + return getStatic(path, def, qcdn); | ||
55 | + }; | ||
56 | + | ||
37 | if (moduleName && page) { | 57 | if (moduleName && page) { |
38 | const statics = { | 58 | const statics = { |
39 | name: `${moduleName}.${page}`, | 59 | name: `${moduleName}.${page}`, |
40 | styles: [], | 60 | styles: [], |
41 | javascripts: [ | 61 | javascripts: [ |
42 | - getStatic('common.vendors.js', 'js/vendors.js'), | ||
43 | - getStatic('common.main.js', 'js/main.js'), | 62 | + getStaticWithCdn('common.vendors.js', 'js/vendors.js'), |
63 | + getStaticWithCdn('common.main.js', 'js/main.js'), | ||
44 | ] | 64 | ] |
45 | }; | 65 | }; |
46 | 66 | ||
47 | if (isFeature || localCss || vue) { | 67 | if (isFeature || localCss || vue) { |
68 | + | ||
48 | if (!isFeature) { | 69 | if (!isFeature) { |
49 | - statics.styles.push(getStatic('common.main.css', 'css/main.css')); | 70 | + statics.styles.push(getStaticWithCdn('common.main.css', 'css/main.css')); |
50 | } | 71 | } |
51 | statics.styles.push( | 72 | statics.styles.push( |
52 | - getStatic(`pages.${moduleName}.${page}.css`, `css/page.${moduleName}.${page}.css`)); | 73 | + getStaticWithCdn(`pages.${moduleName}.${page}.css`, `css/page.${moduleName}.${page}.css`)); |
53 | } else { | 74 | } else { |
54 | - statics.styles.push(getStatic('common.index.css', 'css/index.css')); | 75 | + statics.styles.push(getStaticWithCdn('common.index.css', 'css/index.css')); |
55 | } | 76 | } |
56 | 77 | ||
57 | res.locals.statics = statics; | 78 | res.locals.statics = statics; |
79 | + res.locals.staticAssetUrl = qcdn ? assetUrlQcdn : assetUrl; | ||
58 | res.locals.preloads = _.concat(getPreloads(statics.styles, 'style'), | 80 | res.locals.preloads = _.concat(getPreloads(statics.styles, 'style'), |
59 | getPreloads(statics.javascripts, 'script', true)); | 81 | getPreloads(statics.javascripts, 'script', true)); |
60 | } | 82 | } |
@@ -48,6 +48,7 @@ | @@ -48,6 +48,7 @@ | ||
48 | 48 | ||
49 | {{!-- Android机器页面不再受到用户字体缩放强制改变大小 'http://m.blog.csdn.net/article/details?id=51275080' --}} | 49 | {{!-- Android机器页面不再受到用户字体缩放强制改变大小 'http://m.blog.csdn.net/article/details?id=51275080' --}} |
50 | <script type="text/javascript"> | 50 | <script type="text/javascript"> |
51 | + window._staticAssetUrl = '{{staticAssetUrl}}'; | ||
51 | var isWechat = /micromessenger/i.test(navigator.userAgent || ''); | 52 | var isWechat = /micromessenger/i.test(navigator.userAgent || ''); |
52 | if (isWechat) { | 53 | if (isWechat) { |
53 | document.title =document.title.replace(' | Yoho!Buy有货 | 潮流购物逛不停', ''); | 54 | document.title =document.title.replace(' | Yoho!Buy有货 | 潮流购物逛不停', ''); |
-
Please register or login to post a comment