Authored by yyq

fix zk

... ... @@ -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
... ...
... ... @@ -2,7 +2,8 @@ const _ = require('lodash');
const config = global.yoho.config;
module.exports = (app) => {
let manifest;
let manifest,
manifestQcdn;
if (!app.locals.devEnv) {
let manifestPath = '../../manifest.json';
... ... @@ -14,8 +15,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,27 +44,33 @@ 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;
... ...