Authored by 毕凯

找回个人中心公告丢失的代码

@@ -3,7 +3,9 @@ @@ -3,7 +3,9 @@
3 * @author: bikai<kai.bi@yoho.cn> 3 * @author: bikai<kai.bi@yoho.cn>
4 * @date: 2015/11/12 4 * @date: 2015/11/12
5 */ 5 */
6 -var $ = require('jquery'); 6 +var $ = require('jquery'),
  7 + noticeScroll = require('../plugin/notice-scroll');
  8 +
7 var $userAvatar = $('.user-avatar'), 9 var $userAvatar = $('.user-avatar'),
8 $listItem = $('.list-item'); 10 $listItem = $('.list-item');
9 var myImage = new Image(), 11 var myImage = new Image(),
@@ -19,6 +21,8 @@ myImage.onload = function() { @@ -19,6 +21,8 @@ myImage.onload = function() {
19 $userAvatar.css('background-image', 'url(' + avatar + ')'); 21 $userAvatar.css('background-image', 'url(' + avatar + ')');
20 }; 22 };
21 23
  24 +noticeScroll('.notice', $('.notice').data('time') * 1000);
  25 +
22 $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', function() { 26 $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', function() {
23 $listItem.removeClass('highlight'); 27 $listItem.removeClass('highlight');
24 $(this).addClass('highlight'); 28 $(this).addClass('highlight');
  1 +/**
  2 + * 公告栏目滚动
  3 + * bikai kai.bi@yoho.cn
  4 + */
  5 +
  6 +var $ = require('jquery');
  7 +
  8 +function noticeScroll(selecter, time) {
  9 + var $notice = $(selecter),
  10 + $noticeItem = $notice.find('.notice-item'),
  11 + count = $noticeItem.length,
  12 + i = 1;
  13 +
  14 + selecter = selecter || '.notice';
  15 + time = time || 3000;
  16 +
  17 + if (count > 1) {
  18 + setInterval(function() {
  19 + if (i >= count) {
  20 + i = 0;
  21 + }
  22 + $noticeItem.fadeOut();
  23 + $notice.find('.item-' + i).fadeIn();
  24 + i++;
  25 + }, time);
  26 + }
  27 +}
  28 +
  29 +module.exports = noticeScroll;
@@ -33,6 +33,16 @@ @@ -33,6 +33,16 @@
33 <p>浏览记录</p> 33 <p>浏览记录</p>
34 </a> 34 </a>
35 </div> 35 </div>
  36 + {{#if notice.open}}
  37 + <div class="notice" data-time="{{notice.time}}">
  38 + {{#notice.list}}
  39 + <a class="notice-item item-{{@index}}" href="{{url}}">
  40 + <span class="notice-icon"></span>
  41 + {{title}}
  42 + </a>
  43 + {{/notice.list}}
  44 + </div>
  45 + {{/if}}
36 <div class="my-order"> 46 <div class="my-order">
37 <a class="order-title" href="/home/orders"> 47 <a class="order-title" href="/home/orders">
38 我的订单 48 我的订单
@@ -51,7 +51,7 @@ class HomeController extends AbstractAction @@ -51,7 +51,7 @@ class HomeController extends AbstractAction
51 'myIndexPage' => true, 51 'myIndexPage' => true,
52 'showDownloadApp' => true, 52 'showDownloadApp' => true,
53 'navHome' => true, 53 'navHome' => true,
54 - // 'notice' => UserModel::getNoticeData(), 54 + 'notice' => UserModel::getNoticeData(),
55 'pageFooter' => true, 55 'pageFooter' => true,
56 'cartUrl' => Helpers::url('/cart/index/index', null), 56 'cartUrl' => Helpers::url('/cart/index/index', null),
57 'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))), 57 'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),