Authored by 李靖

首页开发完成

... ... @@ -135,6 +135,21 @@ class newHome extends global.yoho.BaseModel {
});
}
// 公告
_noticeData() {
let options = {
url: 'favorite',
data: {
method: 'app.resources.getNotices'
},
param: {
code: 200
}
};
return this.get(options);
}
index(params) {
return Promise.all([
this._userData(params),
... ...
... ... @@ -142,7 +142,7 @@
</a>
</div>
{{/ infoNum}}
<div class="ad-pic res-c">
<div class="ad-pic res-c clearfix">
<div class="resource-content">
{{> content}}
</div>
... ...
... ... @@ -3,6 +3,8 @@ import 'product/new-recommend/new-recommend';
import $ from 'yoho-jquery';
import Page from 'yoho-page';
import 'common/set-trend-world';
import Swiper from 'yoho-swiper2';
import yoho from 'yoho-app';
class NewHome extends Page {
constructor() {
... ... @@ -12,7 +14,9 @@ class NewHome extends Page {
$scrollC: $('.scroll-c'),
$scrollWords: $('.scroll-words'),
$userAvatar: $('.user-avatar'),
$codeSet: $('.code-set')
$codeSet: $('.code-set'),
$resYas: $('.res-c').find('a'),
$trendCode: $('.trend-code')
};
this.init();
... ... @@ -22,10 +26,66 @@ class NewHome extends Page {
this.autoScroll();
this.defaultPic();
this.bindEvents();
this.swiper();
this.showTrend();
}
// 首次进入个人中心,且登陆,且没有设置潮流口令,打开弹框子
showTrend() {
if (yoho.isLogin() && (!this.selector.$trendCode.html()) && !window.cookie('first-trend')) {
$('.set-trend-world').removeClass('set-trend-hide');
window.setCookie('first-trend', true, {
path: '/home',
expires: 1
});
}
}
bindEvents() {
this.selector.$codeSet.on('click', this.codeSet.bind(this));
this.selector.$resYas.on('click', this.yas.bind(this));
}
// 资源位
swiper() {
if ($('.banner-center-swiper').length > 0) {
new Swiper('.banner-center-swiper', {
pagination: '.swiper-pagination',
lazyLoading: true,
lazyLoadingInPrevNext: true,
paginationClickable: true,
autoplay: 3000
});
}
}
// 埋点
yas(e) {
let $this = $(e.currentTarget);
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);
}
}
// 默认头像
... ... @@ -33,7 +93,7 @@ class NewHome extends Page {
let myImage = new Image(),
avatar;
avatar = this.selector.$userAvatar.data('avatar');
avatar = this.selector.$userAvatar.data('avatar') || '';
myImage.src = avatar;
myImage.onload = () => {
this.selector.$userAvatar.css('background-image', 'url(' + avatar + ')');
... ...
... ... @@ -9,7 +9,9 @@ class NewRecommend extends Page {
super();
this.selector = {
$goodsContainer: $('#new-recommend-c').find('.container')
$goodsContainer: $('#new-recommend-c').find('.container'),
$goodInfo: $('.good-info'),
$recommendC: $('#new-recommend-c')
};
this.view = {
... ... @@ -40,6 +42,8 @@ class NewRecommend extends Page {
this.selector.$goodsContainer.append($goodsData);
lazyLoad($goodsData.find('img.lazy'));
} else {
this.selector.$recommendC.hide();
}
}
}).catch(error => {
... ...
@import "common/set-trend-world";
@import "channel/thumb-row";
@import "channel/divide-image";
@import "channel/banner-center";
@import "layout/swiper";
.new-home-c {
background-color: #f0f0f0;
... ... @@ -292,6 +296,34 @@
height: auto;
}
}
.thumb-row {
padding-top: 0;
.thumb-row-box {
display: block;
float: left;
width: 355px;
margin: 0 10px;
max-height: 260px;
}
}
.banner-center-swiper {
height: 260px;
.banner-list {
height: 260px;
li {
height: 260px;
img {
height: 260px;
}
}
}
}
}
@keyframes autoScroll {
... ...