index.page.js
2.76 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
/**
* 个人中心首页
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/11/12
*/
require('scss/home/index.page.scss');
require('js/common');
let $ = require('yoho-jquery'),
noticeScroll = require('js/plugin/notice-scroll');
let $userAvatar = $('.user-avatar'),
$listItem = $('.list-item');
let myImage = new Image(),
avatar;
let Swiper = require('yoho-swiper2');
if ($('.recommend-for-you').length) {
require('./recommend-for-you-user-center');
}
require('js/common/suspend-cart');
require('js/common/footer');
require('js/common/set-trend-world');
if ($('.banner-center-swiper').length > 0) {
new Swiper('.banner-center-swiper', {
pagination: '.swiper-pagination',
lazyLoading: true,
lazyLoadingInPrevNext: true,
paginationClickable: true,
autoplay: 3000
});
}
window.reMarginFooter('.footer-tab');
// 部分老用户没有头像,显示默认头像
avatar = $userAvatar.data('avatar');
if (avatar) {
myImage.src = avatar;
myImage.onload = function() {
$userAvatar.css('background-image', 'url(' + avatar + ')');
};
}
noticeScroll('.notice', $('.notice').data('time') * 1000);
$('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', function() {
$listItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', '.list-item, .type-item, .order-title', function() {
$(this).removeClass('highlight');
});
// 修改潮流口令
$('.code-set').on('touchstart', function(e) {
e.preventDefault();
$('.set-trend-world').show();
});
// 埋点
$('.res-c').on('click', 'a', function() {
let $this = $(this);
let index = $this.index() + 1;
let pIndex = $this.parent('div').index() + 1;
let url = $this.attr('href');
let name = $this.attr('name');
let id = $this.attr('id');
let status = $this.parent('li').hasClass('swiper-slide');
if (status) {
index = $this.parent('li').index() + 1;
pIndex = 1;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo && window._yas.sendCustomInfo({
op: 'YB_MY_BANNER_C',
param: JSON.stringify({
I_INDEX: index,
F_URL: encodeURIComponent(url),
F_NAME: name,
F_INDEX: pIndex,
F_ID: id
})
}, true);
}
});
(function() {
if (!$('.set-trend-world').hasClass('trend-world') && $('.my-header').hasClass('login')) {
if (!window.cookie('trend-pop') || parseInt(window.cookie('trend-pop'), 10) !== 1) {
$('.set-trend-world').removeClass('set-trend-hide');
setTimeout(function() {
window.setCookie('trend-pop', 1, {expires: 1});
}, 1000);
}
}
}());