Authored by ccbikai

星潮教室优化

@@ -45,25 +45,26 @@ app.use(bodyParser.urlencoded({ @@ -45,25 +45,26 @@ app.use(bodyParser.urlencoded({
45 extended: false 45 extended: false
46 })); 46 }));
47 app.use(cookieParser()); 47 app.use(cookieParser());
48 -app.use(session({  
49 - proxy: true,  
50 - resave: false,  
51 - saveUninitialized: true,  
52 - unset: 'destroy',  
53 - secret: 'nothing', // 兼容 PHP SESSION,sessionID 不加密  
54 - name: 'PHPSESSID', // 兼容 PHP SESSION  
55 - genid: () => {  
56 - return uuid.v4(); // 兼容 PHP SESSION  
57 - },  
58 - cookie: {  
59 - domain: 'yohobuy.com'  
60 - },  
61 - store: new MemcachedStore({  
62 - hosts: config.memcache.session,  
63 - prefix: 'qinsessionsession:', // 兼容 PHP SESSION  
64 - key: 'yohobuy_session' // 兼容 PHP SESSION  
65 - })  
66 -})); 48 +
  49 +// app.use(session({
  50 +// proxy: true,
  51 +// resave: false,
  52 +// saveUninitialized: true,
  53 +// unset: 'destroy',
  54 +// secret: 'nothing', // 兼容 PHP SESSION,sessionID 不加密
  55 +// name: 'PHPSESSID', // 兼容 PHP SESSION
  56 +// genid: () => {
  57 +// return uuid.v4(); // 兼容 PHP SESSION
  58 +// },
  59 +// cookie: {
  60 +// domain: 'yohobuy.com'
  61 +// },
  62 +// store: new MemcachedStore({
  63 +// hosts: config.memcache.session,
  64 +// prefix: 'qinsessionsession:', // 兼容 PHP SESSION
  65 +// key: 'yohobuy_session' // 兼容 PHP SESSION
  66 +// })
  67 +// }));
