Blame view

public/js/help/help.page.js 1.93 KB
王水玲 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/**
 * [帮助中心]
 * @author: wsl(shuiling.wang@yoho.cn)
 * @date: 2016/07/25
 */
var helpSearch = require('./help-search');
var problemBox = require('./help-common');
var helper = require('./help-helper');
var searchTemplet = require('../../hbs/help/search-cont.hbs');
var parentID, qs, queryId, page, keywords, $cate;

require('../common');

qs = window.queryString();
queryId = qs.id;
page = qs.page || 1;
keywords = qs.helpQuery;
$cate = $('.cateId-' + queryId);// 当前分类


helpSearch.init();
problemBox();

// 获取搜索的结果
if (keywords) {
    $.get('/help/search', {
        page: page,
        keywords: keywords
    }, function(result) {
        var id,
            $detailCont = $('.detail-cont');

        if (result.helper_list) {
王水玲 authored
34
            $.each(result.helper_list, function(k, s) {
王水玲 authored
35
                if (s.helperType === 2) {
王水玲 authored
36 37 38
                    s.problem = true;
                }
王水玲 authored
39
                if (parseInt(s.secendCategoryId, 10) === 0) {
王水玲 authored
40 41 42 43
                    id = s.firstCategoryId;
                } else {
                    id = s.secendCategoryId;
                }
王水玲 authored
44 45

王水玲 authored
46 47
                s.content = helper.cutStr({
                    str: s.content,
王水玲 authored
48
                    len: 290,
王水玲 authored
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
                    type: s.helperType,
                    url: '/help/detail?id=' + id + '&contId=' + s.id
                });

                s.content = helper.keywordLabel(s.content, keywords);
                s.caption = helper.keywordLabel(s.caption, keywords);
            });

            $detailCont.html(searchTemplet(result));
        } else {
            $.get('/help/onlineService', {}, function(url) {
                result.jumpUrl = url;
                $detailCont.html(searchTemplet(result));
            });
        }
    });
}

if (!$cate.hasClass('big-category')) {
    parentID = $cate.data('parentId');

    $('.parentId-' + parentID).show();
王水玲 authored
71
    $('.cateId-' + parentID).find('.icon').removeClass('plus').addClass('minus');
王水玲 authored
72
}