Authored by ccbikai(👎🏻🍜)

个性化商品

... ... @@ -8,38 +8,53 @@ const channels = {
};
exports.productLst = function(req, res, next) {
let keys = ['sort', 'misort', 'msort', 'gender', 'brand'],
params = {
uid: req.user.uid || req.query.uid,
udid: req.query.udid,
promotion: req.query.pid,
let uid = req.user.uid || req.query.uid;
let udid = req.query.udid;
let getProductList;
if (req.query.maybeLike) {
getProductList = model.maybeLikeList(Object.assign({
uid: uid,
udid: udid,
yh_channel: req.query.yh_channel || (req.cookies._Channel && channels[req.cookies._Channel]) || 1,
specified_sort: req.query.enum,
stocknumber: req.query.sn,
p_d: req.query.pd,
noDup: req.query.noDup,
limit: req.query.limit || 10
};
limit: req.query.limit || 12
}, req.query));
} else {
let keys = ['sort', 'misort', 'msort', 'gender', 'brand'],
params = {
uid: uid,
udid: udid,
promotion: req.query.pid,
yh_channel: req.query.yh_channel || (req.cookies._Channel && channels[req.cookies._Channel]) || 1,
specified_sort: req.query.enum,
stocknumber: req.query.sn,
p_d: req.query.pd,
noDup: req.query.noDup,
limit: req.query.limit || 10
};
keys.forEach(function(k) {
if (req.query[k]) {
params[k] = req.query[k];
}
});
keys.forEach(function(k) {
if (req.query[k]) {
params[k] = req.query[k];
}
});
if (params.specified_sort) {
if (params.brand) {
params.limit = params.brand.split(',').length;
} else if (params.sort) {
params.limit = params.sort.split(',').length;
} else if (params.misort) {
params.limit = params.misort.split(',').length;
} else if (params.msort) {
params.limit = params.msort.split(',').length;
if (params.specified_sort) {
if (params.brand) {
params.limit = params.brand.split(',').length;
} else if (params.sort) {
params.limit = params.sort.split(',').length;
} else if (params.misort) {
params.limit = params.misort.split(',').length;
} else if (params.msort) {
params.limit = params.msort.split(',').length;
}
}
getProductList = model.productLst(params);
}
model.productLst(params).then((result) => {
getProductList.then((result) => {
res.jsonp(result);
}).catch(next);
};
... ...
... ... @@ -67,6 +67,13 @@ module.exports = {
f.component[0].type === 'productGroup' && f.component[0].defaultSkns) {
sknsArr.push(_getProductBySkns(f.component[0]));
}
if (f.component && f.component[0] &&
f.component[0].type === 'productGroup' && f.component[0].favourite_prds_enable === '1') {
f.component[0].searchCondition = Object.assign(f.component[0].searchCondition || {}, {
maybeLike: 1
});
}
});
}
... ...
... ... @@ -39,5 +39,24 @@ module.exports = {
});
return data;
});
},
maybeLikeList: function(params) {
return api.get('', {
method: 'app.search.newLast7day',
uid: params.uid || 0,
udid: params.udid || 0,
yh_channel: params.yh_channel,
need_filter: 'null'
}, {
cache: true
}).then(res => {
var data = [],
lst = (res && res.data && res.data.product_list) || [];
lst.forEach(function(o) {
o && data.push(_getProduct(o));
});
return data;
});
}
};
... ...
... ... @@ -11,16 +11,12 @@ const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const domains = {
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://dev-api.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
global: 'http://api-global.yohobuy.com',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
global: 'http://global-test-soa.yohops.com:9999',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api'
};
... ...