Authored by 郭成尧

Merge branch 'hotfix/error' into gray

... ... @@ -76,6 +76,8 @@ const getBrandByChannel = (channel) => {
};
break;
default:
channel = 1;
break;
}
return _packageAd(params).then(result => {
... ...
... ... @@ -10,7 +10,6 @@ const optModel = require(`${mRoot}/opt`);
const brandModel = require(`${mRoot}/brand`);
const helpers = global.yoho.helpers;
const stringProcess = require(`${global.utils}/string-process`);
const crypto = global.yoho.crypto;
const _ = require('lodash');
/**
... ... @@ -113,7 +112,7 @@ const favoriteBrand = (req, res, next) => {
/* 判断参数是否有效 */
let id = req.body.id,
opt = req.body.opt || 'ok',
uid = req.user.uid || (req.body.uid && parseInt(crypto.decrypt(null, req.body.uid))) || req.cookies.appUid,
uid = req.user.uid || (req.body.uid && parseInt(req.body.uid, 10)) || req.cookies.appUid,
isBrand = req.body.isBrand;
if (!stringProcess.isNumeric(id) || !stringProcess.isNumeric(uid)) {
... ...
... ... @@ -6,12 +6,9 @@
'use strict';
const mRoot = '../models';
const express = require('express');
const app = express();
const plustarModel = require(`${mRoot}/plustar`);
const htmlProcess = require(`${global.utils}/html-process`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
const crypto = global.yoho.crypto;
const _ = require('lodash');
let channels = {
... ... @@ -93,7 +90,7 @@ const getDetailData = (req, res, next) => {
if (isApp) {
if (req.query.uid) {
uid = crypto.encryption('', req.query.uid + '');
uid = req.query.uid;
}
} else {
uid = req.user.uid;
... ... @@ -140,7 +137,7 @@ const getDetailData = (req, res, next) => {
* [品牌详情异步数据]
*/
const getDetailDataAsync = (req, res, next) => {
let uid = req.user.uid;
let uid;
let udid = req.sessionID || 'yoho';
let clientType = req.body.client_type || '';
let brandId = req.body.brand_id || 0;
... ... @@ -148,8 +145,10 @@ const getDetailDataAsync = (req, res, next) => {
if (isApp) {
if (req.body.uid) {
uid = parseInt(crypto.decrypt(null, req.body.uid));
uid = parseInt(req.body.uid, 10);
}
} else {
uid = parseInt(req.user.uid, 10);
}
if (!brandId) {
... ... @@ -160,7 +159,7 @@ const getDetailDataAsync = (req, res, next) => {
isLike: result.isLike,
infos: result.infos
});
});
}).catch(next);
};
module.exports = {
... ...
... ... @@ -7,7 +7,6 @@ const _ = require('lodash');
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
const htmlProcess = require(`${global.utils}/html-process`);
const crypto = global.yoho.crypto;
const imageProcess = require(`${global.utils}/image`);
const privateKeyList = {
... ... @@ -314,7 +313,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
if (isApp) {
url = '?openby:yohobuy={"action":"go.brand","params":{"brand_id":"' + brandId + '","is_different":"' + isDifferent + '"}}';
uid = parseInt(crypto.decrypt(null, uid));
uid = parseInt(uid, 10);
} else {
url = '//' + brandDomain + '.m.yohobuy.com';
}
... ...
... ... @@ -8,7 +8,7 @@ exports.get = (req, res, next) => {
};
return imgCheckAPI.gen().then(result => {
if (result.code === 200) {
if (result.code === 200 && result.data) {
let codeStr = result.data.degrees.reduce((str, rotate) => {
return str.concat((4 - rotate / 90 % 4) % 4);
}, '');
... ...
... ... @@ -285,7 +285,7 @@ const wechat = {
doPassportCallback(openId, nickname, 'wechat', req, res).catch(next);
})(req, res, next);
} else {
return next(new Error('Auth State Mismatch'));
return next('Auth State Mismatch');
}
}
};
... ... @@ -310,7 +310,7 @@ const sina = {
doPassportCallback(openId, nickname, 'sina', req, res).catch(next);
})(req, res, next);
} else {
return next(new Error('Auth State Mismatch'));
return next('Auth State Mismatch');
}
}
};
... ...
... ... @@ -20,7 +20,7 @@ const list = (req, res, next) => {
cartUrl: helpers.urlFormat('/cart/index/index')
}, req.query);
let title = '';
let query = req.query.query ? decodeURIComponent(req.query.query) : '';
let query = req.query.query;
let isQueryFirstClass = false; // 标识用户搜的是不是一级品类
let isQuerySecondClass = false; // 标识用户搜的是不是二级品类
let domain = null;
... ...
... ... @@ -145,7 +145,7 @@ let _getShopsInfo = (brandId) => {
}, {
cache: true
}).then(shops => {
if (shops.code === 200) {
if (shops && shops.code === 200) {
return _processShopsInfo(shops.data);
}
... ... @@ -160,7 +160,7 @@ let _getPromotionInfo = (skn) => {
}, {
cache: true
}).then((result) => {
if (result.code === 200) {
if (result && result.code === 200) {
return result.data;
}
... ... @@ -180,7 +180,7 @@ let _getFavorite = (productId, uid) => {
uid: uid,
id: productId
}).then((result) => {
if (result.code === 200) {
if (result && result.code === 200) {
return result.data;
}
... ... @@ -211,7 +211,7 @@ let getProductData = (data) => {
code: 200,
cache: true
}).then(result => {
if (result.code === 500 || !result.data) {
if (!result || result.code === 500 || !result.data) {
return {};
}
result = result.data;
... ... @@ -418,7 +418,7 @@ const _cartCount = (uid, shoppingKey) => {
uid: uid,
shopping_key: shoppingKey
}).then((result) => {
if (result.code === 200) {
if (result && result.code === 200) {
var count = result.data.cart_goods_count || 0;
if (count > 99) {
... ... @@ -464,7 +464,7 @@ let getNewProductAsyncData = (data) => {
code: 200,
cache: true
}).then(result => {
if (result.code === 500 || !result.data) {
if (!result || result.code === 500 || !result.data) {
return {};
}
result = result.data;
... ... @@ -556,7 +556,7 @@ let getProductAsyncData = (data) => {
code: 200,
cache: true
}).then(result => {
if (result.code === 500 || !result.data) {
if (!result || result.code === 500 || !result.data) {
return {};
}
result = result.data;
... ...
... ... @@ -117,7 +117,7 @@ const _getShopInfo = (shopId, uid) => {
shop_id: shopId,
uid: uid || 0
}, {code: 200}).then((result) => {
return result.data;
return result && result.data;
});
};
... ... @@ -131,7 +131,7 @@ const getShopIntro = (shopId, uid) => {
shop_id: shopId,
uid: uid
}, {code: 200}).then(result => {
return result.data;
return result && result.data;
});
};
... ... @@ -148,7 +148,7 @@ const _getShopCategory = (shopId, channel, gender) => {
gender: gender || '1,3',
shop_id: shopId
}, {code: 200, cache: true}).then(result => {
return result.data;
return result && result.data;
});
};
... ... @@ -711,7 +711,7 @@ const getBrandBanner = (brandId) => {
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
if (result && result.code === 200 && result.data) {
if (result.data.banner) {
return helpers.image(result.data.banner, 640, 150);
} else {
... ... @@ -878,7 +878,7 @@ const shopCouponsList = (params) => {
let shopCoupons = [];
let couPonstatus;
if (result.data) {
if (result && result.data) {
_.forEach(result.data, value => {
couPonstatus = parseInt(value.status, 10);
... ... @@ -919,7 +919,7 @@ const brandCouponsList = (params) => {
let shopCoupons = [];
let couPonstatus;
if (result.data && result.data.coupons) {
if (result && result.data && result.data.coupons) {
_.forEach(result.data.coupons, value => {
couPonstatus = parseInt(value.status, 10);
... ...
... ... @@ -275,7 +275,7 @@ const newDetail = {
code: 200,
cache: true
}).then(result => {
if (result.code === 500 || !result.data) {
if (!result || result.code === 500 || !result.data) {
return {};
}
... ... @@ -359,7 +359,7 @@ const newDetail = {
return api.get('', params, cacheConf)
.then(result => {
if (result.code === 200) {
if (result && result.code === 200) {
return tool.processShopsInfo(result.data);
}
return [];
... ...
... ... @@ -3,7 +3,8 @@ const _ = require('lodash');
// 黑名单参数
const BLACK_LIST = [
'client_secret',
'method'
'method',
'openby:yohobuy'
];
module.exports = () => {
... ...
... ... @@ -8,8 +8,7 @@ var $ = require('yoho-jquery'),
security = require('../../plugin/security'),
tip = require('../../plugin/tip'),
Hammer = require('yoho-hammer'),
dialog = require('../../plugin/dialog'),
Swiper = require('yoho-swiper');
dialog = require('../../plugin/dialog');
var $input = $('#search-input input');
... ... @@ -30,7 +29,7 @@ var writeSearch = require('./write-search');
var ranToken = writeSearch.getRanToken();
var historyval = writeSearch.getHistoryval();
var chHammer, cHammer, navSwiper;
var chHammer, cHammer;
var C_ID, POS_ID, FLR_INDEX, prdLoad, querys, prdids = [];
... ... @@ -212,6 +211,7 @@ $('.search-items .search-group').on('click', 'li', function(event) {
$('.hot-term').on('click', function(event) {
var Hotquery = '';
POS_ID = 2;
FLR_INDEX = 2;
... ... @@ -236,7 +236,7 @@ $('.hot-term').on('click', function(event) {
}
goSearch(Hotquery);
})
});
inputAction();
... ...