qrcode.js 895 Bytes
/**
 * 个人中心二维码 controller
 * @author: weiqingting<qingting.wei@yoho.cn>
 * @date: 2016/05/16
 */

'use strict';

const QRcodeModel = require('../models/qrcode-api');
const helpers = global.yoho.helpers;

exports.QRcode = (req, res, next) => {
    let id = req.query.orderCode || 0;

    req.ctx(QRcodeModel).getQRcodeData(id, req.user.uid).then((result)=>{
        if (!result) {
            return next();
        }

        let vm = {
            path: [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'},
                {name: '个人中心'}, {name: '订单中心'}, {name: '查看二维码'}],
            qrcodeData: result,
            onlyOne: result.ticks.length === 1,
            code: id,
            ticktypeName: result.title,
            returnOrder: helpers.urlFormat('/home/orders')
        };

        res.render('QRcode', vm);
    }).catch(next);
};