index.js
1.27 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
/**
* 购物车
* @author: feng.chen<feng.chen@yoho.cn>
* @date: 2016/12/21
*/
'use strict';
const helpers = global.yoho.helpers;
const headerModel = require('../../../doraemon/models/header'); // 头部model
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
const indexModel = require('../models/index');
let index = (req, res, next) => {
let isLogin = req.user && req.user.uid,
pageData = {
isLogin,
signurl: helpers.urlFormat('/signin.html', {
refer: '/cart/index/index'
})
};
res.render('index', Object.assign(pageData, {
title: '购物车',
module: 'cart',
page: 'index',
localCss: true,
width750: true,
pageHeader: headerModel.setNav({
navTitle: '购物车',
backUrl: '/product/show_.html'
}),
pageFooter: true,
}));
};
let indexData = (req, res, next) => {
if (!req.xhr) {
return next();
}
let shoppingKey = req.cookies._SPK || '',
channel = req.cookies._Channel;
return indexModel.indexData(8040155, 'dc9d09e2ffd8607f2cfd8b9c95962923', channel).then(data => {
res.json(data);
}).catch(next);
}
module.exports = {
index,
indexData
};