Authored by 郭成尧

guang-fav

... ... @@ -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';
}
... ...
... ... @@ -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 [];
... ...