|
|
/**
|
|
|
* 主页
|
|
|
* 个人中心主页
|
|
|
* @author: shenzm<zhimin.shen@yoho.cn>
|
|
|
* @date: 2016/07/18
|
|
|
*/
|
...
|
...
|
@@ -14,6 +14,8 @@ 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,
|
...
|
...
|
@@ -22,16 +24,16 @@ const component = { |
|
|
}
|
|
|
|
|
|
homeModel.getUserHomeData(uid).then(data => {
|
|
|
const proData = data[0];
|
|
|
let result = {
|
|
|
module: 'home',
|
|
|
page: 'index',
|
|
|
head_ico: uid ? '' : '',
|
|
|
profile_name: uid ? 'James Sen' : '登录/注册',
|
|
|
head_ico: proData.head_ico ? helpers.image(proData.head_ico, 200, 200) : '',
|
|
|
profile_name: uid ? proData.profile_name : '登录/注册',
|
|
|
userinfourl: uid ? '/home/mydetails' : helpers.urlFormat('/signin.html', {
|
|
|
refer: req.originalUrl
|
|
|
}),
|
|
|
};
|
|
|
|
|
|
res.render('index', _.merge(result, data[1]));
|
|
|
}).catch(next);
|
|
|
},
|
...
|
...
|
@@ -44,9 +46,8 @@ const component = { |
|
|
});
|
|
|
}).catch(next);
|
|
|
},
|
|
|
|
|
|
helpDetail: (req, res, next) => {
|
|
|
var helpDetailPara = {
|
|
|
let helpDetailPara = {
|
|
|
code: req.query.code,
|
|
|
caption: req.query.caption
|
|
|
};
|
...
|
...
|
@@ -59,7 +60,6 @@ const component = { |
|
|
});
|
|
|
}).catch(next);
|
|
|
},
|
|
|
|
|
|
feedback: (req, res, next) => {
|
|
|
res.render('feedback', {
|
|
|
module: 'home',
|
...
|
...
|
@@ -67,7 +67,6 @@ const component = { |
|
|
suggestSub: true,
|
|
|
}).catch(next);
|
|
|
},
|
|
|
|
|
|
saveFeedback: (req, res, next) => {
|
|
|
let saveFeedbackPara = {
|
|
|
uid: '13549737',
|
...
|
...
|
@@ -103,63 +102,99 @@ const component = { |
|
|
}
|
|
|
}).catch(next);
|
|
|
},
|
|
|
|
|
|
favorite: (req, res, next) => {
|
|
|
let tab = req.query.tab;
|
|
|
let testData = {
|
|
|
brandUrl: helpers.urlFormat('/product/new'),
|
|
|
productUrl: helpers.urlFormat('/product/new')
|
|
|
};
|
|
|
|
|
|
if (tab === 'brand') {
|
|
|
res.render('favorite-brand', _.merge({
|
|
|
if (req.query.tab === 'brand') {
|
|
|
res.render('favorite-brand', {
|
|
|
module: 'home',
|
|
|
page: 'favorite-brand',
|
|
|
}, testData));
|
|
|
brandUrl: helpers.urlFormat('/product/new')
|
|
|
});
|
|
|
} else {
|
|
|
res.render('favorite', _.merge({
|
|
|
res.render('favorite', {
|
|
|
module: 'home',
|
|
|
page: 'favorite',
|
|
|
}, testData));
|
|
|
productUrl: helpers.urlFormat('/product/new')
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
favpaging: (req, res, next) => {
|
|
|
let tab = req.query.tab;
|
|
|
let page = req.query.page;
|
|
|
|
|
|
if (page > 2) return res.json([]);
|
|
|
|
|
|
let testData = [];
|
|
|
for (var i = 1; i <= 9; i++) {
|
|
|
if (tab === 'brand') {
|
|
|
testData.push({
|
|
|
fav_id: Number(page + i),
|
|
|
brandName: '品牌名测试' + Number(page + i),
|
|
|
invalidGoods: true
|
|
|
let uid = req.user.uid;
|
|
|
uid = 20000134; // 测试uid
|
|
|
|
|
|
const tab = req.query.tab;
|
|
|
const page = req.query.page;
|
|
|
const result = [];
|
|
|
let isend = true;
|
|
|
|
|
|
if (tab === 'brand') {
|
|
|
const gender = '1,2,3'; // todo 获取频道的性别
|
|
|
homeModel.getFavBrandData(uid, gender, page, 10).then(data => {
|
|
|
if (data && page <= data.page_total) {
|
|
|
data.brand_list.forEach(function(d) {
|
|
|
result.push({
|
|
|
fav_id: d.brand_id,
|
|
|
link: "", // todo
|
|
|
imgUrl: d.brand_ico ? helpers.image(d.brand_ico, 160, 125) : '',
|
|
|
brandName: d.brand_name,
|
|
|
down: d.status == 0
|
|
|
})
|
|
|
});
|
|
|
|
|
|
if (page < data.page_total) {
|
|
|
isend = false;
|
|
|
}
|
|
|
}
|
|
|
return res.json({
|
|
|
isend: isend,
|
|
|
list: result
|
|
|
});
|
|
|
} else {
|
|
|
testData.push({
|
|
|
fav_id: Number(page + i),
|
|
|
title: '商品名测试测试测试测试测试测试测试测试' + Number(page + i),
|
|
|
invalidGoods: true,
|
|
|
discountPrice: '¥' + 900,
|
|
|
price: '¥' + 990
|
|
|
});
|
|
|
} else {
|
|
|
homeModel.getFavProductData(uid, page, 10).then(data => {
|
|
|
if (data && page <= data.page_total) {
|
|
|
data.product_list.forEach(function(d) {
|
|
|
if (!d.product_skn) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let link = '';
|
|
|
if (d.goodsId && d.cnAlphabet) {
|
|
|
link = helpers.urlFormat(`/product/pro_${d.product_id}_${d.goodsId}/${d.cnAlphabet}.html`);
|
|
|
}
|
|
|
|
|
|
result.push({
|
|
|
fav_id: d.product_id,
|
|
|
link: link,
|
|
|
imgUrl: d.image ? helpers.image(d.image) : '',
|
|
|
title: d.product_name,
|
|
|
price: '¥' + Number(d.market_price).toFixed(2),
|
|
|
discountPrice: (Number(d.market_price) - Number(d.sales_price) > 0) ? '¥' + Number(d.sales_price).toFixed(2) : false,
|
|
|
sellOut: d.storage < 0,
|
|
|
invalidGoods: d.status == 0
|
|
|
})
|
|
|
});
|
|
|
|
|
|
if (page < data.page_total) {
|
|
|
isend = false;
|
|
|
}
|
|
|
}
|
|
|
return res.json({
|
|
|
isend: isend,
|
|
|
list: result
|
|
|
});
|
|
|
}
|
|
|
}).catch(next);
|
|
|
}
|
|
|
|
|
|
return res.json(testData);
|
|
|
},
|
|
|
|
|
|
favdel: (req, res, next) => {
|
|
|
let id = req.body.id;
|
|
|
let uid = req.user.uid;
|
|
|
uid = 20000134; // 测试uid
|
|
|
|
|
|
return res.json({
|
|
|
code: 200
|
|
|
});
|
|
|
const favId = req.body.favId;
|
|
|
const type = req.body.type;
|
|
|
homeModel.favoriteDelete(uid, favId, type).then(data => {
|
|
|
return res.json(data);
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 关于我们
|
|
|
aboutUs: (req, res, next) => {
|
|
|
res.render('about-us', {
|
...
|
...
|
@@ -169,4 +204,4 @@ const component = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = component; |
|
|
module.exports = component; |
|
|
\ No newline at end of file |
...
|
...
|
|