material.js 1.19 KB

'use strict';

const materialModel = require('../models/material');
const headerModel = require('../../../doraemon/models/header'); // 头部model

exports.list = (req, res, next) => {
    let responseData = {
        pageHeader: headerModel.setNav({
            navTitle: '商品素材列表页',
        }),
        title: '商品素材列表页',
        module: '3party',
        page: 'material',
        width750: true,
        localCss: true
    };

    let params = {
        uid: req.user.uid,
        page: 1,
        isApp: req.yoho.isApp,
        unionType: req.query.union_type
    };

    req.ctx(materialModel).canLogin(params).then(result => {
        if (result === 'N') {
            return next();
        } else {
            req.ctx(materialModel).list(params).then(list => {
                res.render('material', Object.assign(responseData, list));
            }).catch(next);
        }
    }).catch(next);
};

exports.moreGoods = (req, res, next) => {
    let params = {
        page: req.query.page || 2,
        isApp: req.yoho.isApp,
        unionType: req.query.union_type
    };

    req.ctx(materialModel).list(params).then(result => {
        res.json(result);
    }).catch(next);
};