index.js
1.97 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
/**
* 个人中心 controller
* @author: chengyao.guo<chengyao.guo@yoho.cn>
* @date: 2016/08/10
*/
'use strict';
const headerModel = require('../../../doraemon/models/header'); // 头部model
const indexModel = require('../models/index');
/**
* 用户中心首页
* @param req
* @param res
* @param next
*/
exports.index = (req, res, next) => {
let params = {
uid: req.user.uid
};
let headerData = headerModel.setNav({
navTitle: '个人中心'
});
indexModel.index(params).then(result => {
if (result) {
res.render('index', Object.assign(result, {
isLogin: params.uid ? true : false,
module: 'home',
page: 'index',
title: 'Yoho!Buy 有货',
pageHeader: headerData,
pageFooter: true
}));
}
}).catch(next);
};
/**
* 个人基本资料页面
* @param req
* @param res
* @param next
*/
exports.myDetails = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '基本资料'
});
let responseData = {
pageHeader: headerData,
module: 'home',
page: 'personal-details',
title: '基本资料',
pageFooter: true
};
indexModel.myDetails({
}).then(result => {
res.render('personal-details', Object.assign(responseData, result));
}).catch(next);
};
/**
* 浏览记录
* @param req
* @param res
* @param next
*/
exports.record = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '浏览记录'
});
let responseData = {
pageHeader: headerData,
module: 'home',
page: 'browse-record',
title: '浏览记录',
pageFooter: true
};
indexModel.record({
}).then(result => {
console.log(Object.assign(responseData, result));
res.render('browse-record', Object.assign(responseData, result));
}).catch(next);
};