Authored by wenjiekong

添加userjs

... ... @@ -4,13 +4,12 @@
*/
'use strict';
const cookie = global.yoho.cookie;
const logger = global.yoho.logger;
const consultModel = require('../models/consult');
exports.index = (req, res, next) => {
const uid = cookie.getUid(req);
const uid = req.user.uid;
const page = req.query.page || 1;
consultModel.consultList(uid, page /* ,limit=10*/)
... ...
... ... @@ -7,6 +7,7 @@
const path = require('path');
const Promise = require('bluebird');
const moment = require('moment');
const _ = require('lodash');
const imgUtils = require(path.join(global.utils, 'images'));
const api = global.yoho.API;
const searchApi = global.yoho.SearchAPI;
... ... @@ -32,6 +33,14 @@ function getProductGoodsInfo(skns) {
data: {
query: query
}
}).then(result => {
let resData = {};
_.forEach(_.get(result, 'data.product_list', []), good => {
resData[good.product_skn] = good;
});
return resData;
});
}
... ... @@ -49,10 +58,9 @@ exports.consultList = (uid, page, limit) => {
};
const fetchConsults = co(function*(params) {
let res = yield api.get('', {
method: 'web.personCen.buyConsult',
data: params
});
let res = yield api.get('', Object.assign({
method: 'web.personCen.buyConsult'
}, params));
return res;
});
... ... @@ -68,7 +76,7 @@ exports.consultList = (uid, page, limit) => {
const skns = [];
if (res.code === 200 && origin && origin.consult_list.length) {
if (res.code === 200 && origin && origin.consult_list && origin.consult_list.length) {
origin.consult_list.forEach(consult => {
skns.push(consult.skn);
});
... ...
... ... @@ -11,7 +11,6 @@ const cRoot = './controllers';
const headerModel = require('../../doraemon/models/header');
const _ = require('lodash');
const helpers = global.yoho.helpers;
// const config = global.yoho.config;
const commentController = require(`${cRoot}/comment`);
... ...
... ... @@ -7,7 +7,7 @@ module.exports = () => {
if (req.session && _.isNumber(req.session._LOGIN_UID)) {
req.user.uid = req.session._LOGIN_UID;
}
req.user.uid = 11993475;
// session 没有读取到的时候,从 cookie 读取 UID
if (!req.user.uid && req.cookies._UID) {
req.user.uid = cookie.getUid(req);
... ...