67 68
68 app.use((req, res, next) => { 69 app.use((req, res, next) => {
69 req.user = {}; 70 req.user = {};
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 {{/content}} 8 {{/content}}
9 9
10 <div class="avatar-wrap"> 10 <div class="avatar-wrap">
11 - <div class="avatar-swiper avatar-0"> 11 + <div class="avatar-swiper avatar">
12 <ul class="clearfix swiper-wrapper"> 12 <ul class="clearfix swiper-wrapper">
13 {{# starAvatar}} 13 {{# starAvatar}}
14 <li class="swiper-slide"> 14 <li class="swiper-slide">
@@ -64,11 +64,13 @@ function setAvatar($userAvatar) { @@ -64,11 +64,13 @@ function setAvatar($userAvatar) {
64 64
65 function setIndexAction() { 65 function setIndexAction() {
66 var starIScroll; 66 var starIScroll;
  67 + var commonHeaderTop = $('#yoho-header').outerHeight();
67 var $loadingTip = $('.loading-tip'); 68 var $loadingTip = $('.loading-tip');
  69 + var $avatarWrap = $('.avatar-wrap');
68 70
69 // 下拉刷新,上拉加载 71 // 下拉刷新,上拉加载
70 starIScroll = new PullRefresh('.star-wrap', { 72 starIScroll = new PullRefresh('.star-wrap', {
71 - height: $(window).height() - $('#yoho-header').height() - $('.head-tab').height(), 73 + height: $(window).height() - commonHeaderTop,
72 pullDown: function() { 74 pullDown: function() {
73 if (!stopLoading) { 75 if (!stopLoading) {
74 stopLoading = true; 76 stopLoading = true;
@@ -86,8 +88,13 @@ function setIndexAction() { @@ -86,8 +88,13 @@ function setIndexAction() {
86 }); 88 });
87 89
88 starIScroll.iScroll.on('scroll', function() { 90 starIScroll.iScroll.on('scroll', function() {
89 - if (this.startY < -180) {  
90 - console.log('111'); 91 + if (commonHeaderTop > $avatarWrap.offset().top) {
  92 + // $('.avatar-clone').css('top', $('.head-tab').outerHeight());
  93 + $('.avatar-clone').show();
  94 + starIScroll[0].update();
  95 + starIScroll[1].update();
  96 + } else {
  97 + $('.avatar-clone').hide();
91 } 98 }
92 }); 99 });
93 100
@@ -190,7 +197,7 @@ function setIndexAction() { @@ -190,7 +197,7 @@ function setIndexAction() {
190 // } 197 // }
191 198
192 if (bannerLen > 1) { 199 if (bannerLen > 1) {
193 - avatarSwiper[0] = new Swiper('.avatar-0', { 200 + avatarSwiper = new Swiper('.avatar', {
194 loop: true, 201 loop: true,
195 202
196 // loopedSlides: bannerLen, 203 // loopedSlides: bannerLen,
@@ -198,12 +205,15 @@ function setIndexAction() { @@ -198,12 +205,15 @@ function setIndexAction() {
198 centeredSlides: true, 205 centeredSlides: true,
199 slidesPerView: 'auto', 206 slidesPerView: 'auto',
200 spaceBetween: 10, 207 spaceBetween: 10,
201 - slidesOffsetBefore: '-' + $('.avatar-0').find('li').not('.swiper-slide-visible').width() / 2, 208 + slidesOffsetBefore: -($('.avatar').find('li').not('.swiper-slide-visible').width() / 2),
202 watchSlidesProgress: true, 209 watchSlidesProgress: true,
203 watchSlidesVisibility: true, 210 watchSlidesVisibility: true,
204 observer: true, 211 observer: true,
205 observeParents: true 212 observeParents: true
206 }); 213 });
  214 +
  215 + avatarSwiper[0].params.control = avatarSwiper[1];// 需要在Swiper2初始化后,Swiper1控制Swiper2
  216 + avatarSwiper[1].params.control = avatarSwiper[0];// 需要在Swiper1初始化后,Swiper2控制Swiper1
207 } 217 }
208 218
209 // 明星动态头像左右滑动 219 // 明星动态头像左右滑动
@@ -247,6 +257,8 @@ function setIndexAction() { @@ -247,6 +257,8 @@ function setIndexAction() {
247 } 257 }
248 258
249 getIndexHtml = function() { 259 getIndexHtml = function() {
  260 + var $starMain = $('.star-main');
  261 +
250 loading.showLoadingMask(); 262 loading.showLoadingMask();
251 $.ajax({ 263 $.ajax({
252 url: '/guang/star/getIndexHtml', 264 url: '/guang/star/getIndexHtml',
@@ -254,14 +266,15 @@ getIndexHtml = function() { @@ -254,14 +266,15 @@ getIndexHtml = function() {
254 success: function(data) { 266 success: function(data) {
255 stopLoading = false; 267 stopLoading = false;
256 268
257 - console.log(data);  
258 -  
259 if (!data) { 269 if (!data) {
260 stopLoading = true; 270 stopLoading = true;
261 tip.show('没有更多内容了'); 271 tip.show('没有更多内容了');
262 } 272 }
263 273
264 - $('.star-main').html(data); 274 + $starMain.html(data);
  275 + bannerLen = $('.avatar .swiper-slide').length;
  276 +
  277 + $starMain.prepend($('.avatar-swiper').clone().addClass('avatar-clone').hide());
265 278
266 // 限制标题字数 279 // 限制标题字数
267 $('.cont-area').each(function() { 280 $('.cont-area').each(function() {
@@ -270,7 +283,6 @@ getIndexHtml = function() { @@ -270,7 +283,6 @@ getIndexHtml = function() {
270 283
271 loading.hideLoadingMask(); 284 loading.hideLoadingMask();
272 lazyLoad($('img.lazy')); 285 lazyLoad($('img.lazy'));
273 - bannerLen = $('.avatar-0 .swiper-slide').length;  
274 286
275 setTimeout(function() { 287 setTimeout(function() {
276 setIndexAction(); 288 setIndexAction();
@@ -115,10 +115,14 @@ @@ -115,10 +115,14 @@
115 overflow: hidden; 115 overflow: hidden;
116 margin-top: 30px; 116 margin-top: 30px;
117 117
118 - .fixed { 118 + &.avatar-clone {
119 position: fixed; 119 position: fixed;
120 left: 0; 120 left: 0;
121 top: 0; 121 top: 0;
  122 + margin-top: 86px;
  123 + padding: 5px 0;
  124 + background: #000;
  125 + z-index: 9;
122 } 126 }
123 127
124 li { 128 li {