yas-bottom.js 3.51 KB
var $ = require('yoho-jquery');
var yas = require('../common/data-yas');

exports.yasBottom = function() {
    /* 获取商品编码*/
    function getPrdId() {
        return +$('.main').data('id');
    }

    /* 点击商品详情页模块导航时埋点*/
    $('.shoppingCar .shoppingCar-nav ul').on('click', 'li', function() {
        var $this = $(this);
        var $index = $this.index() + 1;

        yas.givePoint('YB_GDS_NAVIGATION_C', {PRD_ID: getPrdId(), NAV_INDE: $index});
    });

    /* 点击商品评价模块中的全部/有图/图片时埋点*/
    $('.cc-content .comment-tabs').on('click', 'h2', function() {
        var $this = $(this);
        var $index = $this.index() + 1;

        yas.givePoint('YB_GDS_REVIEWS_TAB_C', {PRD_ID: getPrdId(), POS_ID: $index});
    });

    $('.comments').on('click', '.img-preview .img-thumb', function() {
        yas.givePoint('YB_GDS_REVIEWS_TAB_C', {PRD_ID: getPrdId(), POS_ID: 3});
    });

    /* 点击商品详情页中的【我要咨询】时埋点*/
    $('#common-advice').click(function() {
        yas.givePoint('YB_GDS_CONSULT_C', {PRD_ID: getPrdId()});
    });

    /* 点击商品详情页底部店铺推荐和最近浏览TAB时埋点*/
    $('.bottom-tab p').on('click', 'span', function() {
        var $this = $(this);
        var $index = $this.index() + 1;

        if ($index !== 3) {
            yas.givePoint('YB_GDS_RECOMMEND_REVIEW_TAB_C', {PRD_ID: getPrdId(), TAB_ID: $index});
        }
    });

    /* 点击商品详情页底部店铺推荐和最近浏览中的商品时*/
    $('.recommend-content .img-list').on('click', 'li', function() {
        var $this = $(this);
        var relatedID = +$this.find('.goods-id').text();
        var option = {
            PRD_ID: getPrdId(),
            RELATED_ID: relatedID,
            TAB_ID: 1
        };

        yas.givePoint('YB_GDS_RECOMMEND_REVIEW_GOODS_C', option);
    });

    $('#latest-walk-goods').on('click', '.good', function() {
        var $this = $(this);
        var relatedID = +$this.find('a').attr('href').split('_')[1];
        var option = {
            PRD_ID: getPrdId(),
            RELATED_ID: relatedID,
            TAB_ID: 2
        };

        yas.givePoint('YB_GDS_RECOMMEND_REVIEW_GOODS_C', option);
    });


      /* 点击商品详情页底部店铺推荐和最近浏览中的【换一换】按钮时埋点*/
    $('.bottom-tab .change').click(function() {
        yas.givePoint('YB_GDS_RECOMMEND_REVIEW_CHANGE_C', {PRD_ID: getPrdId(), TAB_ID: 1});
    });


      /* 点击套餐详情页中的商品时埋点*/
    $('.package-box').on('click', '.package-pro .good-info', function() {
        var $this = $(this);
        var $index = $this.index() === 0 ? $this.index() + 1 : ($this.index() / 2) + 1;
        var id = $this.find('.good-thumb').attr('href').split('_')[1];
        var option = {
            PRD_ID: getPrdId(),
            PACKAGE_GOODS: id,
            PACKAGE_INDEX: $index
        };

        yas.givePoint('YB_GDS_PACKAGE_GOODS_C', option);
    });

     /* 点击套餐详情页中的立即购买按钮时埋点*/
    $('.package-box').on('click', '#buy-detail', function() {
        var arr = [];
        var good = $('.package-box .package-pro').find('.good-info');

        good.each(function(i, ele) {
            var $this = $(this);
            var id = $this.find('.good-thumb').attr('href').split('_')[1];

            arr.push(id);
        });
        yas.givePoint('YB_GDS_PACKAGE_BUY_NOW_C', {
            PRD_ID: getPrdId(),
            PACKAGE_GOODS: arr.join(';')
        });
    });
};