Blame view

public/js/cart/recommend-for-you-cart.js 1.25 KB
陈峰 authored
1 2 3 4 5 6 7
/**
 * 为您优选
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/11/16
 */

lijing authored
8
let $ = require('yoho-jquery'),
陈峰 authored
9 10
    lazyLoad = require('yoho-jquery-lazyload');
lijing authored
11
let $recommendForYou = $('.recommend-for-you');
陈峰 authored
12 13

$.get('/product/recommend-for-you/cart').then(function(html) {
lijing authored
14
    let PRDID = [];
陈峰 authored
15
陈峰 authored
16 17 18 19
    $recommendForYou.html(html);
    if ($recommendForYou.find('.good-info').length) {
        $recommendForYou.show();
    }
陈峰 authored
20 21
    lazyLoad($('img.lazy'));
ccbikai(👎🏻🍜) authored
22
    // 为您优选埋点 http://redmine.yoho.cn/issues/10116
陈峰 authored
23 24 25 26
    $recommendForYou.find('.good-info').each(function() {
        PRDID.push($(this).data('id'));
    });
陈峰 authored
27
    window.givePoint && window.givePoint({
ccbikai(👎🏻🍜) authored
28 29 30 31 32
        REC_POSE: 110003,
        PRD_ID: PRDID.join(','),
        PRD_NUM: $('.recommend-for-you .good-info').length,
        ACTION_ID: 0,
        page_num: 1
陈峰 authored
33 34 35
    });

    $recommendForYou.find('.good-info').on('click', 'a', function() {
lijing authored
36
        let index = $(this).closest('.good-info').index() + 1;
陈峰 authored
37
陈峰 authored
38
        window.givePoint && window.givePoint({
ccbikai(👎🏻🍜) authored
39 40 41 42 43
            REC_POSE: 110003,
            PRD_ID: $(this).closest('.good-info').data('id'),
            PRD_NUM: index,
            ACTION_ID: 1,
            page_num: 1
陈峰 authored
44 45 46 47 48 49 50
        });

        return true;
    });

}).fail(function() {
    $recommendForYou.hide();
ccbikai(👎🏻🍜) authored
51
});