help.page.js
2.84 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* [帮助中心]
* @author: jiangmin
* @date: 2016/07/25
*/
var $subsets = $('.subsets');
var helpSearch = require('./help-search');
var problemBox = require('./problem-box');
var helper = require('./help-helper');
var comI = require('../common/index');
var searchTemplet = require('../../tpl/help/search-cont.hbs');
var qs = comI.queryString();
var queryId = qs.id;
var page = qs.page || 1;
var keywords = qs.helpQuery;
var $cate = $('.cateId-' + queryId);// 当前分类
var parentID;
require('../common/header');
require('../common/return-top');
helpSearch.init();
problemBox();
// 获取搜索的结果
if (keywords) {
$.get('/help/search', {
page: page,
keywords: keywords
}, function(result) {
var id,
$detailCont = $('.detail-cont');
if (result.helper_list) {
$.each(result.helper_list, function(k, s) {
if (s.helperType === '2') {
s.problem = true;
s.allCont = s.content;
}
if (s.secendCategoryId === 0) {
id = s.firstCategoryId;
} else {
id = s.secendCategoryId;
}
s.content = helper.cutStr({
str: s.content,
len: 380,
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));
});
}
});
}
/**
* 目录切换
*/
$subsets.click(function() {
var $this = $(this);
var className = $this.attr('class').split(' ')[1];
var parentId = 'parentId-' + className.split('-')[1];
var $child = $this.parent().find('.' + parentId);// 当前子分类
if ($this.hasClass('open')) {
$child.hide();
$this.removeClass('open').children('.plus').css('background-image', 'url(\'../img/help/plus.png\')');
} else {
$('.smll-category').hide();
$('.subsets').children('.plus').css('background-image', 'url(\'../img/help/plus.png\')');
$child.show();
$subsets.removeClass('open');
$this.addClass('open').children('.plus').css('background-image', 'url(\'../img/help/minus.png\')');
}
});
if (!$cate.hasClass('big-category')) {
parentID = $cate.data('parentId');
$('.parentId-' + parentID).show();
$('.cateId-' + parentID).find('.plus').css('background-image', 'url(\'../img/help/minus.png\')');
}
$('.center-content').css('border-top-color', '#fff');