onlineService.js 1.58 KB
/**
* 个人中心在线客服
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/02
*/

'use strict';

const onlineModel = require('../models/onlineService');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const helpers = global.yoho.helpers;

const getOnlineServiceInfo = (req, res, next) => {
    let serviceUrl = helpers.urlFormat('/service/im');

    onlineModel.getOnlineServiceInfo().then((result) => {

        res.render('online-service', {
            module: 'home',
            page: 'online-service',
            pageHeader: _.assign(headerModel.setNav({
                navTitle: '在线客服'
            }), {
                navBtn: false
            }),
            title: '在线客服',
            pageFooter: true,
            service: result,
            serviceUrl: serviceUrl
        });
    }).catch(next);
};

const getOnlineServiceDetail = (req, res, next) => {
    let cateId = parseInt(req.query.cateInfo, 10);
    let title = req.query.cateInfo.substring(req.query.cateInfo.indexOf('_') + 1);

    onlineModel.getOnlineServiceDetail(cateId).then((result) => {

        res.render('online-service-detail', {
            module: 'home',
            page: 'online-service',
            pageHeader: _.assign(headerModel.setNav({
                navTitle: title
            }), {
                navBtn: false
            }),
            title: title,
            pageFooter: true,
            service: result
        });
    }).catch(next);
};


module.exports = {
    getOnlineServiceInfo,
    getOnlineServiceDetail
};