Authored by 李靖

首页开发完成

@@ -135,6 +135,21 @@ class newHome extends global.yoho.BaseModel { @@ -135,6 +135,21 @@ class newHome extends global.yoho.BaseModel {
135 }); 135 });
136 } 136 }
137 137
  138 + // 公告
  139 + _noticeData() {
  140 + let options = {
  141 + url: 'favorite',
  142 + data: {
  143 + method: 'app.resources.getNotices'
  144 + },
  145 + param: {
  146 + code: 200
  147 + }
  148 + };
  149 +
  150 + return this.get(options);
  151 + }
  152 +
138 index(params) { 153 index(params) {
139 return Promise.all([ 154 return Promise.all([
140 this._userData(params), 155 this._userData(params),
@@ -142,7 +142,7 @@ @@ -142,7 +142,7 @@
142 </a> 142 </a>
143 </div> 143 </div>
144 {{/ infoNum}} 144 {{/ infoNum}}
145 - <div class="ad-pic res-c"> 145 + <div class="ad-pic res-c clearfix">
146 <div class="resource-content"> 146 <div class="resource-content">
147 {{> content}} 147 {{> content}}
148 </div> 148 </div>
@@ -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 + ')');
@@ -9,7 +9,9 @@ class NewRecommend extends Page { @@ -9,7 +9,9 @@ class NewRecommend extends Page {
9 super(); 9 super();
10 10
11 this.selector = { 11 this.selector = {
12 - $goodsContainer: $('#new-recommend-c').find('.container') 12 + $goodsContainer: $('#new-recommend-c').find('.container'),
  13 + $goodInfo: $('.good-info'),
  14 + $recommendC: $('#new-recommend-c')
13 }; 15 };
14 16
15 this.view = { 17 this.view = {
@@ -40,6 +42,8 @@ class NewRecommend extends Page { @@ -40,6 +42,8 @@ class NewRecommend extends Page {
40 42
41 this.selector.$goodsContainer.append($goodsData); 43 this.selector.$goodsContainer.append($goodsData);
42 lazyLoad($goodsData.find('img.lazy')); 44 lazyLoad($goodsData.find('img.lazy'));
  45 + } else {
  46 + this.selector.$recommendC.hide();
43 } 47 }
44 } 48 }
45 }).catch(error => { 49 }).catch(error => {
1 @import "common/set-trend-world"; 1 @import "common/set-trend-world";
  2 +@import "channel/thumb-row";
  3 +@import "channel/divide-image";
  4 +@import "channel/banner-center";
  5 +@import "layout/swiper";
2 6
3 .new-home-c { 7 .new-home-c {
4 background-color: #f0f0f0; 8 background-color: #f0f0f0;
@@ -292,6 +296,34 @@ @@ -292,6 +296,34 @@
292 height: auto; 296 height: auto;
293 } 297 }
294 } 298 }
  299 +
  300 + .thumb-row {
  301 + padding-top: 0;
  302 +
  303 + .thumb-row-box {
  304 + display: block;
  305 + float: left;
  306 + width: 355px;
  307 + margin: 0 10px;
  308 + max-height: 260px;
  309 + }
  310 + }
  311 +
  312 + .banner-center-swiper {
  313 + height: 260px;
  314 +
  315 + .banner-list {
  316 + height: 260px;
  317 +
  318 + li {
  319 + height: 260px;
  320 +
  321 + img {
  322 + height: 260px;
  323 + }
  324 + }
  325 + }
  326 + }
295 } 327 }
296 328
297 @keyframes autoScroll { 329 @keyframes autoScroll {