二十:首页 后端接口数据完整代码

144 阅读1分钟

后端接口数据完整代码:

var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
        res.render('index', {
                title: 'Express'
        });
});

router.get('/api/index_list/data', function(req, res, next) {
        res.send({
                "code": 0,
                "data": {
                        topBar: [{
                                        id: '1',
                                        name: '推荐'
                                },
                                {
                                        id: '2',
                                        name: '户外运动'
                                },
                                {
                                        id: '3',
                                        name: '服饰内衣'
                                },
                                {
                                        id: '4',
                                        name: '鞋子箱包'
                                },
                                {
                                        id: '5',
                                        name: '美妆护肤'
                                },
                                {
                                        id: '6',
                                        name: '家具数码'
                                },
                                {
                                        id: '7',
                                        name: '食品母婴'
                                },
                        ],
                        data: [{
                                        type: 'swiperList',
                                        swiperList: [{
                                                        imgUrl: '../../static/img/swiper-1.png'
                                                },
                                                {
                                                        imgUrl: '../../static/img/swiper-2.png'
                                                },
                                                {
                                                        imgUrl: '../../static/img/swiper-3.png'
                                                },
                                        ],
                                },
                                {
                                        type: 'recommendedList',
                                        recommendedList: [{
                                                bigUrl: '../../static/img/recommended-big.png',
                                                data: [{
                                                                imgUrl: '../../static/img/recommended-1.png'
                                                        },
                                                        {
                                                                imgUrl: '../../static/img/recommended-2.png'
                                                        },
                                                        {
                                                                imgUrl: '../../static/img/recommended-3.png'
                                                        }
                                                ]
                                        }]
                                },
                                {
                                        type: 'commodityList',
                                        commodityList: [{
                                                        id: 1,
                                                        img: '../../static/img/commondity.png',
                                                        name: '爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试',
                                                        pprice: '299',
                                                        oprice: '699',
                                                        discount: '5.5'
                                                },
                                                {
                                                        id: 2,
                                                        img: '../../static/img/commondity.png',
                                                        name: '爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试',
                                                        pprice: '269',
                                                        oprice: '699',
                                                        discount: '5.5'
                                                },
                                                {
                                                        id: 3,
                                                        img: '../../static/img/commondity.png',
                                                        name: '爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试爆款商品测试',
                                                        pprice: '289',
                                                        oprice: '688',
                                                        discount: '5.5'
                                                }
                                        ]
                                },
                        ]
                }
        });
});

module.exports = router;