chat-qa.page.js
2.3 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
'use strict';
let tip = require('plugin/tip');
let $hotGroup = $('.hot-group'),
$searchGroup = $('.search-group'),
$noResult = $('.no-result');
require('common');
$('.list-group div').on('touchstart',
function() {
$(this).addClass('highlight');
}).on('touchend touchcancel',
function() {
$(this).removeClass('highlight');
}
);
$('.open-down').click(
function() {
$(this).next('.down-item').toggle().siblings('.down-item').hide();
}
);
$('.cancel-btn').click(
function() {
window.history.go(-1);
}
);
$(
function() {
$('.get-qa').focus();
}
);
$('.get-qa').on('keyup focus',
function() {
let searchText = $(this).val();
if (searchText === '') {
$hotGroup.show();
$searchGroup.hide();
$noResult.hide();
} else {
$.ajax({
url: '/service/keySearch',
data: {
keyword: searchText
},
success: function(result) {
$searchGroup.show();
$noResult.hide();
$hotGroup.hide();
let keyList = result.data.helper_list;
if (keyList === '') {
$searchGroup.empty();
$noResult.show();
$noResult.find('.noKey').html(searchText);
} else {
let keyItem = '';
for (let i = 0; i < keyList.length; i++) {
let redText = keyList[i].caption.replace(searchText, '<span>$&</span>');
let id = keyList[i].id;
keyItem += '<a class="common-item" href="./qaDetail?keyword=' + searchText +
'&sonId=' + id + '">' +
'<p>' + redText + '</p>' +
'<i class="arr-ico iconfont"></i>' +
'</a>';
}
$searchGroup.html(keyItem);
}
},
error: function() {
tip.show('网络异常!');
}
});
}
}
);