|
|
/**
|
|
|
* ajax 分期首页
|
|
|
* @author: wsl<shuiling.wang@yoho.cn>
|
|
|
* @date: 2016/08/17
|
|
|
*/
|
|
|
|
|
|
var $ = require('yoho-jquery'),
|
|
|
ellipsis = require('yoho-mlellipsis'),
|
|
|
ListData = require('./installment-goods'),
|
|
|
bp = require('./burying-point'),
|
|
|
PullRefresh = require('../plugin/pull-refresh'),
|
|
|
noticeScroll = require('../plugin/notice-scroll'),
|
|
|
uuid = require('uuid'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload');
|
|
|
uuid = require('uuid');
|
|
|
|
|
|
var uuidVal = uuid.v4(),
|
|
|
$tab = $('.detail-tab span'),
|
|
|
$isOpen = $('.is-open'),
|
|
|
$installmentCont = $('.installment-cont');
|
|
|
var installment = {
|
|
|
init: function() {
|
|
|
var self = this;
|
|
|
|
|
|
var starIScroll;
|
|
|
self.paramsInit();
|
|
|
|
|
|
require('../common');
|
|
|
$(window).on('mousewheel', false);
|
|
|
noticeScroll('.notice', $('.notice').data('time') * 1000);
|
|
|
ellipsis.init();
|
|
|
self.setDetailText();
|
|
|
|
|
|
noticeScroll('.notice', $('.notice').data('time') * 1000);
|
|
|
lazyLoad($('img.lazy'));
|
|
|
ellipsis.init();
|
|
|
$('img.lazy').lazyload({
|
|
|
effect: 'fadeIn'
|
|
|
});
|
|
|
|
|
|
$(window).on('mousewheel', false);
|
|
|
if (self.$isOpen.val() === 'true') {
|
|
|
self.iscrollAction();
|
|
|
}
|
|
|
|
|
|
if ($isOpen.val() === 'true') {
|
|
|
// 下拉刷新
|
|
|
starIScroll = new PullRefresh('.installment-main', {
|
|
|
pullDown: function() {
|
|
|
if($('.detail-tab .on').index() === 0) {
|
|
|
location.href = '/home/installment/index?uid=20000184&tab=1';
|
|
|
} else {
|
|
|
location.href = '/home/installment/index?uid=20000184&tab=2';
|
|
|
}
|
|
|
// 商品列表翻页加载数据
|
|
|
new ListData({
|
|
|
url: '/home/installment/get-goods',
|
|
|
page: 1,
|
|
|
boxArea: $('#goods-list'),
|
|
|
uuid: self.uuidVal
|
|
|
});
|
|
|
|
|
|
if (self.cookieTab && window.queryString.refresh) {
|
|
|
self.$tab.eq(self.cookieTab).addClass('on').siblings().removeClass('on');
|
|
|
self.$installmentCont.hide().eq(self.cookieTab).show();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scroll', function() {
|
|
|
$(window).trigger('scroll');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品列表翻页加载数据
|
|
|
new ListData({
|
|
|
url: '/home/installment/get-goods',
|
|
|
page: 1,
|
|
|
boxArea: $('#goods-list'),
|
|
|
uuid: uuidVal
|
|
|
});
|
|
|
|
|
|
// 标题限制行数
|
|
|
function setDetailText() {
|
|
|
var $this, $title;
|
|
|
// 已开通tab 切换
|
|
|
self.$tab.on('click', function() {
|
|
|
self.tabChangeAction(this);
|
|
|
});
|
|
|
|
|
|
$('.good-detail-text .name').each(function() {
|
|
|
$this = $(this);
|
|
|
$title = $this.find('a');
|
|
|
// 统计:开通按钮点击时
|
|
|
$('.open-btn').on('click', function() {
|
|
|
bp.setContYas('YB_INST_OPEN', {});
|
|
|
});
|
|
|
|
|
|
$title[0].mlellipsis(2);
|
|
|
});
|
|
|
}
|
|
|
$(document).on('click', '.good-info', function() {
|
|
|
|
|
|
setDetailText();
|
|
|
// 统计:商品点击时
|
|
|
bp.setContYas('YB_INST_HOME_GDS_LIST', {
|
|
|
PRD_NUM: parseInt($(this).index()) + 1, //eslint-disable-line
|
|
|
PRD_ID: $(this).data('goodId'),
|
|
|
ACTION_ID: 1,
|
|
|
REC_ID: self.uuidVal
|
|
|
});
|
|
|
});
|
|
|
|
|
|
if (window.queryString.tab === '2') {
|
|
|
$tab.eq(1).addClass('on').siblings().removeClass('on');
|
|
|
$installmentCont.hide().eq(1).show();
|
|
|
starIScroll.iScroll.refresh();
|
|
|
}
|
|
|
// 统计:开通后模块位点击时
|
|
|
$('.nav-bit').on('click', function() {
|
|
|
bp.setContYas('YB_INST_REPAYMENT_CLICK', {
|
|
|
POS_ID: $(this).data('id')
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 已开通tab 切换
|
|
|
$tab.on('click', function() {
|
|
|
var labId = 1;
|
|
|
if (window.queryString.status === '2') {
|
|
|
setTimeout(function() {
|
|
|
$('.advertisement-area').fadeIn();
|
|
|
}, 2000);
|
|
|
|
|
|
$(this).addClass('on').siblings().removeClass('on');
|
|
|
$installmentCont.hide().eq($(this).index()).show();
|
|
|
$('.advertisement-area .close-box, .advertisement-area .mask-bg').on('click', function() {
|
|
|
$('.advertisement-area').fadeOut();
|
|
|
return false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if ($(this).index() === 1) {
|
|
|
setDetailText();
|
|
|
labId = 2;
|
|
|
lazyLoad($('img.lazy'));
|
|
|
}
|
|
|
self.setCookies();
|
|
|
},
|
|
|
setDetailText: function() { // 标题限制行数
|
|
|
var $this, $title;
|
|
|
|
|
|
// 统计:开通成功后首页头部tab切换
|
|
|
bp.setContYas('YB_INST_OPENED_HOME_CLICK', {
|
|
|
LAB_ID: labId
|
|
|
});
|
|
|
$('.good-detail-text .name').each(function() {
|
|
|
$this = $(this);
|
|
|
$title = $this.find('a');
|
|
|
|
|
|
starIScroll.iScroll.refresh();
|
|
|
});
|
|
|
$title[0].mlellipsis(2);
|
|
|
});
|
|
|
},
|
|
|
tabChangeAction: function(dom) {
|
|
|
var self = this,
|
|
|
labId = 1,
|
|
|
index = $(dom).index();
|
|
|
|
|
|
$(dom).addClass('on').siblings().removeClass('on');
|
|
|
self.$installmentCont.hide().eq(index).show();
|
|
|
window.setCookie('installmentTab', index);
|
|
|
|
|
|
if (index === 1) {
|
|
|
self.setDetailText();
|
|
|
labId = 2;
|
|
|
$('img.lazy').lazyload({
|
|
|
effect: 'fadeIn'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 统计:开通按钮点击时
|
|
|
$('.open-btn').on('click', function() {
|
|
|
bp.setContYas('YB_INST_OPEN', {});
|
|
|
});
|
|
|
// 统计:开通成功后首页头部tab切换
|
|
|
bp.setContYas('YB_INST_OPENED_HOME_CLICK', {
|
|
|
LAB_ID: labId
|
|
|
});
|
|
|
|
|
|
$(document).on('click', '.good-info', function() {
|
|
|
self.starIScroll.iScroll.refresh();
|
|
|
},
|
|
|
iscrollAction: function() {
|
|
|
// 下拉刷新
|
|
|
var starIScroll = new PullRefresh('.installment-main', {
|
|
|
pullDown: function() {
|
|
|
window.setCookie('installmentTab', $('.detail-tab .on').index());
|
|
|
location.href = '/home/installment/index?uid=' + window.queryString.uid + '&refresh=1';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 统计:商品点击时
|
|
|
bp.setContYas('YB_INST_HOME_GDS_LIST', {
|
|
|
PRD_NUM: parseInt($(this).index()) + 1, //eslint-disable-line
|
|
|
PRD_ID: $(this).data('goodId'),
|
|
|
ACTION_ID: 1,
|
|
|
REC_ID: uuidVal
|
|
|
});
|
|
|
});
|
|
|
starIScroll.iScroll.on('scroll', function() {
|
|
|
$(window).trigger('scroll');
|
|
|
});
|
|
|
|
|
|
// 统计:开通后模块位点击时
|
|
|
$('.nav-bit').on('click', function() {
|
|
|
bp.setContYas('YB_INST_REPAYMENT_CLICK', {
|
|
|
POS_ID: $(this).data('id')
|
|
|
});
|
|
|
});
|
|
|
$('img').on('load', function() {
|
|
|
starIScroll && starIScroll.iScroll.refresh();
|
|
|
});
|
|
|
|
|
|
this.starIScroll = starIScroll;
|
|
|
},
|
|
|
paramsInit: function() {
|
|
|
var self = this;
|
|
|
|
|
|
$.extend(self, {
|
|
|
uuidVal: uuid.v4(),
|
|
|
$tab: $('.detail-tab span'),
|
|
|
$isOpen: $('.is-open'),
|
|
|
$installmentCont: $('.installment-cont'),
|
|
|
cookieTab: window.cookie('installmentTab') + 0,
|
|
|
starIScroll: ''
|
|
|
});
|
|
|
},
|
|
|
setCookies: function() {
|
|
|
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);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
require('../common');
|
|
|
require('yoho-jquery-lazyload');
|
|
|
|
|
|
$(window).load(function() {
|
|
|
|
|
|
if ($('.installment-only').length > 0) {
|
|
|
// 统计:进入页面时
|
|
|
bp.setContYas('YB_INST_HOME', {
|
|
|
IS_OPEN: $isOpen.val()
|
|
|
IS_OPEN: installment.$isOpen.val()
|
|
|
});
|
|
|
|
|
|
// 统计:商品第一页加载时
|
...
|
...
|
@@ -124,10 +174,10 @@ $(window).load(function() { |
|
|
PRD_NUM: $('.installment-only .good-info').length,
|
|
|
PRD_ID: bp.countGoodsId(),
|
|
|
ACTION_ID: 0,
|
|
|
REC_ID: uuidVal
|
|
|
REC_ID: installment.uuidVal
|
|
|
});
|
|
|
|
|
|
if ($isOpen.val() === 'true') {
|
|
|
if (installment.$isOpen.val() === 'true') {
|
|
|
|
|
|
// 统计:待还款金额默认页面加载时
|
|
|
bp.setContYas('YB_INST_OPENED_HOME_LOAD', {
|
...
|
...
|
@@ -137,7 +187,6 @@ $(window).load(function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
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); |
|
|
$(function() {
|
|
|
installment.init();
|
|
|
}); |
...
|
...
|
|