Authored by hongweigao

品牌不发ajax一次处理

@@ -38,15 +38,6 @@ exports.japanKorean = (req, res, next) => { @@ -38,15 +38,6 @@ exports.japanKorean = (req, res, next) => {
38 }).catch(next); 38 }).catch(next);
39 }; 39 };
40 40
41 -exports.getbrandFloorDataAjax = (req, res, next) => {  
42 - const channelType = req.query.channelType || 'boys',  
43 - contentCode = req.query.contentCode || '';  
44 -  
45 - channelModel.getbrandFloorDataAjax(channelType, contentCode).then(data => {  
46 - res.json(data);  
47 - }).catch(next);  
48 -};  
49 -  
50 exports.getNewArrival = (req, res, next) => { 41 exports.getNewArrival = (req, res, next) => {
51 let reqBody = req.body, 42 let reqBody = req.body,
52 pageIndex = reqBody.pageIndex, 43 pageIndex = reqBody.pageIndex,
  1 +/**
  2 + * 频道页 品牌logo helper
  3 + * @author: 高红威<hongwei.gao@yoho.cn>
  4 + * @date: 2016/12/9
  5 + */
  6 +exports.brandLogoList = (brandLogos, showNum) => {
  7 + var out = '<ul>',
  8 + items = brandLogos.logoBrand,
  9 + moreBrand = brandLogos.moreBrand,
  10 + i = 0,
  11 + item = null,
  12 + fillNum = 0;
  13 +
  14 + // 不是每页显示个数的倍数,填充数据
  15 + if (items.length % showNum !== 0) {
  16 + fillNum = showNum - (items.length % showNum);
  17 + for (i = 0; i < fillNum; i++) {
  18 + items.push({
  19 + href: 'javascript:;',
  20 + img: ''
  21 + });
  22 + }
  23 + }
  24 +
  25 + for (i = 0; i < items.length; i++) {
  26 + // item = options.fn(items[i]);
  27 + item = items[i];
  28 + if (i % showNum === 5 || i === 5) {
  29 +
  30 + // 插入切换按钮的位置
  31 + out = out + '<li class="logo-brand-switch" data-page="' + Math.floor(i / showNum) + '">' +
  32 + '<a class="prev iconfont" href="javascript:;">&#xe609;</a>' +
  33 + '<a class="next iconfont" href="javascript:;">&#xe608;</a></li>' +
  34 + '<li data-page="' + Math.floor(i / showNum) + '">' +
  35 + '<a href="' + item.href + '" target="_blank"><img class="lazy" data-original="' +
  36 + item.img + '" alt=""></a>' + '</li>';
  37 + } else if (i !== 0 && i % showNum === 0) {
  38 +
  39 + // 插入more的位置,more占的是下一页第一个brand的位置,所以page是i/17
  40 + out = out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
  41 + '<a href="' + moreBrand + '" target="_blank">MORE ></a></li>' +
  42 + '<li data-page="' + Math.floor(i / showNum) + '">' +
  43 + '<a href="' + item.href + '" target="_blank"><img class="lazy" data-original="' +
  44 + item.img + '" alt=""></a>' + '</li>';
  45 + } else {
  46 + out = out + '<li data-page="' + Math.floor(i / showNum) + '">' +
  47 + '<a href="' + item.href + '" target="_blank"><img class="lazy" data-original="' +
  48 + item.img + '" alt=""></a>' + '</li>';
  49 + }
  50 + }
  51 +
  52 + // 加上最后一个more, more占的是下一页第一个brand的位置,这里已经循环不到brand,所以加在末尾
  53 + return out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
  54 + '<a href="' + moreBrand + '" target="_blank">MORE ></a></li></ul>';
  55 +
  56 +};
@@ -24,7 +24,7 @@ app.use(global.yoho.hbs({ @@ -24,7 +24,7 @@ app.use(global.yoho.hbs({
24 layoutsDir: doraemon, 24 layoutsDir: doraemon,
25 partialsDir: [path.join(__dirname, 'views/partial')], 25 partialsDir: [path.join(__dirname, 'views/partial')],
26 views: path.join(__dirname, 'views/action'), 26 views: path.join(__dirname, 'views/action'),
27 - helpers: global.yoho.helpers 27 + helpers: Object.assign(require('./helper'), global.yoho.helpers)
28 })); 28 }));
29 29
30 // router 30 // router
@@ -159,12 +159,13 @@ const _getSlideData = srcData => { @@ -159,12 +159,13 @@ const _getSlideData = srcData => {
159 * @param {Object} srcData 原始数据 159 * @param {Object} srcData 原始数据
160 * @return {Object} 转换后的数据 160 * @return {Object} 转换后的数据
161 */ 161 */
162 -const _getNewReportFloorData = (args, type, code) => { 162 +const _getNewReportFloorData = (args) => {
163 const title = args[0].data.text; 163 const title = args[0].data.text;
164 let item = args[1].data; 164 let item = args[1].data;
165 let secondItem = args[2].data; 165 let secondItem = args[2].data;
166 let thirdItem = args[3].data; 166 let thirdItem = args[3].data;
167 - let forthItem = args.length === 5 ? args[4] : {}; 167 + let forthItem = args[4] || {};
  168 + let brandLogos = {logoBrand: [], moreBrand: ''};
168 169
169 let list = []; 170 let list = [];
170 171
@@ -199,8 +200,20 @@ const _getNewReportFloorData = (args, type, code) => { @@ -199,8 +200,20 @@ const _getNewReportFloorData = (args, type, code) => {
199 200
200 // logo列表 201 // logo列表
201 if (forthItem.template_name && forthItem.template_name === 'floor') { 202 if (forthItem.template_name && forthItem.template_name === 'floor') {
202 - data.newReport.brandUrl = '/getbrandFloorDataAjax?channelType=' + type +  
203 - '&contentCode=' + code; 203 + // 品牌数据
  204 + _.forEach(forthItem.data, (floorData) => {
  205 + let o = {};
  206 +
  207 + o.href = floorData.url;
  208 + o.img = helpers.image(floorData.src, 185, 86, 2);
  209 + brandLogos.logoBrand.push(o);
  210 + });
  211 +
  212 + if (args[5] && args[5].data[0] && args[5].data[0].url) {
  213 + brandLogos.moreBrand = args[5].data[0].url || '';
  214 + }
  215 +
  216 + data.newReport.brandLogos = brandLogos;
204 } 217 }
205 return floorDatas; 218 return floorDatas;
206 }; 219 };
@@ -224,16 +237,32 @@ const _setChannelType = (obj, type) => { @@ -224,16 +237,32 @@ const _setChannelType = (obj, type) => {
224 */ 237 */
225 const _getPreBrandTopData = (args, type) => { 238 const _getPreBrandTopData = (args, type) => {
226 const title = args[0].data.text; 239 const title = args[0].data.text;
227 - let item = args[1].data; 240 + let item = args[1].data,
  241 + logoItems = args[2] || {},
  242 + brandLogos = {logoBrand: [], moreBrand: ''};
228 243
229 const data = { 244 const data = {
230 preferenceBrands: { 245 preferenceBrands: {
231 name: title, 246 name: title,
232 - imgBrand: [],  
233 - brandUrl: '/getbrandFloorDataAjax?channelType=' + type 247 + imgBrand: []
234 } 248 }
235 }; 249 };
236 250
  251 + // logo列表
  252 + if (logoItems.template_name && logoItems.template_name === 'floor') {
  253 + // 品牌数据
  254 + _.forEach(args[2].data, (floorData) => {
  255 + let o = {};
  256 +
  257 + o.href = floorData.url;
  258 + o.img = helpers.image(floorData.src, 185, 86, 2);
  259 + brandLogos.logoBrand.push(o);
  260 + });
  261 + if (args[3] && args[3].data[0] && args[3].data[0].url) {
  262 + brandLogos.moreBrand = args[3].data[0].url;
  263 + }
  264 + data.preferenceBrands.brandLogos = brandLogos;
  265 + }
237 data.preferenceBrands.imgBrand = item; 266 data.preferenceBrands.imgBrand = item;
238 if (type === 'kids') { 267 if (type === 'kids') {
239 data.preferenceBrands.sliderColor = '#7AD3F8'; 268 data.preferenceBrands.sliderColor = '#7AD3F8';
@@ -798,7 +827,7 @@ const _processJKFloorData = (rawData, type, code) => { @@ -798,7 +827,7 @@ const _processJKFloorData = (rawData, type, code) => {
798 827
799 // 最新速报 828 // 最新速报
800 if (text.indexOf('最新速报') >= 0) { 829 if (text.indexOf('最新速报') >= 0) {
801 - floorData = _getNewReportFloorData(rawData.slice(index, index + 5), type, code); 830 + floorData = _getNewReportFloorData(rawData.slice(index, index + 6));
802 831
803 // 单个图作为最新速报模块用过的,标识一下,不作为广告位了 832 // 单个图作为最新速报模块用过的,标识一下,不作为广告位了
804 _.filter(rawData.slice(index, index + 5), function(o) { 833 _.filter(rawData.slice(index, index + 5), function(o) {
@@ -1119,39 +1148,39 @@ const getJKContent = (req) => { @@ -1119,39 +1148,39 @@ const getJKContent = (req) => {
1119 return Promise.all([headerModel.requestHeaderData(channel), 1148 return Promise.all([headerModel.requestHeaderData(channel),
1120 _requestContent(channel, {}, contentCode)]).then(res => { 1149 _requestContent(channel, {}, contentCode)]).then(res => {
1121 1150
1122 - let headerData = res[0].data || res[0],  
1123 - contentData = res[1].data ? res[1].data.list : res[1]; 1151 + let headerData = res[0].data || res[0],
  1152 + contentData = res[1].data ? res[1].data.list : res[1];
1124 1153
1125 - let data = {}; 1154 + let data = {};
1126 1155
1127 - const processResult = _processJKFloorData(contentData, channel, contentCode); 1156 + const processResult = _processJKFloorData(contentData, channel, contentCode);
1128 1157
1129 - data = headerData;  
1130 - data.module = 'channel';  
1131 - data.page = 'channel';  
1132 - data.pageType = channel;  
1133 - data.mchannel = 'japanKorean';// 子频道,如日韩馆  
1134 - data.footerTop = true;  
1135 - data.channel = processResult.floors; 1158 + data = headerData;
  1159 + data.module = 'channel';
  1160 + data.page = 'channel';
  1161 + data.pageType = channel;
  1162 + data.mchannel = 'japanKorean';// 子频道,如日韩馆
  1163 + data.footerTop = true;
  1164 + data.channel = processResult.floors;
1136 1165
1137 1166
1138 - return {  
1139 - rawData: contentData,  
1140 - floorData: data,  
1141 - searchPromise: processResult.promise,  
1142 - singlehotFloorIndex: processResult.singlehotFloorIndex,  
1143 - singlehotFloorTitle: processResult.singlehotFloorTitle,  
1144 - queryParams: processResult.queryParams,  
1145 - channelType: channel  
1146 - }; 1167 + return {
  1168 + rawData: contentData,
  1169 + floorData: data,
  1170 + searchPromise: processResult.promise,
  1171 + singlehotFloorIndex: processResult.singlehotFloorIndex,
  1172 + singlehotFloorTitle: processResult.singlehotFloorTitle,
  1173 + queryParams: processResult.queryParams,
  1174 + channelType: channel
  1175 + };
1147 1176
1148 - }).then(result => { 1177 + }).then(result => {
1149 1178
1150 // 如果有promise则做相应处理 1179 // 如果有promise则做相应处理
1151 - if (result.searchPromise.length) {  
1152 - return Promise.all(result.searchPromise).then(res => {  
1153 - _.forEach(res, (data, index) => {  
1154 - result.floorData.channel 1180 + if (result.searchPromise.length) {
  1181 + return Promise.all(result.searchPromise).then(res => {
  1182 + _.forEach(res, (data, index) => {
  1183 + result.floorData.channel
1155 .splice(result.singlehotFloorIndex[index], 0, 1184 .splice(result.singlehotFloorIndex[index], 0,
1156 _processFloorDataWithQueryReusult( 1185 _processFloorDataWithQueryReusult(
1157 result.rawData, 1186 result.rawData,
@@ -1160,57 +1189,14 @@ const getJKContent = (req) => { @@ -1160,57 +1189,14 @@ const getJKContent = (req) => {
1160 result.singlehotFloorTitle[index], 1189 result.singlehotFloorTitle[index],
1161 result.channelType 1190 result.channelType
1162 )); 1191 ));
1163 - }); 1192 + });
1164 1193
1165 - return result.floorData; 1194 + return result.floorData;
  1195 + });
  1196 + } else {
  1197 + return result.floorData || result;
  1198 + }
1166 }); 1199 });
1167 - } else {  
1168 - return result.floorData || result;  
1169 - }  
1170 - });  
1171 -};  
1172 -  
1173 -  
1174 -// 品牌楼层floorData-ajax  
1175 -const getbrandFloorDataAjax = (type, code) => {  
1176 - let params = {new_device: 'Y'};  
1177 -  
1178 - return _requestContent(type, params, code).then(res => {  
1179 - let contentData = res.data ? res.data.list : [];  
1180 -  
1181 - let data = {  
1182 - logoBrand: [],  
1183 - moreBrand: ''  
1184 - };  
1185 -  
1186 - _.forEach(contentData, (d, index) => {  
1187 - let logoIndex = index;  
1188 -  
1189 - // 频道页,有两处logo列表,一处优选品牌后面;一处最新速报后面,此处判断  
1190 - if (d.data && d.data.text && d.data.text.indexOf('优选品牌') >= 0) {  
1191 - logoIndex = index + 2;  
1192 - } else if (d.data && d.data.text && d.data.text.indexOf('最新速报') >= 0) {  
1193 - logoIndex = index + 4;  
1194 - }  
1195 -  
1196 - if (logoIndex !== index) {  
1197 - _.forEach(contentData[logoIndex].data, (floorData) => {  
1198 - let o = {};  
1199 -  
1200 - o.href = floorData.url;  
1201 - o.img = helpers.image(floorData.src, 185, 86, 2);  
1202 -  
1203 - data.logoBrand.push(o);  
1204 - });  
1205 - data.moreBrand = contentData[logoIndex + 1].data[0].url;  
1206 -  
1207 - return false;  
1208 - }  
1209 -  
1210 - });  
1211 -  
1212 - return data;  
1213 - });  
1214 }; 1200 };
1215 1201
1216 const getResourceData = (formatData) => { 1202 const getResourceData = (formatData) => {
@@ -1273,7 +1259,6 @@ module.exports = { @@ -1273,7 +1259,6 @@ module.exports = {
1273 getNewArrival: getNewArrival, 1259 getNewArrival: getNewArrival,
1274 getContent: getContent, 1260 getContent: getContent,
1275 getJKContent: getJKContent, 1261 getJKContent: getJKContent,
1276 - getbrandFloorDataAjax: getbrandFloorDataAjax,  
1277 getIndexGuideData: getIndexGuideData, 1262 getIndexGuideData: getIndexGuideData,
1278 formatIndexGuideData: formatIndexGuideData, 1263 formatIndexGuideData: formatIndexGuideData,
1279 getResourceData: getResourceData, 1264 getResourceData: getResourceData,
@@ -21,7 +21,6 @@ router.get('/japanKorean', channelController.japanKorean); @@ -21,7 +21,6 @@ router.get('/japanKorean', channelController.japanKorean);
21 router.get('/channel/isNewUserAjax', channelController.hasNewUserFloor); 21 router.get('/channel/isNewUserAjax', channelController.hasNewUserFloor);
22 22
23 // ajax 23 // ajax
24 -router.get('/getbrandFloorDataAjax', channelController.getbrandFloorDataAjax);  
25 router.post('/common/getNewArrival', channelController.getNewArrival); 24 router.post('/common/getNewArrival', channelController.getNewArrival);
26 router.get('/guide', channelController.getIndexGuide); 25 router.get('/guide', channelController.getIndexGuide);
27 26
1 -<div class="preference-brand">  
2 - <div class="img-brand">  
3 - <ul class="img-list imgopacity clearfix">  
4 - {{# imgBrand}}  
5 - <li class="img-item">  
6 - <a href="{{url}}" target= "_blank">  
7 - <img data-original="{{image src 378 175}}" src="{{image src 378 175}}" alt="">  
8 - </a>  
9 - </li>  
10 - {{/ imgBrand}}  
11 - </ul>  
12 - <div class="img-brand-switch">  
13 - <a class="prev" href="javascript:;">  
14 - <span class="iconfont">&#xe609;</span>  
15 - </a>  
16 - <a class="next" href="javascript:;">  
17 - <span class="iconfont">&#xe608;</span>  
18 - </a>  
19 - </div>  
20 - </div>  
21 - <div class="logo-brand imgopacity" data-url="{{brandUrl}}"></div>  
22 -</div> 1 +<div class="preference-brand">
  2 + <div class="img-brand">
  3 + <ul class="img-list imgopacity clearfix">
  4 + {{# imgBrand}}
  5 + <li class="img-item">
  6 + <a href="{{url}}" target= "_blank">
  7 + <img data-original="{{image src 378 175}}" src="{{image src 378 175}}" alt="">
  8 + </a>
  9 + </li>
  10 + {{/ imgBrand}}
  11 + </ul>
  12 + <div class="img-brand-switch">
  13 + <a class="prev" href="javascript:;">
  14 + <span class="iconfont">&#xe609;</span>
  15 + </a>
  16 + <a class="next" href="javascript:;">
  17 + <span class="iconfont">&#xe608;</span>
  18 + </a>
  19 + </div>
  20 + </div>
  21 + {{#if brandLogos}}
  22 + <div class="logo-brand imgopacity" data-showNum="16">
  23 + {{{brandLogoList brandLogos 16}}}
  24 + </div>
  25 + {{/if}}
  26 +</div>
1 -<div class="preference-brand imgopacity">  
2 - <div class="img-slider-wrapper clearfix" style="background-color:{{sliderColor}};">  
3 - <div class="img-brand-switch">  
4 - <a class="prev iconfont" href="javascript:;">&#xe609;</a>  
5 - <a class="next iconfont" href="javascript:;">&#xe608;</a>  
6 - </div>  
7 - <div class="img-container-landscape">  
8 - <ul class="img-list">  
9 - {{# imgBrand}}  
10 - <li class="img-item">  
11 - <a href="{{url}}" target= "_blank">  
12 - <img data-original="{{image src 320 430}}" src="{{image src 320 430}}" alt="{{alt}}">  
13 - </a>  
14 - </li>  
15 - {{/ imgBrand}}  
16 - </ul>  
17 - </div>  
18 - </div>  
19 - <div class="logo-brand " data-url="{{brandUrl}}">  
20 - </div>  
21 -</div> 1 +<div class="preference-brand imgopacity">
  2 + <div class="img-slider-wrapper clearfix" style="background-color:{{sliderColor}};">
  3 + <div class="img-brand-switch">
  4 + <a class="prev iconfont" href="javascript:;">&#xe609;</a>
  5 + <a class="next iconfont" href="javascript:;">&#xe608;</a>
  6 + </div>
  7 + <div class="img-container-landscape">
  8 + <ul class="img-list">
  9 + {{# imgBrand}}
  10 + <li class="img-item">
  11 + <a href="{{url}}" target= "_blank">
  12 + <img data-original="{{image src 320 430}}" src="{{image src 320 430}}" alt="{{alt}}">
  13 + </a>
  14 + </li>
  15 + {{/ imgBrand}}
  16 + </ul>
  17 + </div>
  18 + </div>
  19 + {{#if brandLogos}}
  20 + <div class="logo-brand" data-showNum="10">
  21 + {{{brandLogoList brandLogos 10}}}
  22 + </div>
  23 + {{/if}}
  24 +</div>
@@ -27,7 +27,9 @@ @@ -27,7 +27,9 @@
27 </div> 27 </div>
28 {{/if}} 28 {{/if}}
29 {{/ list}} 29 {{/ list}}
30 - {{#if brandUrl}}  
31 - <div class="logo-brand" data-url="{{brandUrl}}"></div> 30 + {{#if brandLogos}}
  31 + <div class="logo-brand" data-showNum="10">
  32 + {{{brandLogoList brandLogos 10}}}
  33 + </div>
32 {{/if}} 34 {{/if}}
33 </div> 35 </div>
@@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 lazyLoad = require('yoho-jquery-lazyload'); 8 lazyLoad = require('yoho-jquery-lazyload');
9 - 9 +console.log($('.logo-brand'));
10 var homePage = $('.home-page').data('page'), 10 var homePage = $('.home-page').data('page'),
11 - brandUrl = $('.logo-brand').data('url'), 11 + shownum = $('.logo-brand').data('shownum'),
12 mChannel = $('.home-page').data('mchannel') || ''; 12 mChannel = $('.home-page').data('mchannel') || '';
13 13
14 var newArrParams = {}; 14 var newArrParams = {};
@@ -65,14 +65,13 @@ if (homePage === 'boys') { @@ -65,14 +65,13 @@ if (homePage === 'boys') {
65 65
66 if (homePage === 'boys') { 66 if (homePage === 'boys') {
67 $('.logo-brand').logoBrand({ 67 $('.logo-brand').logoBrand({
68 - url: brandUrl 68 + showNum: shownum
69 }); 69 });
70 70
71 $('.img-brand').slider2({autoplay: true}); 71 $('.img-brand').slider2({autoplay: true});
72 } else { 72 } else {
73 $('.logo-brand').logoBrand({ 73 $('.logo-brand').logoBrand({
74 - showNum: 10,  
75 - url: brandUrl 74 + showNum: shownum
76 }); 75 });
77 $('.img-slider-wrapper').slider2({autoplay: true}); 76 $('.img-slider-wrapper').slider2({autoplay: true});
78 } 77 }
@@ -5,11 +5,11 @@ @@ -5,11 +5,11 @@
5 */ 5 */
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 - Handlebars = require('yoho-handlebars'),  
9 lazyLoad = require('yoho-jquery-lazyload'); 8 lazyLoad = require('yoho-jquery-lazyload');
10 9
11 (function() { 10 (function() {
12 var LogoBrand = function(element, options) { 11 var LogoBrand = function(element, options) {
  12 + console.log(options);
13 this.$element = $(element); 13 this.$element = $(element);
14 this.options = $.extend({}, $.fn.logoBrand.defaults, options); 14 this.options = $.extend({}, $.fn.logoBrand.defaults, options);
15 15
@@ -19,81 +19,8 @@ var $ = require('yoho-jquery'), @@ -19,81 +19,8 @@ var $ = require('yoho-jquery'),
19 LogoBrand.prototype = { 19 LogoBrand.prototype = {
20 init: function() { 20 init: function() {
21 this.$element.addClass('logos-' + this.options.showNum); 21 this.$element.addClass('logos-' + this.options.showNum);
22 - this._sendRequest();  
23 - },  
24 - _createHelper: function() {  
25 - var showNum = this.options.showNum;  
26 -  
27 - Handlebars.registerHelper('brandList', function(items, options) {  
28 - var out = '<ul>',  
29 - i = 0,  
30 - item = null,  
31 - fillNum = 0;  
32 -  
33 - // 不是每页显示个数的倍数,填充数据  
34 - if (items.length % showNum !== 0) {  
35 - fillNum = showNum - (items.length % showNum);  
36 - for (i = 0; i < fillNum; i++) {  
37 - items.push({  
38 - href: 'javascript:;',  
39 - img: ''  
40 - });  
41 - }  
42 - }  
43 -  
44 - for (i = 0; i < items.length; i++) {  
45 - item = options.fn(items[i]);  
46 -  
47 - if (i % showNum === 5 || i === 5) {  
48 -  
49 - // 插入切换按钮的位置  
50 - out = out + '<li class="logo-brand-switch" data-page="' + Math.floor(i / showNum) + '">' +  
51 - '<a class="prev iconfont" href="javascript:;">&#xe609;</a>' +  
52 - '<a class="next iconfont" href="javascript:;">&#xe608;</a></li>' +  
53 - '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';  
54 - } else if (i !== 0 && i % showNum === 0) {  
55 -  
56 - // 插入more的位置,more占的是下一页第一个brand的位置,所以page是i/17  
57 - out = out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +  
58 - '<a href="javascript:;" target="_blank">MORE ></a></li>' +  
59 - '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';  
60 - } else {  
61 - out = out + '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';  
62 - }  
63 - }  
64 -  
65 - // 加上最后一个more, more占的是下一页第一个brand的位置,这里已经循环不到brand,所以加在末尾  
66 - return out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +  
67 - '<a href="javascript:;" target="_blank">MORE ></a></li></ul>';  
68 -  
69 - });  
70 - },  
71 - _sendRequest: function() {  
72 - var that = this;  
73 -  
74 - $.ajax({  
75 - type: 'GET',  
76 - url: that.options.url,  
77 - dataType: 'json',  
78 - success: function(data) {  
79 - var brandTpl,  
80 - brandHtml;  
81 -  
82 - if (!data || data.length === 0) {  
83 - return;  
84 - }  
85 -  
86 - that._createHelper();  
87 - brandHtml = '\{{#brandList logoBrand}}' +  
88 - '<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' +  
89 - '\{{/brandList}}';  
90 - brandTpl = Handlebars.compile(brandHtml);  
91 - that.$element.html(brandTpl(data));  
92 - that.$element.find('.brand-more a').attr('href', data.moreBrand);  
93 - lazyLoad(that.$element.find('img.lazy'));  
94 - that._bindEvent();  
95 - }  
96 - }); 22 + lazyLoad(this.$element.find('img.lazy'));
  23 + this._bindEvent();
97 }, 24 },
98 _brandShow: function(hidePage, showPage) { 25 _brandShow: function(hidePage, showPage) {
99 var that = this; 26 var that = this;