search.page.js 2.25 KB
/**
 * search
 * @author: sefon 2016-7-12 15:28:22
 */

var $ = require('yoho-jquery');
var yas = require('../common/data-yas');
var lazyLoad = require('yoho-jquery-lazyload');



var product = require('./index/product');
var qs = window.queryString;

var $footPage = $('.foot-pager1').data('total'),
    $productIdArr = [],
    $leftUl = $('.sort-container .sort-child-list'),
    $leftLi = $leftUl.find('li.active');


var filterValue = yas.getFilterValue();

$('.good-info .product-id').each(function() {
    $productIdArr.push($(this).html());
});

require('../common');
require('../plugins/filter');
require('../plugins/sort-pager');
require('./detail/latest-walk');

product.init(4);



lazyLoad($('img.lazy'), {
    failure_limit: 20
});


/*
 * 页面加载完
 */
$(function() {
    var sto = setInterval(function() {
        if (window._yas && window._yas.sendCustomInfo) {
            // 关键词搜索结果页展示时
            yas.givePoint('YB_KEYWORD_GOODS_LIST_L', {
                KEYWORD: qs.query,
                RES_QTY: $footPage || 0,
                PRD_LIST: $productIdArr.join(','),
                PAGE_NUM: qs.pager || 1,
                FILTER_VALUE: filterValue,
                L1_SORT: $leftLi.length > 0 ? $leftLi.parent().prev().attr('title') : '',
                L2_SORT: $leftLi.find('a').attr('title') || '',
                SORT_TYPE: qs.order || 's_n_desc'
            });
            clearInterval(sto);
        }
    }, 100);

    // 点击搜索列表商品
    $('.good-item-wrapper').click(function() {
        var $this = $(this),
            proId = $this.find('.product-id').html(),
            aIndex = $this.attr('activeIndex'),
            pageNum = qs.pager || 1,
            limit = qs.limit || 60,
            proNum = (parseInt(pageNum, 10) - 1) * limit + parseInt(aIndex, 10);

        // 点击搜索列表商品埋点
        yas.givePoint('YB_KEYWORD_GOODS_LIST_C', {
            KEYWORD: qs.query,
            PRD_ID: proId,
            PRD_NUM: proNum,
            PAGE_NUM: pageNum,
            FILTER_VALUE: filterValue,
            L1_SORT: $leftLi.length > 0 ? $leftLi.parent().prev().attr('title') : '',
            L2_SORT: $leftLi.find('a').attr('title') || '',
            SORT_TYPE: qs.order || 's_n_desc'
        });
    });
});