Authored by 郭成尧

info-base

@@ -2,6 +2,16 @@ @@ -2,6 +2,16 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-04-27 14:55:31 3 * @Date: 2017-04-27 14:55:31
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-27 14:56:45 5 + * @Last Modified time: 2017-05-02 13:57:55
6 */ 6 */
7 'use strict'; 7 'use strict';
  8 +
  9 +import {Controller} from 'yoho-mvc';
  10 +
  11 +class DetailController extends Controller {
  12 + constructor() {
  13 + super();
  14 + }
  15 +}
  16 +
  17 +module.exports = DetailController;
1 -/**  
2 - * 逛详情页  
3 - * @author: xuqi<qi.xu@yoho.cn>  
4 - * @date: 2015/10/13  
5 - */  
6 -require('guang/info-index.page.css');  
7 -  
8 -let $ = require('yoho-jquery'),  
9 - ellipsis = require('yoho-mlellipsis'),  
10 - lazyLoad = require('yoho-jquery-lazyload');  
11 -  
12 -let $authorIntro = $('.author .intro');  
13 -  
14 -// collocation block variable  
15 -let $fixedThumbContainer = $(''),  
16 - $coBlock,  
17 - $thumbContainer = $('.thumb-container');  
18 -  
19 -let $sideNav = $('.side-nav'),  
20 - $guangPage = $('.guang-detail-page'),  
21 - $overlay = $('.overlay'),  
22 - $subNav = $('.sub-nav');  
23 -  
24 -let time = 0;  
25 -  
26 -require('common');  
27 -require('plugin/wx-share')();  
28 -require('./detail-dynamic');  
29 -  
30 -let CollactionBlock = require('./collocation-block');  
31 -  
32 -$('#wrapper').css({  
33 - 'overflow-y': 'scroll'  
34 -});  
35 -  
36 -// 初始化iscroll  
37 -function initIscroll() {  
38 - let $yohoHeader = $('.yoho-header');  
39 - let hH = 0,  
40 - winH, tcH, cbH, cbTop, fixedThumbDom;  
41 -  
42 - if (CollactionBlock.exists()) {  
43 - new CollactionBlock();  
44 - }  
45 -  
46 - // 考虑通用头部的影响:对offset().top以及winH做对应偏移  
47 - if ($yohoHeader.length > 0) {  
48 - hH = $yohoHeader.outerHeight();  
49 - }  
50 -  
51 - /*  
52 - myScroll = new IScroll('#wrapper', {  
53 - probeType: 3,  
54 - mouseWheel: true,  
55 - click: true  
56 - });  
57 - document.addEventListener('touchmove', function(e) {  
58 - e.preventDefault();  
59 - }, false);  
60 -  
61 - if (!hasCollocationBlock) {  
62 - myScroll.on('scroll', function() {  
63 - $scroller.trigger('scroll');  
64 - });  
65 - return;  
66 - }  
67 -  
68 - */  
69 -  
70 -  
71 - winH = $(window).height() - hH;  
72 - fixedThumbDom = $fixedThumbContainer[0];  
73 -  
74 - tcH = $thumbContainer ? $thumbContainer.outerHeight() : 0;  
75 - if ($coBlock) {  
76 - cbH = $coBlock.outerHeight();  
77 - cbTop = $coBlock.offset().top - hH;  
78 - }  
79 -  
80 - $(window).on('scroll', function() {  
81 - let sTop = -this.y;  
82 - let classList = fixedThumbDom && fixedThumbDom.className;  
83 -  
84 - if (sTop <= cbTop - winH + tcH) {  
85 - if (classList.indexOf('fixed-bottom') === -1) {  
86 - $fixedThumbContainer  
87 - .addClass('fixed-bottom')  
88 - .removeClass('hide');  
89 - }  
90 - } else if (sTop <= cbTop) {  
91 - if (classList.indexOf('hide') === -1) {  
92 - $fixedThumbContainer  
93 - .addClass('hide')  
94 - .removeClass('fixed-bottom fixed-top');  
95 - }  
96 - } else if (sTop <= cbTop + cbH - tcH) {  
97 - if (classList.indexOf('fixed-top') === -1) {  
98 - $fixedThumbContainer  
99 - .addClass('fixed-top')  
100 - .removeClass('hide absolute')  
101 - .css('top', '');  
102 - }  
103 - } else if (sTop <= cbTop + cbH) {  
104 - if (classList.indexOf('absolute') === -1) {  
105 - $fixedThumbContainer  
106 - .addClass('absolute')  
107 - .removeClass('fixed-top hide');  
108 - }  
109 - fixedThumbDom.style.top = cbTop + hH + cbH - tcH - sTop + 'px';  
110 - } else if (sTop > cbTop + cbH) {  
111 - if (classList.indexOf('hide') === -1) {  
112 - $fixedThumbContainer  
113 - .addClass('hide')  
114 - .removeClass('absolute');  
115 - }  
116 - }  
117 - });  
118 -}  
119 -  
120 /* 1 /*
121 - // window onload 后重新refresh iscroll  
122 - window.onload = function() {  
123 - myScroll && myScroll.refresh();  
124 - };  
125 -  
126 - // 图片加载完成之后重新 refresh iscroll  
127 - $('img').on('load', function() {  
128 - myScroll && myScroll.refresh();  
129 - }); 2 + * @Author: Targaryen
  3 + * @Date: 2017-05-02 13:55:28
  4 + * @Last Modified by: Targaryen
  5 + * @Last Modified time: 2017-05-02 13:59:11
130 */ 6 */
  7 +'use strict';
  8 +require('guang/info-index.page.css');
