Blame view

public/js/guang/index-editor.page.js 2.14 KB
1 2 3 4 5
/**
 * 列表页,编辑页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */
6
require('guang/index-editor.page.css');
陈峰 authored
7
8
陈峰 authored
9
let $ = require('yoho-jquery');
10
陈峰 authored
11
let info = require('./info-common');
12
陈峰 authored
13
let loadMore = info.loadMore;
14
陈峰 authored
15
let winH = $(window).height();
16
陈峰 authored
17 18 19 20
let $author = $('#author-infos');
let $tag = $('#tag');
let $gender = $('#gender');
let $isApp = $('#isApp');
21
陈峰 authored
22
let setting = {
23 24 25 26
    page: 2,
    end: false
};
陈峰 authored
27 28
let $infos = $('#info-list');
let getDynamicData = require('./list-dynamic');
Targaryen authored
29
let productlistWith = require('./index/product-list');
30
31
require('common');
zhangxiaoru authored
32 33

getDynamicData.getDynamicData();
lijing authored
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
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);
});
沈志敏 authored
62 63

// app埋点
陈峰 authored
64
let C_ID = window._ChannelVary[window.cookie('_Channel')];
沈志敏 authored
65 66 67 68 69 70

$('.info-list').on('click', function(e) {
    if (!window._yas || !window._yas.sendAppLogs) {
        return;
    }
陈峰 authored
71
    let $this = $(e.target),
沈志敏 authored
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
        $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);
    }
});
Targaryen authored
97 98

productlistWith();