template.js
1.13 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
/**
* 模板页控制器文件
* @author: xuqi(qi.xu@yoho.cn)
* @date: 2015/4/14
*/
var datas = require('../../public/js/data'),
data = datas('tpl'),
classification = datas('classification'),
search = datas('search'),
fs = require('fs'),
path = require('path'),
tplPath = path.normalize(path.join(__dirname, '../partials/common/good-info.html'));;
exports.show = function(req, res) {
res.render('pages/template', {
data: data,
layout: '../layouts/layout',
isTemplate: true
});
};
exports.readTpl = function(req, res) {
fs.readFile(tplPath, 'utf8', function(err, data) {
if (err) {
res.send({
success: false
});
}
res.send({
success: true,
data: data
});
});
};
exports.readClassification = function(req, res) {
res.send({
success: true,
data: classification
});
};
exports.search = function(req, res) {
res.send({
success: true,
data: {
end: false, //数据是否结束
goods: search //商品数据
}
});
};