Authored by xuqi

筛选请求处理

@@ -885,5 +885,52 @@ module.exports = function(flag) { @@ -885,5 +885,52 @@ module.exports = function(flag) {
885 } 885 }
886 ] 886 ]
887 }; 887 };
  888 + case 'search':
  889 + return [
  890 + {
  891 + thumb: 'http://img13.static.yhbimg.com/goodsimg/2015/03/03/08/0244a127c89c1f77ab47f55891e45be1e6.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
  892 + name: 'HALFGIRL 插肩棒球服短裙套装',
  893 + isLike: true,
  894 + price: 478,
  895 + salePrice: 208,
  896 + isSale: true,
  897 + isFew: true,
  898 + isNew: false,
  899 + url: ''
  900 + },
  901 + {
  902 + thumb: 'http://img13.static.yhbimg.com/goodsimg/2015/03/02/08/023f696cf1ae78688bc6c8edeccc480c2c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
  903 + name: 'GAWS DIGI 丛林数码印花拼接卫衣',
  904 + isLike: false,
  905 + price: 1268,
  906 + salePrice: 589,
  907 + isSale: true,
  908 + isFew: true,
  909 + isNew: false,
  910 + url: ''
  911 + },
  912 + {
  913 + thumb: 'http://img10.static.yhbimg.com/goodsimg/2015/01/08/07/012f23fc2390ccd634082d34cc2982bf4c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
  914 + name: 'CLOTtee 撞色连帽外套',
  915 + isLike: false,
  916 + price: 488,
  917 + salePrice: 139,
  918 + isSale: true,
  919 + isFew: true,
  920 + isNew: false,
  921 + url: ''
  922 + },
  923 + {
  924 + thumb: 'http://img11.static.yhbimg.com/goodsimg/2015/03/02/09/0139514beb37bf2bf321eafd1a915117f5.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
  925 + name: '黄伟文Wyman X yohood联名商品YYYOHOOD连帽卫衣',
  926 + isLike: false,
  927 + price: 589,
  928 + salePrice: 148,
  929 + isSale: false,
  930 + isFew: false,
  931 + isNew: true,
  932 + url: ''
  933 + }
  934 + ];
888 } 935 }
889 }; 936 };
@@ -14,4 +14,7 @@ module.exports = function(app) { @@ -14,4 +14,7 @@ module.exports = function(app) {
14 app.get('/tag', tag.show); //标签页 14 app.get('/tag', tag.show); //标签页
15 15
16 app.get('/tpl', template.show); //模板页 16 app.get('/tpl', template.show); //模板页
  17 + app.get('/tpl/readTpl', template.readTpl); //读取模板
  18 + app.get('/tpl/classification', template.readClassification); //读取分类数据
  19 + app.get('/tpl/search', template.search); //筛选查询
17 }; 20 };
@@ -3,7 +3,13 @@ @@ -3,7 +3,13 @@
3 * @author: xuqi(qi.xu@yoho.cn) 3 * @author: xuqi(qi.xu@yoho.cn)
4 * @date: 2015/4/14 4 * @date: 2015/4/14
5 */ 5 */
6 -var data = require('../../public/js/data')('tpl'); 6 +var datas = require('../../public/js/data'),
  7 + data = datas('tpl'),
  8 + classification = datas('classification'),
  9 + search = datas('search'),
  10 + fs = require('fs'),
  11 + path = require('path'),
  12 + tplPath = path.normalize(path.join(__dirname, '../partials/common/good-info.html'));;
7 13
8 exports.show = function(req, res) { 14 exports.show = function(req, res) {
9 res.render('pages/template', { 15 res.render('pages/template', {
@@ -12,4 +18,36 @@ exports.show = function(req, res) { @@ -12,4 +18,36 @@ exports.show = function(req, res) {
12 css: '../css/template.css', 18 css: '../css/template.css',
13 usejs: 'template/footer' 19 usejs: 'template/footer'
14 }); 20 });
  21 +};
  22 +
  23 +exports.readTpl = function(req, res) {
  24 + fs.readFile(tplPath, 'utf8', function(err, data) {
  25 + if (err) {
  26 + res.send({
  27 + success: false
  28 + });
  29 + }
  30 +
  31 + res.send({
  32 + success: true,
  33 + data: data
  34 + });
  35 + });
  36 +};
  37 +
  38 +exports.readClassification = function(req, res) {
  39 + res.send({
  40 + success: true,
  41 + data: classification
  42 + });
  43 +};
  44 +
  45 +exports.search = function(req, res) {
  46 + res.send({
  47 + success: true,
  48 + data: {
  49 + end: false, //数据是否结束
  50 + goods: search //商品数据
  51 + }
  52 + });
15 }; 53 };