feature.js 1.34 KB
'use strict';
const model = require('../models/feature');

exports.index = function(req, res, next) {
    model.index({
        code: req.params.code,
        type: req.query.type
    }).then((result) => {
        if (!result) {
            return next();
        }
        let title = req.query.title || result.name || '专题活动';

        // 唤起 APP 的路径
        res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.h5","params":{"param":{"share_id":"${req.query.share_id}","title":"${title}"},"share":"/operations/api/v5/webshare/getShare","shareparam":{"share_id":"${req.query.share_id}"},"title":"${title}","url":"https://activity.yoho.cn/feature/${req.params.code}.html"}}`;

        res.render('feature/index', {
            module: 'activity',
            page: 'feature',
            title: title,
            content: result,
            activity_id: req.params.code,
            isFeature: true,
            loadJs: [{
                src: global.yoho.config.jsSdk
            }]
        });
    }).catch(next);
};

exports.sidebar = function(req, res, next) {
    model.index({
        code: req.params.code
    }).then((result) => {
        if (!result) {
            return next();
        }
        res.render('feature/sidebar', {
            content: result,
            layout: false
        });
    }).catch(next);
};