...
|
...
|
@@ -4,6 +4,7 @@ |
|
|
* @date: 2016/07/18
|
|
|
*/
|
|
|
'use strict';
|
|
|
const homeModel = require('../models/index');
|
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
...
|
...
|
@@ -12,20 +13,95 @@ const helpers = global.yoho.helpers; |
|
|
*/
|
|
|
const component = {
|
|
|
index: (req, res, next) => {
|
|
|
var testData = {
|
|
|
isLogin: false,
|
|
|
head_ico: '',
|
|
|
profile_name: 'XXX',
|
|
|
signinUrl: '/home',
|
|
|
wait_pay_num: 1,
|
|
|
wait_cargo_num: 2,
|
|
|
send_cargo_num: 3
|
|
|
let uid = req.user.uid;
|
|
|
if (!uid && req.xhr) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: '抱歉,您暂未登录!'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
homeModel.getUserHomeData(uid).then(data => {
|
|
|
let result = {
|
|
|
module: 'home',
|
|
|
page: 'index',
|
|
|
head_ico: uid ? '' : '',
|
|
|
profile_name: uid ? 'James Sen' : '登录/注册',
|
|
|
userinfourl: uid ? '/home/mydetails' : helpers.urlFormat('/signin.html', {
|
|
|
refer: req.originalUrl
|
|
|
}),
|
|
|
};
|
|
|
|
|
|
res.render('index', _.merge(result, data[1]));
|
|
|
}).catch(next);
|
|
|
},
|
|
|
help: (req, res, next) => {
|
|
|
homeModel.getHelpInfo().then(helpList => {
|
|
|
res.render('help', {
|
|
|
module: 'home',
|
|
|
page: 'help',
|
|
|
helpList: helpList
|
|
|
});
|
|
|
}).catch(next);
|
|
|
},
|
|
|
|
|
|
helpDetail: (req, res, next) => {
|
|
|
var helpDetailPara = {
|
|
|
code: req.query.code,
|
|
|
caption: req.query.caption
|
|
|
};
|
|
|
res.render('index', _.merge({
|
|
|
|
|
|
homeModel.getHelpDetail(helpDetailPara).then(helpDetail => {
|
|
|
res.render('help-detail', {
|
|
|
module: 'home',
|
|
|
page: 'help',
|
|
|
helpDetail: helpDetail
|
|
|
});
|
|
|
}).catch(next);
|
|
|
},
|
|
|
favorite: (req, res, next) => {
|
|
|
let tab = req.query.tab;
|
|
|
let testData = {
|
|
|
brandUrl: helpers.urlFormat('/product/new'),
|
|
|
productUrl: helpers.urlFormat('/product/new')
|
|
|
}
|
|
|
res.render('favorite', _.merge({
|
|
|
module: 'home',
|
|
|
page: 'index'
|
|
|
page: 'favorite',
|
|
|
}, testData));
|
|
|
},
|
|
|
favpaging: (req, res, next) => {
|
|
|
let tab = req.query.tab;
|
|
|
let page = req.query.page;
|
|
|
|
|
|
console.log("page: " + page);
|
|
|
|
|
|
if (tab === 'brand') {
|
|
|
|
|
|
}
|
|
|
|
|
|
if (page > 3) return res.json([]);
|
|
|
|
|
|
let testData = []
|
|
|
for (var i = 1; i <= 9; i++) {
|
|
|
testData.push({
|
|
|
fav_id: Number(page + i),
|
|
|
title: "商品名测试测试测试测试测试测试测试测试" + Number(page + i),
|
|
|
invalidGoods: true,
|
|
|
discountPrice: '¥' + 900,
|
|
|
price: '¥' + 990
|
|
|
})
|
|
|
}
|
|
|
|
|
|
return res.json(testData);
|
|
|
},
|
|
|
favdel: (req, res, next) => {
|
|
|
let id = req.body.id;
|
|
|
|
|
|
return res.json({
|
|
|
code: 200
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = component; |
|
|
module.exports = component; |
|
|
\ No newline at end of file |
...
|
...
|
|