131 9
132 -// 微信导航  
133 -$('.nav-btn').on('touchstart', function() {  
134 - $sideNav.css('pointer-events', 'none');  
135 - $guangPage.addClass('menu-open');  
136 - $overlay.show().css({  
137 - opacity: 0.3,  
138 - height: $('#scroller').height()  
139 - });  
140 -  
141 - $sideNav.addClass('on');  
142 -  
143 - setTimeout(function() {  
144 - $sideNav.css('pointer-events', 'auto');  
145 - }, 400);  
146 -  
147 - return false;  
148 -});  
149 -  
150 -// 点击一级导航,弹出二级导航  
151 -$sideNav.on('touchend', 'li', function(e) {  
152 - if ($(this).find('.sub-nav').size() > 0) {  
153 - $('.sub-nav').removeClass('show');  
154 - $(this).find('.sub-nav').addClass('show');  
155 - $(this).find('.highlight').removeClass('highlight');  
156 - }  
157 -  
158 - if (e.target.pathname === location.pathname) {  
159 - hideSideBar(); // eslint-disable-line  
160 - return false;  
161 - }  
162 -});  
163 -  
164 -// 返回一级导航,收起二级导航  
165 -$subNav.each(function() {  
166 - $(this).find('li').eq(0).on('click', function() {  
167 - $('.sub-nav').removeClass('show');  
168 - return false;  
169 - });  
170 -}).on('touchstart', function(e) {  
171 - if (e.currentTarget !== e.target) {  
172 - $subNav.find('li').removeClass('current');  
173 - }  
174 -});  
175 -  
176 -// 侧边栏点击背景色变化  
177 -function highlight($elem) {  
178 - $elem.find('li').on('touchstart', function() {  
179 - $elem.find('.highlight').removeClass('highlight');  
180 - $(this).addClass('highlight');  
181 - }).on('touchend touchcancel', function() {  
182 - $(this).removeClass('highlight');  
183 - });  
184 -}  
185 -highlight($sideNav);  
186 -highlight($subNav);  
187 -  
188 -function hideSideBar() {  
189 - if ($guangPage.hasClass('menu-open')) {  
190 - $guangPage.removeClass('menu-open');  
191 - $overlay.hide();  
192 - $('.sub-nav').removeClass('show');  
193 - $sideNav.removeClass('on');  
194 - }  
195 -}  
196 -  
197 -$overlay.on('touchstart', function() {  
198 - hideSideBar();  
199 - return false;  
200 -});  
201 -  
202 -function setCookie(name, value, options) {  
203 - let expires = '',  
204 - path,  
205 - domain,  
206 - secure,  
207 - date;  
208 -  
209 -  
210 - if (typeof value !== 'undefined') {  
211 - options = options || {};  
212 - if (value === null) {  
213 - value = '';  
214 - options.expires = -1;  
215 - }  
216 -  
217 - if (options.expires &&  
218 - (typeof options.expires === 'number' || options.expires.toUTCString)) {  
219 - if (typeof options.expires === 'number') {  
220 - date = new Date();  
221 -  
222 - date.setTime(Date.parse((new Date()).toLocaleDateString()) + 86400 * 1000);  
223 -  
224 - } else {  
225 - date = options.expires;  
226 - }  
227 - expires = '; expires=' + date.toGMTString();  
228 - }  
229 - path = options.path ? '; path=' + options.path : '';  
230 - domain = options.domain ? '; domain=' + options.domain : '';  
231 - secure = options.secure ? '; secure' : '';  
232 - document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');  
233 - }  
234 -}  
235 -  
236 -// 长按二维码埋点  
237 -$('.wei-share').on('touchstart', function() {  
238 - time = setTimeout(function() {  
239 - if (window._yas && window._yas.sendCustomInfo) {  
240 -  
241 - window._yas.sendCustomInfo({  
242 - op: 'YB_PRESS_QRCODE',  
243 - param: JSON.stringify({  
244 - C_ID: window._ChannelVary[window.cookie('_Channel')],  
245 - PAGE_URL: window.location.href  
246 - })  
247 - }, true);  
248 - }  
249 - }, 500);  
250 -});  
251 -  
252 -$('.wei-share').on('touchend', function(e) {  
253 - e.stopPropagation();  
254 - clearTimeout(time);  
255 -});  
256 -  
257 -// 初始化页面,包括是否使用iscorll初始化页面  
258 -// 接口暴露在HTML中,使用压缩名  
259 -(function() {  
260 - let isweixin = navigator.userAgent.indexOf('MicroMessenger') ? true : false;  
261 - let $this, $title;  
262 -  
263 - // pagecache 前端判断是否显示头  
264 - let param = location.search;  
265 - let isHeader = navigator.userAgent.indexOf('MicroMessenger') > -1 ||  
266 - param.indexOf('app_version') > -1 || param.indexOf('appVersion') > -1;  
267 -  
268 - isHeader && $('#yoho-header').remove();  
269 -  
270 - $('.main-wrap').css({  
271 - position: 'static'  
272 - });  
273 -  
274 - ellipsis.init();  
275 -  
276 - if ($('.good-detail-text .name').length > 0) {  
277 - $('.good-detail-text .name').each(function() {  
278 - $this = $(this);  
279 - $title = $this.find('a');  
280 -  
281 - $title[0].mlellipsis(2);  
282 - });  
283 - }  
284 - lazyLoad($('.lazy'));  
285 -  
286 - // title mlellipsis  
287 - $('.info-list .title, .one-good .reco-name').each(function() {  
288 - this.mlellipsis(2);  
289 - });  
290 -  
291 - // offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名  
292 - if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) ===  
293 - parseInt($authorIntro.css('margin-left'), 10))) {  
294 - $authorIntro.css('padding-top', 0);  
295 - }  
296 -  
297 - if (isweixin) {  
298 - $overlay.css('position', 'absolute');  
299 - }  
300 -  
301 - $('#float-layer-close').on('touchend', function() {  
302 - let appClose = window.cookie('_float-layer-app-close') || '0';  
303 -  
304 - // window.setCookie('_float-layer-app-close', 1);  
305 -  
306 - if (parseInt(appClose, 10) === 0) {  
307 - setCookie('_float-layer-app-close', 1, {expires: -1});  
308 -  
309 - } else if (parseInt(appClose, 10) === 1) {  
310 - setCookie('_float-layer-app-close', 2, {expires: -1});  
311 - }  
312 -  
313 - $('#float-layer-app').hide();  
314 - $('.down-bottom').hide();  
315 -  
316 - return false;  
317 - });  
318 -  
319 - if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {  
320 -  
321 - $('#float-layer-btn').on('touchstart', function(e) {  
322 - if (window._yas && window._yas.sendCustomInfo) {  
323 - window._yas.sendCustomInfo({  
324 - op: 'YB_DOWNLOAD_C',  
325 - param: JSON.stringify({  
326 - C_ID: window._ChannelVary[window.cookie('_Channel')],  
327 - TO_URL: 'http://www.yohoshow.com/about/index/yohobuyqr'  
328 - })  
329 - }, true);  
330 - }  
331 -  
332 - window.location = 'http://www.yohoshow.com/about/index/yohobuyqr';  
333 - e.srcEvent.stopPropagation();  
334 - });  
335 -  
336 - if (typeof window.cookie === 'function' && parseInt(window.cookie('_float-layer-app-close'), 10) !== 2) {  
337 - // $('#float-layer-app').show();  
338 - $('.down-bottom').show();  
339 - } else {  
340 - // $('#float-layer-app').hide();  
341 - $('.down-bottom').hide();  
342 - }  
343 - }  
344 -  
345 - initIscroll();  
346 -}()); 10 +const detail = './index';
  11 +const DetailController = require(`${detail}/controller`);
347 12
  13 +new DetailController();