installment.page.js
5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/**
* ajax 分期首页
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/08/17
*/
var $ = require('yoho-jquery'),
ellipsis = require('yoho-mlellipsis'),
cookie = require('yoho-cookie'),
Swiper = require('yoho-swiper'),
ListData = require('./installment-goods'),
bp = require('./burying-point'),
PullRefresh = require('../plugin/pull-refresh'),
uuid = require('uuid');
var installment = {
init: function() {
var self = this;
self.paramsInit();
$(window).on('mousewheel', false);
ellipsis.init();
self.setDetailText();
$('body').attr('ontouchstart', true);
$('img.lazy').lazyload({
effect: 'fadeIn'
});
if (self.$isOpen.val() === 'true') {
self.iscrollAction();
} else {
// 商品列表翻页加载数据
new ListData({
url: '/home/installment/get-goods',
page: 1,
boxArea: $('#goods-list'),
uuid: self.uuidVal
});
}
if (self.cookieTab) {
self.$tab.eq(self.cookieTab).addClass('on').siblings().removeClass('on');
self.$installmentCont.hide().eq(self.cookieTab).fadeIn();
} else {
self.$tab.eq(0).addClass('on').siblings().removeClass('on');
self.$installmentCont.hide().eq(0).fadeIn();
}
self.noticeScroll('.notice', $('.notice').data('time') * 1000);
cookie.remove('installmentTab');
// 已开通tab 切换
self.$tab.on('click', function() {
self.tabChangeAction(this);
});
// 统计:开通按钮点击时
$('.open-btn').on('click', function() {
bp.setContYas('YB_INST_OPEN', {});
});
$(document).on('click', '.good-info', function() {
// 统计:商品点击时
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
});
});
// 统计:开通后模块位点击时
$('.nav-bit').on('click', function() {
bp.setContYas('YB_INST_REPAYMENT_CLICK', {
POS_ID: $(this).data('id')
});
});
if (window.queryString.status === '2') {
setTimeout(function() {
$('.advertisement-area').fadeIn();
}, 2000);
$('.advertisement-area .close-box, .advertisement-area .mask-bg').on('click', function() {
$('.advertisement-area').fadeOut();
return false;
});
}
self.setCookies();
},
noticeScroll: function(selecter, time) {
new Swiper(selecter, {
autoplay: time,
direction: 'vertical',
speed: 500,
loop: true,
noSwiping: true
});
},
setDetailText: function() { // 标题限制行数
var $this, $title;
$('.good-detail-text .name').each(function() {
$this = $(this);
$title = $this.find('a');
$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'
});
}
// 统计:开通成功后首页头部tab切换
bp.setContYas('YB_INST_OPENED_HOME_CLICK', {
LAB_ID: labId
});
self.starIScroll.iScroll.refresh();
},
iscrollAction: function() {
// 下拉刷新
var starIScroll = new PullRefresh('.installment-main', {
pullDown: function() {
window.setCookie('installmentTab', $('.detail-tab .on').index());
location.reload();
}
});
// 解决部分安卓手机不识别calc(100vh)的问题
$('.installment-main').css({height: $(window).height()});
$('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'),
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);
// window.setCookie('appVersion', window.queryString.app_version);
}
};
require('../common');
require('yoho-jquery-lazyload');
$(window).load(function() {
if ($('.installment-only').length > 0) {
// 统计:进入页面时
bp.setContYas('YB_INST_HOME', {
IS_OPEN: installment.$isOpen.val()
});
// 统计:商品第一页加载时
bp.setContYas('YB_INST_HOME_GDS_LIST', {
PRD_NUM: $('.installment-only .good-info').length,
PRD_ID: bp.countGoodsId(),
ACTION_ID: 0,
REC_ID: installment.uuidVal
});
if (installment.$isOpen.val() === 'true') {
// 统计:待还款金额默认页面加载时
bp.setContYas('YB_INST_OPENED_HOME_LOAD', {
LAB_ID: 1
});
}
}
});
$(function() {
installment.init();
});