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

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

    /* 点击商品详情页【立即购买】按钮时埋点*/
      $('#buy-now').click(function() {
          var num = +$('#num').text(),
              color = $('.chose-color .colors .focus').find('.color-name').text(),
              size = $('#sizes .size .focus').data('name');

          var option = {
              PRD_ID: getPrdId(),
              PRD_NUM: num,
              COLOR: color,
              SIZE: size
          };

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

    /* 点击商品详情页商品角度图时埋点*/
      $('#thumbs > .thumb-wrap').on('click', '.thumb', function() {
          var $this = $(this);

          var $index = $this.index() + 1;

          yas.givePoint('YB_GDS_PICTURE_C', {PRD_ID: getPrdId(), PIC_INDEX: $index});
      });

    /* 点击商品分享渠道时埋点*/
      $('.share-row .share-to i').on('click', function() {
          var $this = $(this);

          var $index = $this.index() + 1;

          yas.givePoint('YB_GDS_SHARE_TYPE_C', {PRD_ID: getPrdId(), TYPE_ID: $index});
      });

     /* 查看VIP价格后的【立即登录】按钮点击埋点*/
      $('.market-price .vip-price a').click(function() {
          yas.givePoint('YB_GDS_VIP_PRICE_SIGN_C', {PRD_ID: getPrdId()});
      });

     /* 点击【展开全部促销】按钮时*/
      $('.activity-wrapper .activity-title').click(function() {
          yas.givePoint('YB_GDS_ALL_PROMOTION_C', { PRD_ID: getPrdId() });
      });

     /* 点击优惠券领取模块埋点*/
      $('.small-coupon-list li .coupon-item .small-desc').click(function() {
          var $this = $(this);

          var coupon = $this.parent('.coupon-item').data('id');

          yas.givePoint('YB_GDS_COUPON_C', {PRD_ID: getPrdId(), COUPON: coupon});
      });

     /* 点击商品详情页颜色时*/
      $('.chose-color .colors').on('click', 'li', function() {
          var $this = $(this);
          var color = $this.find('.color-name').text();

          yas.givePoint('YB_GDS_COLOR_C', {PRD_ID: getPrdId(), COLOR: color});
      });

     /* 点击商品详情页尺寸时埋点*/
      $('#sizes .size').on('click', 'li', function() {
          var $this = $(this);
          
          yas.givePoint('YB_GDS_SIZE_C', {PRD_ID: getPrdId(), SIZE: $this.data('name')});
      });

     /* 点击到货通知按钮时*/
      $('.trade-content .type-chose').on('click', '#enable-notify', function() {
          yas.givePoint('YB_GDS_ARRIVAL_NOTICE_C', {PRD_ID: getPrdId()});
      });

       // 点击数量加减号埋点
      $('#plus-num').click(function() {
          yas.givePoint('YB_GDS_NUMBER_C', {PRD_ID: getPrdId(), TYPE: 1});
      });

      $('#minus-num').click(function() {
          yas.givePoint('YB_GDS_NUMBER_C', {PRD_ID: getPrdId(), TYPE: 2});
      });

  };