user.js 1.74 KB
/**
 * 个人中心---编辑个人资料
 * @author gaohongwei <hongwei.gao@yoho.cn>
 * @date: 2016/8/16
 */
'use strict';

const mRoot = '../models';
const userService = require(`${mRoot}/user-service`); // user  model

/**
 * 个人中心
 * @param  {[type]} req [description]
 * @param  {[type]} res [description]
 * @return {[type]}     [description]
 */
exports.index = (req, res, next) => {
    let channel = req.query.channel || req.cookies._Channel || 'boys';

    let uid = '8039836';

    let responseData = {
        module: 'home',
        page: 'user'
    };

    // 真实数据输出
    userService.getUserInfo(channel, uid).then(result => {
        responseData.user = result;
        responseData.headerData = result.headerData;
        res.render('home/user/index', responseData);
    }).catch(next);

};

/**
 * 编辑会员信息
 * @param  {[type]} req [description]
 * @param  {[type]} res [description]
 * @return {[type]}     [description]
 */
exports.editUserInfo = (req, res, next) => {

    let uid = '8039836';

    // 真实数据输出
    userService.editUserInfo(req, uid).then().catch(next);

};

/**
 * 编辑联系信息
 * @param  {[type]} req [description]
 * @param  {[type]} res [description]
 * @return {[type]}     [description]
 */
exports.editUserContactInfo = (req, res, next) => {

    let uid = '8039836';

    // 真实数据输出
    userService.editUserContactInfo(req, uid).then().catch(next);

};

/**
 * 编辑购物着装、习惯
 * @param  {[type]} req [description]
 * @param  {[type]} res [description]
 * @return {[type]}     [description]
 */
exports.editUserHabitsInfo = (req, res, next) => {

    let uid = '8039836';

    // 真实数据输出
    userService.editUserHabitsInfo(req, uid).then().catch(next);

};