user.js
3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/**
* 个人中心---编辑个人资料
* @author gaohongwei <hongwei.gao@yoho.cn>
* @date: 2016/8/16
*/
'use strict';
const mRoot = '../models';
const userService = require(`${mRoot}/user-service`); // user 页 model
const helpers = global.yoho.helpers;
/**
* 个人中心
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res, next) => {
// if (!req.user.uid) {
// res.redirect(helpers.urlFormat('/signin.html'));
// }
let uid = '20001048';
let responseData = {
module: 'home',
page: 'user'
};
// 真实数据输出
userService.getUserInfo(uid).then(result => {
responseData.user = result;
res.render('home/user/index', responseData);
}).catch(next);
};
/**
* 编辑会员信息
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.editUserInfo = (req, res, next) => {
if (!req.user.uid) {
res.redirect(helpers.urlFormat('/signin.html'));
}
let uid = req.user.uid;
// 真实数据输出
userService.editUserInfo(req, uid).then(result => {
res.json(result);
}).catch(next);
};
/**
* 编辑联系信息
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.editUserContactInfo = (req, res, next) => {
if (!req.user.uid) {
res.redirect(helpers.urlFormat('/signin.html'));
}
let uid = req.user.uid;
// 真实数据输出
userService.editUserContactInfo(req, uid).then(result => {
res.json(result);
}).catch(next);
};
/**
* 编辑购物着装、习惯
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.editUserHabitsInfo = (req, res, next) => {
if (!req.user.uid) {
res.redirect(helpers.urlFormat('/signin.html'));
}
let uid = req.user.uid;
// 真实数据输出
userService.editUserHabitsInfo(req, uid).then(result => {
res.json(result);
}).catch(next);
};
/**
* 编辑喜爱品牌
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.editUserLikeBrand = (req, res, next) => {
if (!req.user.uid) {
res.redirect(helpers.urlFormat('/signin.html'));
}
let uid = req.user.uid;
// 真实数据输出
userService.editUserLikeBrand(req, uid).then(result => {
res.json(result);
}).catch(next);
};
/**
* 是否在品牌库
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.isBrandName = (req, res, next) => {
// 真实数据输出
userService.isBrandName(req).then(result => {
res.json(result);
}).catch(next);
};
exports.getProviceList = (req, res, next) => {
// 真实数据输出
userService.getProviceList(req.query.id).then(result => {
res.json(result);
}).catch(next);
};