installment.page.js 2.48 KB
var $ = require('yoho-jquery'),
    ellipsis = require('yoho-mlellipsis'),
    ListData = require('./installment-goods'),
    bp = require('./burying-point'),
    uuid = require('uuid'),
    lazyLoad = require('yoho-jquery-lazyload');

var uuidVal = uuid.v4();

require('../common');


lazyLoad($('img.lazy'));
ellipsis.init();

// 标题限制行数
function setDetailText() {
    var $this, $title;

    $('.good-detail-text .name').each(function() {
        $this = $(this);
        $title = $this.find('a');

        $title[0].mlellipsis(2);
    });
}

// 商品列表翻页加载数据
new ListData({
    url: '/home/installment/get-goods',
    page: 1,
    boxArea: $('#goods-list'),
    uuid: uuidVal
});

setDetailText();

// 已开通tab 切换
$('.detail-tab span').on('click', function() {
    var labId = 1;

    $(this).addClass('on').siblings().removeClass('on');
    $('.installment-cont').hide().eq($(this).index()).show();

    if ($(this).index() === 1) {
        setDetailText();
        labId = 2;
    }

    // 统计:开通成功后首页头部tab切换
    bp.setContYas({
        LAB_ID: labId
    }, true);
});

// 统计:开通按钮点击时
$('.open-btn').on('click', function() {
    bp.setContYas({}, false);
});

$(document).on('click', '.good-info', function() {

    // 统计:商品点击时
    bp.setContYas({
        PRD_NUM: parseInt($(this).index()) + 1,
        PRD_ID: $(this).data('id'),
        ACTION_ID: 1,
        REC_ID: uuidVal
    }, false);
});

// 统计:开通后模块位点击时
$('.nav-bit').on('click', function() {
    bp.setContYas({
        POS_ID: $(this).data('id')
    }, false);
});

setTimeout(function() {
    if ($('.installment-only').length > 0) {

        // 统计:进入页面时
        bp.setContYas({
            IS_OPEN: $('.is-open').val()
        }, true);

        // 统计:商品第一页加载时
        bp.setContYas({
            PRD_NUM: $('.installment-only .good-info').length,
            PRD_ID: bp.countGoodsId(),
            ACTION_ID: 0,
            REC_ID: uuidVal
        }, true);

        if ($('.is-open').val() === 'true') {

            // 统计:待还款金额默认页面加载时
            bp.setContYas({
                LAB_ID: 1
            }, true);
        }
    }
}, 3000);

window.setCookie('installmentUid', window.queryString.uid);
window.setCookie('yhChannel', window.queryString.yh_channel);
window.setCookie('udid', window.queryString.udid);
window.setCookie('clientType', window.queryString.client_type);