Authored by lijing

浏览历史

... ... @@ -72,7 +72,7 @@ exports.myDetails = (req, res, next) => {
* @param next
*/
exports.record = (req, res, next) => {
exports.record = (req, res) => {
let headerData = headerModel.setNav({
navTitle: '浏览记录'
... ... @@ -83,18 +83,36 @@ exports.record = (req, res, next) => {
module: 'home',
page: 'browse-record',
title: '浏览记录',
browseRecordPage: true,
pageFooter: true
};
res.render('browse-record', responseData);
indexModel.record({
};
}).then(result => {
console.log(Object.assign(responseData, result));
res.render('browse-record', Object.assign(responseData, result));
}).catch(next);
exports.recordContent = (req, res, next) => {
let uid = req.user.uid || 6228593; // TODO
let udid = req.user.udid;
let page = req.query.page || 1;
let limit = 10;
indexModel.recordContent(uid, udid, page, limit).then((result) => {
res.render('browse-record-content', result);
}).catch(next);
};
exports.delRecord = (req, res, next) => {
let uid = req.user.uid || 6228593; // TODO
let skn = req.user.skn || 0;
indexModel.delRecord(uid, skn).then((result) => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -144,49 +144,73 @@ const myDetails = (params) => {
});
};
/**
* 浏览记录
* @param params
*/
const record = (params) => {
const recordContent = (uid, udid, page, limit) => {
return api.get('', {
method: 'app.browse.product',
uid: params.uid || 6228593,
limit: 100,
page: 1
uid: uid || 6228593, // TODO
limit: limit,
page: page
}, {code: 200}).then((result) => {
let resu = {
recordResult: []
browseRecord: []
};
if (result && result.code === 200) {
let list = result;
// 不能再查到结果了
if (page > 1 && list === []) {
resu.noRecord = true;
}
if (result.data.total === 0) {
resu.total = 0;
}
_.forEach(list.data.product_list, function(val) {
let obj = {
productList: []
};
_.forEach(result.data.product_list, function(val) {
let obj = {};
obj = _.assign(obj, {
product_name: val.product_name,
product_skn: val.product_skn,
invalidGoods: val.status === 0,
storage: val.storage
storage: val.storage,
image: val.image,
link: '/product/show_' + val.product_skn + '.html',
sales_price: val.sales_price,
market_price: (val.market_price - val.sales_price) > 0 ? val.market_price : false,
invalidGoods: val.status === 0
});
resu.recordResult.push(obj);
resu.browseRecord.push(obj);
});
return resu;
}
// console.log(resu);
return resu;
});
};
const delRecord = (uid, skn) => {
return api.get('', {
method: 'app.browse.delete',
uid: uid,
skn: skn
});
};
module.exports = {
index,
myDetails,
record
recordContent,
delRecord
};
... ...
... ... @@ -42,6 +42,8 @@ router.get('/cancelOrder', orderDetailController.cancelOrder); // 取消订单
router.get('/', homeController.index); // 个人中心首页
router.get('/mydetails', homeController.myDetails); // 个人基本资料页面
router.get('/record', homeController.record); // 浏览记录
router.get('/recordContent', homeController.recordContent); // 浏览记录
router.get('/delRecord', homeController.delRecord); // 删除浏览记录
// 我的收藏
router.get('/favorite', favorite.favorite);
... ...
{{# browseRecord}}
<a class="browse-record-good clearfix {{#if invalidGoods}}invalidGoods{{/if}}" data-skn="{{product_skn}}" href="{{link}}">
<img class="thumb lazy" data-original="{{image}}">
<img class="thumb lazy" data-original="{{image image 447 596}}">
<div class="deps clearfix">
<p class="name row">{{product_name}}</p>
<p class="price row">
... ...
<div class="browse-record-page yoho-page">
<div class="records">
{{# browseRecord}}
<a class="browse-record-good clearfix {{#if invalidGoods}}invalidGoods{{/if}}" data-skn="{{product_skn}}" href="{{link}}">
<img class="thumb lazy" data-original="{{image}}">
<div class="deps clearfix">
<p class="name row">{{product_name}}</p>
<p class="price row">
<span class="sale-price{{#unless market_price}} original-price{{/unless}}">¥{{sales_price}}</span>
&nbsp;&nbsp;
{{#if market_price}}
<span class="market-price">¥{{market_price}}</span>
{{/if}}
</p>
<p class="sold-out row">
{{#unless storage}}
<span class="sold-out-tag">已售罄</span>
{{/unless}}
</p>
<span class="iconfont del-icon">&#xe621;</span>
</div>
</a>
{{/ browseRecord}}
{{#if noRecord}}
<div class="no-record">
<div class="icon"></div>
<span>暂无浏览记录</span>
<a class="walk-way" href="{{walkwayUrl}}">随便逛逛</a>
</div>
{{/if}}
</div>
<div class="load-more hide">
<span class="more">正在加载...</span>
... ...