Authored by xuqi

ps页面添加收起介绍功能

@@ -16,7 +16,13 @@ require('lazyload'); @@ -16,7 +16,13 @@ require('lazyload');
16 exports.init = function() { 16 exports.init = function() {
17 $(function() { 17 $(function() {
18 var $intro = $('#intro'), 18 var $intro = $('#intro'),
  19 + $moreIntro = $('#more-intro'),
  20 + $introTxt = $moreIntro.find('.more-intro-text'),
  21 + $iconUp = $moreIntro.find('.up'),
  22 + $iconDown = $moreIntro.find('.down'),
19 winH = $(window).height(), 23 winH = $(window).height(),
  24 + mIntro, //品牌介绍文字介绍
  25 + aIntro,
20 tpl; 26 tpl;
21 var isLogin = $('#is-login').val(); 27 var isLogin = $('#is-login').val();
22 isLogin = isLogin ? isLogin : 'N'; 28 isLogin = isLogin ? isLogin : 'N';
@@ -39,21 +45,32 @@ exports.init = function() { @@ -39,21 +45,32 @@ exports.init = function() {
39 $('.info-block-content, .info-block-title').each(function() { //相关文章 45 $('.info-block-content, .info-block-title').each(function() { //相关文章
40 $(this).mlellipsis(2); 46 $(this).mlellipsis(2);
41 }); 47 });
  48 + mIntro = $intro.text();
  49 + aIntro = $intro.attr('_title');
42 }, 0); 50 }, 0);
43 51
44 //lazyload 52 //lazyload
45 $('img.lazy').lazyload(); 53 $('img.lazy').lazyload();
46 54
47 - //显示品牌介绍所有文字 55 + aIntro = $intro.attr('_title');
  56 + //显示品牌介绍所有文字/隐藏
48 function showMoreIntro() { 57 function showMoreIntro() {
49 - var intro = $intro.attr('_title');  
50 -  
51 - $intro.text(intro);  
52 -  
53 - $('#more-intro .more').css('visibility', 'hidden'); 58 + $moreIntro.toggleClass('show');
  59 +
  60 + if ($moreIntro.hasClass('show')) {
  61 + $intro.text(aIntro);
  62 + $introTxt.text('收起');
  63 + $iconDown.addClass('hide');
  64 + $iconUp.removeClass('hide');
  65 + } else {
  66 + $intro.text(mIntro);
  67 + $introTxt.text('more');
  68 + $iconUp.addClass('hide');
  69 + $iconDown.removeClass('hide');
  70 + }
54 } 71 }
55 72
56 - $('#more-intro').delegate('.more', 'click', function() { 73 + $moreIntro.delegate('.more', 'click', function() {
57 showMoreIntro(); 74 showMoreIntro();
58 }); 75 });
59 76
@@ -15,7 +15,8 @@ @@ -15,7 +15,8 @@
15 </p> 15 </p>
16 <div id="more-intro" class="more-intro"> 16 <div id="more-intro" class="more-intro">
17 <span class="more-intro-text more">more</span> 17 <span class="more-intro-text more">more</span>
18 - <span class="more-intro-icon more iconfont">&#xe607;</span> 18 + <span class="more-intro-icon more iconfont down">&#xe609;</span>
  19 + <span class="more-intro-icon more iconfont up hide">&#xe608;</span>
19 </div> 20 </div>
20 </div> 21 </div>
21 </div> 22 </div>