Blame view

apps/home/controllers/onlineService.js 1.58 KB
zhangxiaoru authored
1 2 3 4 5 6 7 8 9 10 11
/**
* 个人中心在线客服
* @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');
12
const helpers = global.yoho.helpers;
zhangxiaoru authored
13 14

const getOnlineServiceInfo = (req, res, next) => {
15
    let serviceUrl = helpers.urlFormat('/service/im');
zhangxiaoru authored
16 17 18 19 20 21 22 23 24 25 26 27 28

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

        res.render('online-service', {
            module: 'home',
            page: 'online-service',
            pageHeader: _.assign(headerModel.setNav({
                navTitle: '在线客服'
            }), {
                navBtn: false
            }),
            title: '在线客服',
            pageFooter: true,
zhangxiaoru authored
29
            service: result,
30
            serviceUrl: serviceUrl
zhangxiaoru authored
31 32
        });
    }).catch(next);
zhangxiaoru authored
33 34 35 36
};

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

    onlineModel.getOnlineServiceDetail(cateId).then((result) => {
zhangxiaoru authored
40
zhangxiaoru authored
41 42 43 44 45 46 47 48 49 50 51 52 53
        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);
zhangxiaoru authored
54 55
};
zhangxiaoru authored
56
zhangxiaoru authored
57
module.exports = {
zhangxiaoru authored
58 59
    getOnlineServiceInfo,
    getOnlineServiceDetail
zhangxiaoru authored
60
};