index.js
3.98 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
137
138
139
140
141
/**
* 个人中心主页
* @author: shenzm<zhimin.shen@yoho.cn>
* @date: 2016/07/18
*/
'use strict';
const homeModel = require('../models/index');
const _ = require('lodash');
const helpers = global.yoho.helpers;
/**
* 个人中心主页
*/
const component = {
index: (req, res, next) => {
let uid = req.user.uid;
uid = 8050378; // 测试uid
if (!uid && req.xhr) {
return res.json({
code: 400,
message: '抱歉,您暂未登录!'
});
}
homeModel.getUserHomeData(uid).then(data => {
const proData = data[0];
const result = {
module: 'home',
page: 'index',
noLocalJS: true,
noLocalCSS: true,
head_ico: proData && proData.head_ico ? helpers.image(proData.head_ico, 200, 200) : '',
profile_name: proData ? proData.profile_name : '登录/注册',
userinfourl: proData ? '/home/mydetails' : helpers.urlFormat('/signin.html', {
refer: req.originalUrl
}),
serviceUrl: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&'
};
res.render('index', _.merge(result, data[1]));
}).catch(next);
},
mydetails: (req, res) => {
let uid = req.user.uid;
uid = 14459668; // 测试uid
homeModel.getUserProfileData(uid).then(data => {
res.render('mydetails', {
module: 'home',
page: 'mydetails',
head_ico: data && data.head_ico ? helpers.image(data.head_ico, 92, 92) : '',
nickname: '',
gender: data.gender === '1' ? 'men' : 'women',
birthday: data.birthday
});
})
},
help: (req, res, next) => {
homeModel.getHelpInfo().then(helpList => {
res.render('help', {
module: 'home',
page: 'help',
noLocalJS: true,
noLocalCSS: true,
helpList: helpList
});
}).catch(next);
},
helpDetail: (req, res, next) => {
let helpDetailPara = {
code: req.query.code,
caption: req.query.caption
};
homeModel.getHelpDetail(helpDetailPara).then(helpDetail => {
res.render('help-detail', {
module: 'home',
page: 'help',
noLocalJS: true,
noLocalCSS: true,
helpDetail: helpDetail
});
}).catch(next);
},
feedback: (req, res) => {
res.render('feedback', {
module: 'home',
page: 'feedback',
suggestSub: true,
noLocalCSS: true
})
},
saveFeedback: (req, res, next) => {
let saveFeedbackPara = {
uid: '13549737',
content: req.body.content,
suggest_type: 2
};
if (req.user && req.user.uid) {
_.merge(saveFeedbackPara, {
uid: req.user.uid
});
}
if (req.user && req.user.udid && !req.user.uid) {
_.merge(saveFeedbackPara, {
udid: req.user.udid
});
}
homeModel.saveFeedback(saveFeedbackPara).then(result => {
console.log(result);
if (result.code === 200) {
return res.json({
code: 200,
message: '谢谢您的反馈'
});
} else {
return res.json({
code: 400,
message: '保存出错'
});
}
}).catch(next);
},
about: (req, res) => {
res.render('about', {
module: 'home',
page: 'index',
noLocalJS: true,
noLocalCSS: true
});
}
};
module.exports = component;