|
@@ -3,6 +3,8 @@ import 'product/new-recommend/new-recommend'; |
|
@@ -3,6 +3,8 @@ import 'product/new-recommend/new-recommend'; |
3
|
import $ from 'yoho-jquery';
|
3
|
import $ from 'yoho-jquery';
|
4
|
import Page from 'yoho-page';
|
4
|
import Page from 'yoho-page';
|
5
|
import 'common/set-trend-world';
|
5
|
import 'common/set-trend-world';
|
|
|
6
|
+import Swiper from 'yoho-swiper2';
|
|
|
7
|
+import yoho from 'yoho-app';
|
6
|
|
8
|
|
7
|
class NewHome extends Page {
|
9
|
class NewHome extends Page {
|
8
|
constructor() {
|
10
|
constructor() {
|
|
@@ -12,7 +14,9 @@ class NewHome extends Page { |
|
@@ -12,7 +14,9 @@ class NewHome extends Page { |
12
|
$scrollC: $('.scroll-c'),
|
14
|
$scrollC: $('.scroll-c'),
|
13
|
$scrollWords: $('.scroll-words'),
|
15
|
$scrollWords: $('.scroll-words'),
|
14
|
$userAvatar: $('.user-avatar'),
|
16
|
$userAvatar: $('.user-avatar'),
|
15
|
- $codeSet: $('.code-set')
|
17
|
+ $codeSet: $('.code-set'),
|
|
|
18
|
+ $resYas: $('.res-c').find('a'),
|
|
|
19
|
+ $trendCode: $('.trend-code')
|
16
|
};
|
20
|
};
|
17
|
|
21
|
|
18
|
this.init();
|
22
|
this.init();
|
|
@@ -22,10 +26,66 @@ class NewHome extends Page { |
|
@@ -22,10 +26,66 @@ class NewHome extends Page { |
22
|
this.autoScroll();
|
26
|
this.autoScroll();
|
23
|
this.defaultPic();
|
27
|
this.defaultPic();
|
24
|
this.bindEvents();
|
28
|
this.bindEvents();
|
|
|
29
|
+ this.swiper();
|
|
|
30
|
+ this.showTrend();
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
|
33
|
+ // 首次进入个人中心,且登陆,且没有设置潮流口令,打开弹框子
|
|
|
34
|
+ showTrend() {
|
|
|
35
|
+ if (yoho.isLogin() && (!this.selector.$trendCode.html()) && !window.cookie('first-trend')) {
|
|
|
36
|
+ $('.set-trend-world').removeClass('set-trend-hide');
|
|
|
37
|
+ window.setCookie('first-trend', true, {
|
|
|
38
|
+ path: '/home',
|
|
|
39
|
+ expires: 1
|
|
|
40
|
+ });
|
|
|
41
|
+ }
|
25
|
}
|
42
|
}
|
26
|
|
43
|
|
27
|
bindEvents() {
|
44
|
bindEvents() {
|
28
|
this.selector.$codeSet.on('click', this.codeSet.bind(this));
|
45
|
this.selector.$codeSet.on('click', this.codeSet.bind(this));
|
|
|
46
|
+ this.selector.$resYas.on('click', this.yas.bind(this));
|
|
|
47
|
+ }
|
|
|
48
|
+
|
|
|
49
|
+ // 资源位
|
|
|
50
|
+ swiper() {
|
|
|
51
|
+ if ($('.banner-center-swiper').length > 0) {
|
|
|
52
|
+ new Swiper('.banner-center-swiper', {
|
|
|
53
|
+ pagination: '.swiper-pagination',
|
|
|
54
|
+ lazyLoading: true,
|
|
|
55
|
+ lazyLoadingInPrevNext: true,
|
|
|
56
|
+ paginationClickable: true,
|
|
|
57
|
+ autoplay: 3000
|
|
|
58
|
+ });
|
|
|
59
|
+ }
|
|
|
60
|
+ }
|
|
|
61
|
+
|
|
|
62
|
+ // 埋点
|
|
|
63
|
+ yas(e) {
|
|
|
64
|
+ let $this = $(e.currentTarget);
|
|
|
65
|
+ let index = $this.index() + 1;
|
|
|
66
|
+ let pIndex = $this.parent('div').index() + 1;
|
|
|
67
|
+ let url = $this.attr('href');
|
|
|
68
|
+ let name = $this.attr('name');
|
|
|
69
|
+ let id = $this.attr('id');
|
|
|
70
|
+ let status = $this.parent('li').hasClass('swiper-slide');
|
|
|
71
|
+
|
|
|
72
|
+ if (status) {
|
|
|
73
|
+ index = $this.parent('li').index() + 1;
|
|
|
74
|
+ pIndex = 1;
|
|
|
75
|
+ }
|
|
|
76
|
+
|
|
|
77
|
+ if (window._yas && window._yas.sendCustomInfo) {
|
|
|
78
|
+ window._yas.sendCustomInfo && window._yas.sendCustomInfo({
|
|
|
79
|
+ op: 'YB_MY_BANNER_C',
|
|
|
80
|
+ param: JSON.stringify({
|
|
|
81
|
+ I_INDEX: index,
|
|
|
82
|
+ F_URL: encodeURIComponent(url),
|
|
|
83
|
+ F_NAME: name,
|
|
|
84
|
+ F_INDEX: pIndex,
|
|
|
85
|
+ F_ID: id
|
|
|
86
|
+ })
|
|
|
87
|
+ }, true);
|
|
|
88
|
+ }
|
29
|
}
|
89
|
}
|
30
|
|
90
|
|
31
|
// 默认头像
|
91
|
// 默认头像
|
|
@@ -33,7 +93,7 @@ class NewHome extends Page { |
|
@@ -33,7 +93,7 @@ class NewHome extends Page { |
33
|
let myImage = new Image(),
|
93
|
let myImage = new Image(),
|
34
|
avatar;
|
94
|
avatar;
|
35
|
|
95
|
|
36
|
- avatar = this.selector.$userAvatar.data('avatar');
|
96
|
+ avatar = this.selector.$userAvatar.data('avatar') || '';
|
37
|
myImage.src = avatar;
|
97
|
myImage.src = avatar;
|
38
|
myImage.onload = () => {
|
98
|
myImage.onload = () => {
|
39
|
this.selector.$userAvatar.css('background-image', 'url(' + avatar + ')');
|
99
|
this.selector.$userAvatar.css('background-image', 'url(' + avatar + ')');
|