help-common.js
2.25 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
/**
* [帮助中心 常见问题弹框]
* @author: wsl(shuiling.wang@yoho.cn)
* @date: 2016/12/02
*/
var problemTpl = require('../../hbs/help/problem-box.hbs');
var yas = require('../common/data-yas');
// 问题弹窗操作
var problemBox = function() {
var $problemBox;
$('.help-page').append(problemTpl());
$problemBox = $('.problem-box');
$problemBox.css({lineHeight: $(window).height() + 'px'});
$('.problem a').on('click', function() {
var ask = $(this).data('ask') || '';
var answer = $(this).data('answer') || '';
$problemBox.find('.a-area').html(ask);
$problemBox.find('.q-area').html(answer);
$problemBox.show();
});
$('.problem-box .close, .problem-box .mark').on('click', function() {
$problemBox.hide();
});
};
var $subsets = $('.subsets');
/**
* 目录切换
*/
$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('.icon').removeClass('minus').addClass('plus');
} else {
$('.smll-category').hide();
$('.subsets').children('.icon').removeClass('minus').addClass('plus');
$child.show();
$subsets.removeClass('open');
$this.addClass('open').children('.icon').removeClass('plus').addClass('minus');
}
});
// 左侧菜单栏点击埋点
$('.help-navigation .nav li').on('click', function() {
var yasParams;
var id = $(this).attr('class').split(' ')[1].split('-')[1];
var text = $(this).find('.menu-txt').html();
var parentId;
if ($(this).hasClass('big-category')) {
yasParams = {
MENU_ID1: id,
MENU_NM1: text,
MENU_ID2: id,
MENU_NM2: text
};
} else {
parentId = $(this).data('parentId');
yasParams = {
MENU_ID1: parentId,
MENU_NM1: $('.cateId-' + parentId).find('.menu-txt').html(),
MENU_ID2: id,
MENU_NM2: text
};
}
yas.yasEvent('YB_HELP_MENU_C', yasParams);
});
module.exports = problemBox;