Authored by yyq

Merge branch 'master' into release/6.8.1

... ... @@ -4,6 +4,8 @@ const _ = require('lodash');
const stringProcess = require('../../../utils/string-process');
exports.index = function(req, res, next) {
let qcdn = _.get(req.app.locals, 'wap.qcloud_cdn');
req.ctx(model).index({
code: req.params.code,
type: stringProcess.paramsFilter(req.query.type)
... ... @@ -17,6 +19,8 @@ exports.index = function(req, res, next) {
// 唤起 APP 的路径
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"}}`;
let jsSdk = global.yoho.config.jsSdk;
res.render('feature/index', {
module: 'activity',
page: 'feature',
... ... @@ -26,7 +30,7 @@ exports.index = function(req, res, next) {
isFeature: true,
wechatShare: true,
loadJs: [{
src: global.yoho.config.jsSdk
src: qcdn ? jsSdk.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn') : jsSdk
}]
});
}).catch(next);
... ...
... ... @@ -28,7 +28,7 @@
{{#isEqualOr type '' 'common_floor' 'fix'}}
{{! 普通楼层 顶悬浮}}
<div {{#if param.anchorname}} id="{{param.anchorname}}" {{/if}} {{#if param.tabname}} tabname="{{param.tabname}}" {{/if}}
{{#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}}">
{{#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}}">
{{#if param.bgimg}}
{{#isLazyLoad type @index}}
<img class="lazy" data-original="{{imageslim param.bgimg}}">
... ... @@ -124,7 +124,7 @@
<div class="product-container single-item3">
<a class="shop-container" href="{{jumpUrl}}">
<div class="feature-shop-info">
<image src="{{shopImge}}"></image>
<image class="lazy" data-original="{{image2 shopImge q=80}}"></image>
</div>
</a>
</div>
... ...
... ... @@ -188,7 +188,8 @@ const newDetail = {
shoppingKey: shoppingKey,
ua: req.get('user-agent') || '',
from: req.query.from,
closeBuyNowButton: closeBuyNowButton
closeBuyNowButton: closeBuyNowButton,
removeCartCount: _.get(req.app.locals, 'wap.common.removeCartCount')
}, req.__User__)).then((result) => {
if (_.isEmpty(result)) {
return res.json({
... ...
... ... @@ -435,6 +435,10 @@ module.exports = class extends global.yoho.BaseModel {
}
_cartCount(uid, shoppingKey) {
if (!uid && !shoppingKey) {
return Promise.resolve(0);
}
return this.get({
data: {
method: 'app.Shopping.count',
... ... @@ -725,7 +729,7 @@ module.exports = class extends global.yoho.BaseModel {
result.goods_id = data.goodsId;
let apiArray = [
this._cartCount(data.uid, data.shoppingKey),
data.removeCartCount ? Promise.resolve(0) : this._cartCount(data.uid, data.shoppingKey),
this._detailDataPkgAsync(_.assign(result, {
from: data.from,
closeBuyNowButton: data.closeBuyNowButton
... ...
... ... @@ -5,7 +5,7 @@
* @date 2016/05/06
*/
const pkg = require('../package.json');
// const pkg = require('../package.json');
const from = require('./from');
const isProduction = process.env.NODE_ENV === 'production';
... ... @@ -286,7 +286,7 @@ if (isProduction) {
});
} else if (isTest) {
Object.assign(module.exports, {
assetUrl: `//cdn.yoho.cn/yohobuywap-node/${pkg.version}/`,
assetUrl: '//cdn.yoho.cn/yohobuywap-node/',
domains: {
api: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/',
service: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/',
... ...
... ... @@ -2,7 +2,10 @@ const _ = require('lodash');
const config = global.yoho.config;
module.exports = (app) => {
let manifest;
let manifest,
manifestQcdn;
let assetUrl = config.assetUrl,
assetUrlQcdn = assetUrl.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn');
if (!app.locals.devEnv) {
let manifestPath = '../../manifest.json';
... ... @@ -14,8 +17,20 @@ module.exports = (app) => {
manifest = require(manifestPath);
}
function getStatic(path, def) {
return _.get(manifest, path, `${config.assetUrl}${def}`);
if (manifest) {
try {
let strManifest = JSON.stringify(manifest);
strManifest = strManifest.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn');
manifestQcdn = JSON.parse(strManifest);
} catch(e) { // eslint-disable-line
manifestQcdn = manifest;
}
}
function getStatic(path, def, qcdn) {
return _.get(qcdn ? manifestQcdn : manifest, path, `${config.assetUrl}${def}`);
}
function getPreloads(list, type, cross) {
... ... @@ -31,30 +46,37 @@ module.exports = (app) => {
return (req, res, next) => {
res.on('beforeRender', (params) => {
if (params) {
const qcdn = _.get(req.app.locals, 'wap.qcloud_cdn');
const {data} = params;
const {module: moduleName, page, localCss, isFeature, vue} = Object.assign({}, res.locals, data);
const getStaticWithCdn = (path, def) => {
return getStatic(path, def, qcdn);
};
if (moduleName && page) {
const statics = {
name: `${moduleName}.${page}`,
styles: [],
javascripts: [
getStatic('common.vendors.js', 'js/vendors.js'),
getStatic('common.main.js', 'js/main.js'),
getStaticWithCdn('common.vendors.js', 'js/vendors.js'),
getStaticWithCdn('common.main.js', 'js/main.js'),
]
};
if (isFeature || localCss || vue) {
if (!isFeature) {
statics.styles.push(getStatic('common.main.css', 'css/main.css'));
statics.styles.push(getStaticWithCdn('common.main.css', 'css/main.css'));
}
statics.styles.push(
getStatic(`pages.${moduleName}.${page}.css`, `css/page.${moduleName}.${page}.css`));
getStaticWithCdn(`pages.${moduleName}.${page}.css`, `css/page.${moduleName}.${page}.css`));
} else {
statics.styles.push(getStatic('common.index.css', 'css/index.css'));
statics.styles.push(getStaticWithCdn('common.index.css', 'css/index.css'));
}
res.locals.statics = statics;
res.locals.staticAssetUrl = qcdn ? assetUrlQcdn : assetUrl;
res.locals.preloads = _.concat(getPreloads(statics.styles, 'style'),
getPreloads(statics.javascripts, 'script', true));
}
... ...
... ... @@ -48,6 +48,7 @@
{{!-- Android机器页面不再受到用户字体缩放强制改变大小 'http://m.blog.csdn.net/article/details?id=51275080' --}}
<script type="text/javascript">
window._staticAssetUrl = '{{staticAssetUrl}}';
var isWechat = /micromessenger/i.test(navigator.userAgent || '');
if (isWechat) {
document.title =document.title.replace(' | Yoho!Buy有货 | 潮流购物逛不停', '');
... ...
__webpack_public_path__ = window._staticAssetUrl; // eslint-disable-line
import './js/common';
import './js/global';
import './scss/common.scss';
... ...