index-editor.page.js
2.07 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
/**
* 列表页,编辑页
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/10
*/
require('guang/index-editor.page.css');
let $ = require('yoho-jquery');
let info = require('./info-common');
let loadMore = info.loadMore;
let winH = $(window).height();
let $author = $('#author-infos');
let $tag = $('#tag');
let $gender = $('#gender');
let $isApp = $('#isApp');
let setting = {
page: 2,
end: false
};
let $infos = $('#info-list');
let getDynamicData = require('./list-dynamic');
require('../common');
getDynamicData.getDynamicData();
info.initInfosEvt($infos);
if ($author.length > 0) {
$.extend(setting, {
authorId: $author.data('id'),
isApp: $isApp.val()
});
}
if ($tag.length > 0) {
$.extend(setting, {
tag: $tag.val(),
gender: $gender.val(),
isApp: $isApp.val()
});
}
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $infos.height()) {
loadMore($infos, setting);
}
}
// srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
// app埋点
let C_ID = window._ChannelVary[window.cookie('_Channel')];
$('.info-list').on('click', function(e) {
if (!window._yas || !window._yas.sendAppLogs) {
return;
}
let $this = $(e.target),
$btn = $this.closest('.like-btn'),
$info = $this.closest('.guang-info');
if ($btn.length > 0) {
// 点赞
window._yas.sendAppLogs({
appop: 'YB_H5_STROLL_AUTHOR_LIKE_C',
param: JSON.stringify({
C_ID: C_ID,
TYPE: $btn.hasClass('like') ? 2 : 1,
CONTENT_ID: $info.data('id')
})
}, true);
} else if ($info.length > 0) {
// 点击各楼层
window._yas.sendAppLogs({
appop: 'YB_H5_STROLL_AUTHOR_FLR_C',
param: JSON.stringify({
C_ID: C_ID,
CONTENT_INDEX: $('.guang-info').index($info) + 1,
CONTENT_ID: $info.data('id')
})
}, true);
}
});