Blame view

public/js/home/recommend-for-you-user-center.js 1.49 KB
郭成尧 authored
1 2 3 4 5 6 7
/**
 * 为您优选
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/11/16
 */

陈峰 authored
8
let $ = require('yoho-jquery'),
郭成尧 authored
9 10
    lazyLoad = require('yoho-jquery-lazyload');
陈峰 authored
11
let $recommendForYou = $('.recommend-for-you');
郭成尧 authored
12
ccbikai(👎🏻🍜) authored
13 14
setTimeout(function() {
    $.get('/product/recommend-for-you/userCenter').then(function(html) {
陈峰 authored
15
        let PRDID = [];
郭成尧 authored
16
姜枫 authored
17
        $recommendForYou.html(html);
lijing authored
18 19

姜枫 authored
20
        lazyLoad($('img.lazy'));
郭成尧 authored
21
姜枫 authored
22
        // 为您优选埋点 http://redmine.yoho.cn/issues/10116
ccbikai(👎🏻🍜) authored
23
        $recommendForYou.find('.good-info').each(function() {
姜枫 authored
24 25
            PRDID.push($(this).data('id'));
        });
lijing authored
26
陈峰 authored
27
        let $recommendSonLen = $recommendForYou.find('.good-info').length;
郭成尧 authored
28
姜枫 authored
29 30 31 32 33
        if ($recommendSonLen === 0) {
            $recommendForYou.hide();
        } else {
            $recommendForYou.show();
        }
郭成尧 authored
34 35

        window.givePoint({
沈志敏 authored
36
            REC_POSE: 110004,
姜枫 authored
37 38 39
            PRD_ID: PRDID.join(','),
            PRD_NUM: $('.recommend-for-you .good-info').length,
            ACTION_ID: 0,
沈志敏 authored
40
            PAGE_NUM: 1
郭成尧 authored
41 42
        });
ccbikai(👎🏻🍜) authored
43
        $recommendForYou.find('.good-info').on('click', 'a', function() {
陈峰 authored
44
            let index = $(this).closest('.good-info').index() + 1;
郭成尧 authored
45
姜枫 authored
46 47 48 49 50 51 52 53 54 55 56
            window.givePoint({
                REC_POSE: 110004,
                PRD_ID: $(this).closest('.good-info').data('id'),
                PRD_NUM: index,
                ACTION_ID: 1,
                PAGE_NUM: 1
            });

            return true;
        });
ccbikai(👎🏻🍜) authored
57
    }).fail(function() {
姜枫 authored
58 59 60
        $recommendForYou.hide();
    });
}, 500);