Authored by 陈轩

Merge remote-tracking branch 'origin/release/5.1' into release/5.1

@@ -47,12 +47,25 @@ exports.index = (req, res, next) => { @@ -47,12 +47,25 @@ exports.index = (req, res, next) => {
47 * 潮流优选首页-资源位 47 * 潮流优选首页-资源位
48 */ 48 */
49 exports.resourcesTemplate = (req, res, next) => { 49 exports.resourcesTemplate = (req, res, next) => {
50 - let code = req.query.code || '';  
51 let isApp = req.query.app_version || req.query.appVersion || false; 50 let isApp = req.query.app_version || req.query.appVersion || false;
  51 + let uid = '';
  52 + let param = {};
52 53
53 - plusstarModel.getResources({  
54 - content_code: code  
55 - }, { 54 + if (req.yoho.isApp) {
  55 + uid = req.query.uid;
  56 + } else {
  57 + uid = req.user.uid;
  58 + }
  59 +
  60 + if (uid) {
  61 + param.uid = uid;
  62 + }
  63 +
  64 + param.content_code = req.query.code || '';
  65 + param.yh_channel = req.query.yh_channel || 1;
  66 +
  67 +
  68 + plusstarModel.getResourcesData(param, {
56 isApp: isApp 69 isApp: isApp
57 }).then(result => { 70 }).then(result => {
58 res.render('plusstar/resources-template', { 71 res.render('plusstar/resources-template', {
@@ -62,3 +75,29 @@ exports.resourcesTemplate = (req, res, next) => { @@ -62,3 +75,29 @@ exports.resourcesTemplate = (req, res, next) => {
62 }); 75 });
63 }).catch(next); 76 }).catch(next);
64 }; 77 };
  78 +
  79 +/**
  80 + * 潮流优选首页-资源位-商品列表
  81 + */
  82 +exports.resourcesGoodsList = (req, res, next) => {
  83 + let productSkn = req.body.productSkn || '';
  84 + let isApp = req.body.app_version || req.body.appVersion || false;
  85 + let param = {};
  86 +
  87 + param = {
  88 + productSkn: productSkn.split(','),
  89 + yh_channel: req.body.yh_channel,
  90 + page: req.body.page,
  91 + limit: req.body.limit
  92 + };
  93 +
  94 + plusstarModel.getProductBatch(param, {
  95 + isApp: isApp
  96 + }).then(result => {
  97 + res.render('plusstar/resources-goodsList', {
  98 + layout: false,
  99 + result: result,
  100 + title: '潮流优选'
  101 + });
  102 + }).catch(next);
  103 +};
@@ -45,17 +45,40 @@ const getAllChannels = (params) => { @@ -45,17 +45,40 @@ const getAllChannels = (params) => {
45 * @param {[string || array]} productSkn 商品skn 45 * @param {[string || array]} productSkn 商品skn
46 * @return {[array]} 46 * @return {[array]}
47 */ 47 */
48 -const getProductBatch = (productSkn, options) => {  
49 - productSkn = _.isArray(productSkn) ? productSkn : [productSkn]; 48 +const getProductBatch = (param, options) => {
  49 + param.productSkn = _.isArray(param.productSkn) ? param.productSkn : [param.productSkn];
50 return api.get('', { 50 return api.get('', {
51 method: 'h5.product.batch', 51 method: 'h5.product.batch',
52 - productSkn: productSkn.join(',') 52 + productSkn: param.productSkn.join(','),
  53 + yh_channel: param.yh_channel,
  54 + page: param.page,
  55 + limit: param.limit
53 }).then(result => { 56 }).then(result => {
54 - return result && result.data ? productProcess.processProductList(result.data.product_list, options) : []; 57 + let data = {};
  58 +
  59 + if (result && result.data) {
  60 + data = {
  61 + page_total: result.data.page_total,
  62 + product_list: productProcess.processProductList(result.data.product_list, options)
  63 + };
  64 + }
  65 + return data;
55 }); 66 });
56 }; 67 };
57 68
58 /** 69 /**
  70 + * 商品推荐获取
  71 + * @param {[int]} yh_channel 当前频道
  72 + * @param {[int]} uid 用户id
  73 + * @return {[array]}
  74 + */
  75 +const getFashionPrefer = (params) => {
  76 + return api.get('', Object.assign({
  77 + method: 'h5.product.fashionPrefer'
  78 + }, params));
  79 +};
  80 +
  81 +/**
59 * 获取资源位数据 82 * 获取资源位数据
60 * @param {[string]} content_code 83 * @param {[string]} content_code
61 * @return {[array]} 84 * @return {[array]}
@@ -88,10 +111,11 @@ const getResources = (params, options) => { @@ -88,10 +111,11 @@ const getResources = (params, options) => {
88 }; 111 };
89 112
90 if (res.focus_type * 1 === 1) { 113 if (res.focus_type * 1 === 1) {
91 - data.focus1 = [];  
92 - data.focus1.push(list); 114 + data.focus1 = list;
  115 + data.focus1.id = res.template_id;
93 } else { 116 } else {
94 data.focus2 = list; 117 data.focus2 = list;
  118 + data.focus2.id = res.template_id;
95 } 119 }
96 120
97 break; 121 break;
@@ -101,6 +125,7 @@ const getResources = (params, options) => { @@ -101,6 +125,7 @@ const getResources = (params, options) => {
101 } 125 }
102 126
103 list = { 127 list = {
  128 + id: res.template_id,
104 title: res.data.title, 129 title: res.data.title,
105 moreUrl: res.data.more_url, 130 moreUrl: res.data.more_url,
106 moreName: res.data.more_name, 131 moreName: res.data.more_name,
@@ -118,8 +143,10 @@ const getResources = (params, options) => { @@ -118,8 +143,10 @@ const getResources = (params, options) => {
118 143
119 if (res.data.title.name === '热门商品') { 144 if (res.data.title.name === '热门商品') {
120 data.goods.title = list; 145 data.goods.title = list;
  146 + data.goods.id = res.template_id;
121 } else if (res.data.title.name === '热门品类') { 147 } else if (res.data.title.name === '热门品类') {
122 data.recommend.title = list; 148 data.recommend.title = list;
  149 + data.recommend.id = res.template_id;
123 } 150 }
124 151
125 break; 152 break;
@@ -138,19 +165,30 @@ const getResources = (params, options) => { @@ -138,19 +165,30 @@ const getResources = (params, options) => {
138 } 165 }
139 }); 166 });
140 167
141 - if (_.isEmpty(data.goods.productSkns)) {  
142 - return data; 168 + return data;
  169 + });
  170 +};
  171 +
  172 +const getResourcesData = (params, options) => {
  173 + return api.all([
  174 + getResources(params, options),
  175 + getFashionPrefer(params)
  176 + ]).then(result => {
  177 + let skns = result[0] && result[0].goods && result[0].goods.productSkns || [];
  178 + let preferSkns = result[1] && result[1].data || [];
  179 +
  180 + if (result[0] && result[0].goods && result[0].goods.productSkns) {
  181 + result[0].goods.productSkns = _.uniq(Object.assign(skns, preferSkns));
143 } 182 }
144 183
145 - return getProductBatch(data.goods.productSkns, options).then(res => {  
146 - data.goods.data = res;  
147 - return data;  
148 - }); 184 + return result[0];
149 }); 185 });
150 }; 186 };
151 187
152 module.exports = { 188 module.exports = {
153 getAllChannels, 189 getAllChannels,
154 getResources, 190 getResources,
155 - getProductBatch 191 + getFashionPrefer,
  192 + getProductBatch,
  193 + getResourcesData
156 }; 194 };
@@ -36,29 +36,29 @@ const getRssArticle = (gender) => { @@ -36,29 +36,29 @@ const getRssArticle = (gender) => {
36 return articlePromise.then((article) => { 36 return articlePromise.then((article) => {
37 // 内容列表 37 // 内容列表
38 if (article.data.list.artList) { 38 if (article.data.list.artList) {
39 - let build = {}; 39 + let build = {};
40 40
41 - let artListFunc = (i, len, resolve) => {  
42 - if (i < len) {  
43 - let value = article.data.list.artList[i];  
44 - if (typeof value.id !== 'undefined') {  
45 - build = guangProcess.formatArticle(value, false, false, true);  
46 - build.author.name = build.author.name || '';  
47 - return _genIntro(value.id).then((intro) => {  
48 - build.intro = intro;  
49 - result.push(build);  
50 - artListFunc(++i, len, resolve);  
51 - });  
52 - }  
53 - } else { 41 + let artListFunc = (i, len, resolve) => {
  42 + if (i < len) {
  43 + let value = article.data.list.artList[i];
  44 + if (typeof value.id !== 'undefined') {
  45 + build = guangProcess.formatArticle(value, false, false, true);
  46 + build.author.name = build.author.name || '';
  47 + return _genIntro(value.id).then((intro) => {
  48 + build.intro = intro;
  49 + result.push(build);
  50 + artListFunc(++i, len, resolve);
  51 + });
  52 + }
  53 + } else {
54 resolve(result); 54 resolve(result);
55 - }  
56 - }; 55 + }
  56 + };
57 return new Promise((resolve) => { 57 return new Promise((resolve) => {
58 artListFunc(0, article.data.list.artList.length, resolve); 58 artListFunc(0, article.data.list.artList.length, resolve);
59 - }); 59 + });
60 60
61 - } 61 + }
62 }); 62 });
63 }; 63 };
64 64
@@ -75,18 +75,18 @@ const _genIntro = (id) => { @@ -75,18 +75,18 @@ const _genIntro = (id) => {
75 resData.data.forEach((value) => { 75 resData.data.forEach((value) => {
76 if (value.text) { // 文字 76 if (value.text) { // 文字
77 result += htmlProcess.removeHtml(htmlProcess.escapeToHtml(value.text.data.text)) + '<br/>'; 77 result += htmlProcess.removeHtml(htmlProcess.escapeToHtml(value.text.data.text)) + '<br/>';
78 - } else if (value.singleImage) { // 单张图  
79 - result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`; 78 + } else if (value.singleImage) { // 单张图
  79 + result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;
80 } else if (value.smallPic && value.smallPic.data) { // 多张小图 80 } else if (value.smallPic && value.smallPic.data) { // 多张小图
81 - value.smallPic.data.forEach((small) => {  
82 - result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;  
83 - });  
84 - result += '<br/>'; 81 + value.smallPic.data.forEach((small) => {
  82 + result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;
  83 + });
  84 + result += '<br/>';
85 } 85 }
86 - }); 86 + });
87 return result; 87 return result;
88 - }  
89 - }); 88 + }
  89 + });
90 90
91 }; 91 };
92 module.exports = { 92 module.exports = {
@@ -32,6 +32,7 @@ router.get('/', homeController.index); // 逛首页 @@ -32,6 +32,7 @@ router.get('/', homeController.index); // 逛首页
32 32
33 router.get('/plusstar', plusstar.index); // 潮流优选 33 router.get('/plusstar', plusstar.index); // 潮流优选
34 router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位 34 router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位
  35 +router.post('/plusstar/resources-goodsList', plusstar.resourcesGoodsList); // 潮流优选首页-资源位-商品列表
35 router.get('/', index.index); // 逛首页 36 router.get('/', index.index); // 逛首页
36 router.get('/tags/index', index.tag); // 逛标签页 37 router.get('/tags/index', index.tag); // 逛标签页
37 38
1 -<div class='plusstar-page'> 1 +<div class='yoho-page plusstar-page'>
2 {{#if result.channel}} 2 {{#if result.channel}}
3 <div class="tab-nav"> 3 <div class="tab-nav">
4 <ul> 4 <ul>
  1 +{{#if result.product_list}}
  2 + <input type='hidden' value='{{result.page_total}}' class='page-total' />
  3 +{{/if}}
  4 +{{#each result.product_list}}
  5 + {{> common/goods}}
  6 +{{/each}}
1 <div class="resources"> 1 <div class="resources">
2 <!--banner--> 2 <!--banner-->
3 - {{#each result.focus1}} 3 + {{#if result.focus1}}
4 <div class="banner-top"> 4 <div class="banner-top">
5 <div class="banner-swiper swiper-container"> 5 <div class="banner-swiper swiper-container">
6 - <ul class="swiper-wrapper">  
7 - {{#each data}} 6 + <ul class="swiper-wrapper" data-id={{result.focus1.id}}>
  7 + {{#each result.focus1.data}}
8 {{#if @first}} 8 {{#if @first}}
9 <li class="swiper-slide"> 9 <li class="swiper-slide">
10 <a href="{{url}}"> 10 <a href="{{url}}">
@@ -27,9 +27,10 @@ @@ -27,9 +27,10 @@
27 </div> 27 </div>
28 </div> 28 </div>
29 </div> 29 </div>
30 - {{/each}} 30 + {{/if}}
31 31
32 {{#each result.title_image}} 32 {{#each result.title_image}}
  33 + <div class='speck-title-image' data-fid='{{id}}' data-name='{{title}}'>
33 <div class="header-title"> 34 <div class="header-title">
34 {{title}} 35 {{title}}
35 <a class="more" href="{{moreUrl}}">{{moreName}}</a> 36 <a class="more" href="{{moreUrl}}">{{moreName}}</a>
@@ -39,10 +40,11 @@ @@ -39,10 +40,11 @@
39 <img class="lazy" data-original="{{image image.src 750 364}}"> 40 <img class="lazy" data-original="{{image image.src 750 364}}">
40 </a> 41 </a>
41 </div> 42 </div>
  43 + </div>
42 {{/each}} 44 {{/each}}
43 45
44 {{#if result.focus2.data}} 46 {{#if result.focus2.data}}
45 - <div class="focus-left-right"> 47 + <div class="focus-left-right speck-title-image" data-fid='{{result.focus2.id}}' data-name='焦点图'>
46 {{#each result.focus2.data}} 48 {{#each result.focus2.data}}
47 <a href="{{url}}" title="{{title}}"> 49 <a href="{{url}}" title="{{title}}">
48 <img class="lazy" data-original="{{image src 250 250}}"> 50 <img class="lazy" data-original="{{image src 250 250}}">
@@ -52,7 +54,9 @@ @@ -52,7 +54,9 @@
52 {{/if}} 54 {{/if}}
53 <!--/focus-left-right--> 55 <!--/focus-left-right-->
54 56
55 - {{#if result.recommend.title}} 57 + {{#if result.recommend}}
  58 + <div class='speck-title-image' data-fid='{{result.recommend.id}}' data-name='{{result.recommend.title.name}}'>
  59 + {{#if result.recommend.title}}
56 <div class="header-title"> 60 <div class="header-title">
57 {{result.recommend.title.name}} 61 {{result.recommend.title.name}}
58 <a class="more" href="{{result.recommend.title.moreUrl}}"> 62 <a class="more" href="{{result.recommend.title.moreUrl}}">
@@ -63,12 +67,14 @@ @@ -63,12 +67,14 @@
63 {{#if result.recommend.data}} 67 {{#if result.recommend.data}}
64 <div class="recommend-content-five"> 68 <div class="recommend-content-five">
65 {{#each result.recommend.data}} 69 {{#each result.recommend.data}}
66 - <a href="{{url}}" title="{{title}}"> 70 + <a href="{{url}}">
67 <img class="lazy" data-original="{{image src 375 375}}"> 71 <img class="lazy" data-original="{{image src 375 375}}">
68 </a> 72 </a>
69 {{/each}} 73 {{/each}}
70 </div> 74 </div>
71 {{/if}} 75 {{/if}}
  76 + </div>
  77 + {{/if}}
72 78
73 {{#if result.goods.title}} 79 {{#if result.goods.title}}
74 <div class="header-title"> 80 <div class="header-title">
@@ -76,13 +82,12 @@ @@ -76,13 +82,12 @@
76 <a class="more" href="{{result.goods.title.moreUrl}}"> 82 <a class="more" href="{{result.goods.title.moreUrl}}">
77 {{result.goods.title.moreName}} 83 {{result.goods.title.moreName}}
78 </a> 84 </a>
  85 + <input type='hidden' value='{{result.goods.productSkns}}' class='product-skns' />
79 </div> 86 </div>
80 87
81 <div class="goods clearfix"> 88 <div class="goods clearfix">
82 <!--商品---> 89 <!--商品--->
83 - {{#each result.goods.data}}  
84 - {{> common/goods}}  
85 - {{/each}} 90 +
86 </div><!--/goods--> 91 </div><!--/goods-->
87 {{/if}} 92 {{/if}}
88 93
@@ -162,4 +162,4 @@ if ($('#noData').length > 0) { @@ -162,4 +162,4 @@ if ($('#noData').length > 0) {
162 $mask.on('click', function() { 162 $mask.on('click', function() {
163 $mask.hide(); 163 $mask.hide();
164 $message.hide(); 164 $message.hide();
165 -});  
  165 +});
@@ -14,6 +14,8 @@ var $footer = $('#yoho-footer'), @@ -14,6 +14,8 @@ var $footer = $('#yoho-footer'),
14 var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) + 14 var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) +
15 '_' + Math.floor(Math.random() * 1000000 + 1000000)); 15 '_' + Math.floor(Math.random() * 1000000 + 1000000));
16 16
  17 +var _ChannelVary = {boys: 1, girls: 2, kids: 3, lifestyle: 4};
  18 +
17 function cookie(name) { 19 function cookie(name) {
18 var cookies = document.cookie, 20 var cookies = document.cookie,
19 cookieVal, 21 cookieVal,
@@ -195,8 +197,7 @@ function reMarginFooter(fixedElement) { @@ -195,8 +197,7 @@ function reMarginFooter(fixedElement) {
195 a.async = 1; 197 a.async = 1;
196 a.src = j; 198 a.src = j;
197 m.parentNode.insertBefore(a, m); 199 m.parentNode.insertBefore(a, m);
198 -})(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas');  
199 - 200 +}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas'));
200 (function() { 201 (function() {
201 var uid = getUid(); 202 var uid = getUid();
202 203
@@ -307,22 +308,7 @@ function givePoint(parameter) { @@ -307,22 +308,7 @@ function givePoint(parameter) {
307 } 308 }
308 309
309 // 男:1,女:2,潮童:3,创意生活:4 310 // 男:1,女:2,潮童:3,创意生活:4
310 - switch (cookie('_Channel')) {  
311 - case 'boys':  
312 - CID = 1;  
313 - break;  
314 - case 'girls':  
315 - CID = 2;  
316 - break;  
317 - case 'kids':  
318 - CID = 3;  
319 - break;  
320 - case 'lifestyle':  
321 - CID = 4;  
322 - break;  
323 - default:  
324 - CID = 1;  
325 - } 311 + CID = _ChannelVary[cookie('_Channel')] || 1;
326 312
327 parameter = $.extend({ 313 parameter = $.extend({
328 REC_POSE: '', 314 REC_POSE: '',
@@ -340,7 +326,8 @@ function givePoint(parameter) { @@ -340,7 +326,8 @@ function givePoint(parameter) {
340 326
341 window._yas.sendCustomInfo({ 327 window._yas.sendCustomInfo({
342 op: 'YB_CHOOSE_FOR_YOU_Y', 328 op: 'YB_CHOOSE_FOR_YOU_Y',
343 - uid: getUid(), 329 + apf: (queryString().app_version || queryString().appVersion) ? true : false,
  330 + ts: new Date().getTime(),
344 param: JSON.stringify(parameter) 331 param: JSON.stringify(parameter)
345 }, true); 332 }, true);
346 } 333 }
@@ -365,3 +352,5 @@ window.reMarginFooter = reMarginFooter; @@ -365,3 +352,5 @@ window.reMarginFooter = reMarginFooter;
365 window.queryString = queryString(); 352 window.queryString = queryString();
366 353
367 window.givePoint = givePoint; 354 window.givePoint = givePoint;
  355 +
  356 +window._ChannelVary = _ChannelVary;
@@ -258,7 +258,6 @@ function loadMore($container, opt, url) { @@ -258,7 +258,6 @@ function loadMore($container, opt, url) {
258 delete opt.isTab; 258 delete opt.isTab;
259 }, 259 },
260 error: function() { 260 error: function() {
261 - // console.log('error')  
262 tip.show('网络断开连接了~'); 261 tip.show('网络断开连接了~');
263 searching = false; 262 searching = false;
264 delete opt.isTab; 263 delete opt.isTab;
@@ -2,16 +2,33 @@ var $ = require('yoho-jquery'), @@ -2,16 +2,33 @@ var $ = require('yoho-jquery'),
2 tip = require('../plugin/tip'), 2 tip = require('../plugin/tip'),
3 Swiper = require('yoho-swiper'), 3 Swiper = require('yoho-swiper'),
4 loading = require('../plugin/loading'), 4 loading = require('../plugin/loading'),
  5 + debounce = require('lodash/debounce'),
5 lazyLoad = require('yoho-jquery-lazyload'); 6 lazyLoad = require('yoho-jquery-lazyload');
6 7
7 var plusstar = {}, 8 var plusstar = {},
8 $footer = $('#yoho-footer'); 9 $footer = $('#yoho-footer');
9 10
  11 +var windowHeight = $(window).height();
  12 +var scrollFn,
  13 + scrollTop,
  14 + RECPOSE,
  15 + CID,
  16 + isApp,
  17 + speckParamApp = {
  18 + udid: '',
  19 + apt: '',
  20 + sid: ''
  21 + };
  22 +
10 require('../common'); 23 require('../common');
11 24
12 plusstar = { 25 plusstar = {
13 common: { 26 common: {
14 - codeDefault: '' 27 + codeDefault: '',
  28 + page: 1,
  29 + pagesize: 20,
  30 + pageTotal: 1,
  31 + productSkns: []
15 }, 32 },
16 init: function() { 33 init: function() {
17 var that = this, 34 var that = this,
@@ -41,7 +58,31 @@ plusstar = { @@ -41,7 +58,31 @@ plusstar = {
41 58
42 $(this).find('li').removeClass('focus'); 59 $(this).find('li').removeClass('focus');
43 $liDom.addClass('focus'); 60 $liDom.addClass('focus');
  61 + that.ParentLiDom = $liDom;// 保留当前tab先中的对象
44 that.tabNav($liDom.data('code')); 62 that.tabNav($liDom.data('code'));
  63 +
  64 + // 点击潮流优选上方的TAB按钮时
  65 + if (window._yas && window._yas.sendCustomInfo) {
  66 + window._yas.sendCustomInfo({
  67 + op: 'YB_FASHION_TAB_C',
  68 + apf: isApp,
  69 + ts: new Date().getTime(),
  70 + param: JSON.stringify($.extend(speckParamApp, {
  71 + C_ID: CID,
  72 + TAB_ID: $liDom.index() + 1
  73 + }))
  74 + }, true);
  75 +
  76 + window._yas.sendCustomInfo({
  77 + op: 'YB_FASHION_HOME_L',
  78 + apf: isApp,
  79 + ts: new Date().getTime(),
  80 + param: JSON.stringify($.extend(speckParamApp, {
  81 + C_ID: CID,
  82 + TAB_ID: that.ParentLiDom.index() + 1
  83 + }))
  84 + }, true);
  85 + }
45 }); 86 });
46 87
47 // start -- 默认选中 88 // start -- 默认选中
@@ -55,23 +96,103 @@ plusstar = { @@ -55,23 +96,103 @@ plusstar = {
55 that.tabNav($liDom.data('code')); 96 that.tabNav($liDom.data('code'));
56 97
57 // ent -- 默认选中 98 // ent -- 默认选中
  99 + that.ParentLiDom = $liDom;// 保留当前tab先中的对象
  100 + setTimeout(function() {
  101 + that._yas();
  102 + }, 1000);
  103 + },
  104 + _yas: function() {
  105 + // http://redmine.yoho.cn/issues/12224
  106 + var that = this;
  107 +
  108 + if (!window._yas || !window._yas.sendCustomInfo) {
  109 + return false;
  110 + }
  111 +
  112 + RECPOSE = that.ParentLiDom.index() !== 0 ? 100015 : 100014;
  113 + $('.plusstar-resources').bind('click', function(event) {
  114 + var $dom, $domA, index;
  115 +
  116 + if ($(event.target).closest('.good-info').length > 0) {
  117 + // 商品单击埋点
  118 + $dom = $(event.target).closest('.good-info');
  119 + index = $dom.index() + 1;
  120 + window.givePoint($.extend(speckParamApp, {
  121 + REC_POSE: RECPOSE,
  122 + PRD_ID: $dom.data('good-id'),
  123 + ORDER_CODE: '',
  124 + PRD_NUM: index % that.common.pagesize === 0 ? that.common.pagesize : index % that.common.pagesize,
  125 + ACTION_ID: 1,
  126 + page_num: Math.ceil(index / that.common.pagesize)
  127 + }));
  128 + } else if ($(event.target).closest('.banner-top').length > 0) {
  129 + // 头部banner楼层埋点
  130 + $dom = $(event.target).closest('li');
  131 + index = $dom.index() + 1;
  132 + window._yas.sendCustomInfo({
  133 + op: 'YB_FASHION_FLR_C',
  134 + apf: isApp,
  135 + ts: new Date().getTime(),
  136 + param: JSON.stringify($.extend(speckParamApp, {
  137 + C_ID: CID,
  138 + TAB_ID: that.ParentLiDom.index() + 1,
  139 + F_ID: $dom.closest('ul').data('id'),
  140 + F_NAME: '焦点图',
  141 + F_URL: $dom.find('a').attr('href'),
  142 + F_INDEX: 1,
  143 + I_INDEX: index
  144 + }))
  145 + }, true);
  146 + } else if ($(event.target).closest('.speck-title-image a').length > 0) {
  147 + // 各楼层埋点
  148 + $dom = $(event.target).closest('.speck-title-image');
  149 + $domA = $(event.target).closest('.speck-title-image a');
  150 +
  151 + window._yas.sendCustomInfo({
  152 + op: 'YB_FASHION_FLR_C',
  153 + apf: isApp,
  154 + ts: new Date().getTime(),
  155 + param: JSON.stringify($.extend(speckParamApp, {
  156 + C_ID: CID,
  157 + TAB_ID: that.ParentLiDom.index() + 1,
  158 + F_ID: $dom.data('fid'),
  159 + F_NAME: $dom.data('name'),
  160 + F_URL: $domA.attr('href'),
  161 + F_INDEX: $dom.index() + 1,
  162 + I_INDEX: $domA.hasClass('more') ? 0 : ($domA.index() + 1)
  163 + }))
  164 + }, true);
  165 + }
  166 + });
  167 +
  168 + // 潮流优选首页加载时
  169 + window._yas.sendCustomInfo({
  170 + op: 'YB_FASHION_HOME_L',
  171 + apf: isApp,
  172 + ts: new Date().getTime(),
  173 + param: JSON.stringify($.extend(speckParamApp, {
  174 + C_ID: CID,
  175 + TAB_ID: that.ParentLiDom.index() + 1
  176 + }))
  177 + }, true);
58 }, 178 },
59 tabNav: function(code) { 179 tabNav: function(code) {
60 var that = this; 180 var that = this;
61 181
62 this.common.codeDefault = code;// 记住最后一次的tab code 182 this.common.codeDefault = code;// 记住最后一次的tab code
63 -  
64 - loading.showLoadingMask(); 183 + this.common.page = 1;// 商品列表从第一页开始
65 184
66 $.ajax({ 185 $.ajax({
67 type: 'GET', 186 type: 'GET',
68 url: '/guang/plusstar/resources-template', 187 url: '/guang/plusstar/resources-template',
69 data: { 188 data: {
70 code: code, 189 code: code,
71 - app_version: window.queryString.app_version || window.queryString.appVersion 190 + app_version: isApp
72 }, 191 },
73 dataType: 'html', 192 dataType: 'html',
74 success: function(data) { 193 success: function(data) {
  194 + var productSkns = '';
  195 +
75 $('.plusstar-resources').html(data); 196 $('.plusstar-resources').html(data);
76 197
77 if (data === '') { 198 if (data === '') {
@@ -81,7 +202,6 @@ plusstar = { @@ -81,7 +202,6 @@ plusstar = {
81 202
82 that.resInit(); 203 that.resInit();
83 204
84 - loading.hideLoadingMask();  
85 lazyLoad($('img.lazy')); 205 lazyLoad($('img.lazy'));
86 206
87 // 处理左右滑动,未加载的图片 207 // 处理左右滑动,未加载的图片
@@ -97,10 +217,15 @@ plusstar = { @@ -97,10 +217,15 @@ plusstar = {
97 if (window.localStorage) { 217 if (window.localStorage) {
98 $(document).scrollTop(localStorage.getItem(code) || 0); 218 $(document).scrollTop(localStorage.getItem(code) || 0);
99 } 219 }
  220 +
  221 + productSkns = $(data).find('.product-skns').val();
  222 +
  223 + if (productSkns) {
  224 + that.common.productSkns = productSkns.split(',');
  225 + }
100 }, 226 },
101 error: function() { 227 error: function() {
102 tip.show('网络断开连接了~'); 228 tip.show('网络断开连接了~');
103 - loading.hideLoadingMask();  
104 } 229 }
105 }); 230 });
106 }, 231 },
@@ -118,10 +243,95 @@ plusstar = { @@ -118,10 +243,95 @@ plusstar = {
118 pagination: '.banner-top .pagination-inner' 243 pagination: '.banner-top .pagination-inner'
119 }); 244 });
120 } 245 }
  246 + },
  247 + goodsList: function() {
  248 + var that = this,
  249 + skn = [];
  250 +
  251 + if (that.common.page > that.common.pageTotal) {
  252 + return false;
  253 + }
  254 +
  255 + loading.showLoadingMask();
  256 +
  257 + $.ajax({
  258 + type: 'POST',
  259 + url: '/guang/plusstar/resources-goodsList',
  260 + timeout: 5000,
  261 + data: {
  262 + productSkn: that.common.productSkns.join(','),
  263 + app_version: isApp,
  264 + limit: that.common.pagesize,
  265 + page: that.common.page,
  266 + yh_channel: that.ParentLiDom.index() + 1
  267 + },
  268 + dataType: 'html',
  269 + success: function(data) {
  270 + skn = [];
  271 + loading.hideLoadingMask();
  272 +
  273 + if (data === '') {
  274 + return true;
  275 + }
  276 +
  277 + if (that.common.page <= 1) {
  278 + that.common.pageTotal = $(data).siblings('.page-total').val();
  279 + }
  280 +
  281 + $.each($(data).siblings('.good-info'), function() {
  282 + skn.push($(this).data('good-id'));
  283 + });
  284 +
  285 + window.givePoint($.extend(speckParamApp, {
  286 + REC_POSE: RECPOSE,
  287 + PRD_ID: skn.join(','),
  288 + ORDER_CODE: '',
  289 + PRD_NUM: that.common.pagesize,
  290 + ACTION_ID: 0,
  291 + page_num: that.common.page++
  292 + }));
  293 +
  294 + $('.plusstar-resources .goods').append(data);
  295 +
  296 + lazyLoad($('.plusstar-resources .goods').find('img.lazy:not([src])'));
  297 +
  298 + $('.resources .goods .page-total').remove();
  299 + },
  300 + error: function() {
  301 + tip.show('网络断开连接了~');
  302 + loading.hideLoadingMask();
  303 + }
  304 + });
121 } 305 }
122 }; 306 };
123 307
  308 +scrollFn = debounce(function() {
  309 + scrollTop = $(document).scrollTop();
  310 +
  311 + // 当scroll到最后一列商品的高度后继续请求下一页数据
  312 + if (400 + scrollTop >= $(document).height() - windowHeight) {
  313 + plusstar.goodsList();
  314 + }
  315 +
  316 + if (window.localStorage) {
  317 + localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
  318 + }
  319 +
  320 +}, 200);
  321 +
124 $(function() { 322 $(function() {
  323 + isApp = (window.queryString.app_version || window.queryString.appVersion) ? true : false;
  324 +
  325 + if (isApp) {
  326 + speckParamApp = {
  327 + udid: window.queryString.udid || '',
  328 + apt: window.queryString.client_type || '',
  329 + sid: window.queryString.sid || '',
  330 + };
  331 + }
  332 +
  333 + // 男:1,女:2,潮童:3,创意生活:4
  334 + CID = window._ChannelVary[window.cookie('_Channel')] || 1;
125 335
126 if (!(window.queryString.app_version || window.queryString.appVersion)) { 336 if (!(window.queryString.app_version || window.queryString.appVersion)) {
127 $('.tab-nav').css({ 337 $('.tab-nav').css({
@@ -137,9 +347,8 @@ $(function() { @@ -137,9 +347,8 @@ $(function() {
137 347
138 plusstar.init(); 348 plusstar.init();
139 349
140 - if (window.localStorage) {  
141 - $(document).scroll(function() {  
142 - localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());  
143 - });  
144 - } 350 + // 滚动翻页
  351 + $(window).scroll(function() {
  352 + scrollFn();
  353 + });
145 }); 354 });
@@ -33,7 +33,7 @@ $('#nav-tab').on('touchend touchcancel', function(e) { @@ -33,7 +33,7 @@ $('#nav-tab').on('touchend touchcancel', function(e) {
33 $navs.toggleClass('focus'); 33 $navs.toggleClass('focus');
34 $contents.toggleClass('hide'); 34 $contents.toggleClass('hide');
35 35
36 - $(document).trigger('scroll'); //Trigger lazyLoad 36 + $(document).trigger('scroll'); // Trigger lazyLoad
37 }); 37 });
38 $('#nav-tab').on('touchstart', function(e) { 38 $('#nav-tab').on('touchstart', function(e) {
39 var target = e.target || e.srcElement; 39 var target = e.target || e.srcElement;
@@ -41,4 +41,4 @@ $('#nav-tab').on('touchstart', function(e) { @@ -41,4 +41,4 @@ $('#nav-tab').on('touchstart', function(e) {
41 target.className = 'bytouch ' + target.className; 41 target.className = 'bytouch ' + target.className;
42 }).on('touchend touchcancel', function() { 42 }).on('touchend touchcancel', function() {
43 $navs.removeClass('bytouch'); 43 $navs.removeClass('bytouch');
44 -});  
  44 +});
@@ -89,7 +89,7 @@ ellipsis.init(); @@ -89,7 +89,7 @@ ellipsis.init();
89 tip.show('网络断开连接了~'); 89 tip.show('网络断开连接了~');
90 } 90 }
91 }); 91 });
92 - } else if ($('.shopId').val().length > 0){ 92 + } else if ($('.shopId').val().length > 0) {
93 $.ajax({ 93 $.ajax({
94 url: '/product/index/baseShopFav', 94 url: '/product/index/baseShopFav',
95 data: { 95 data: {
@@ -38,6 +38,7 @@ var $subNav = $('.home-sub-nav'), @@ -38,6 +38,7 @@ var $subNav = $('.home-sub-nav'),
38 favId = $('input[name="favId"]').val(), 38 favId = $('input[name="favId"]').val(),
39 uid = $('input[name="uid"]').val(); 39 uid = $('input[name="uid"]').val();
40 40
  41 +
41 var winH = $(window).height(), 42 var winH = $(window).height(),
42 noResult = '<p class="no-result">未找到相关搜索结果</p>'; 43 noResult = '<p class="no-result">未找到相关搜索结果</p>';
43 44
@@ -20,7 +20,7 @@ const removeHtml = (str) => { @@ -20,7 +20,7 @@ const removeHtml = (str) => {
20 const htmlToEscape = (html) => { 20 const htmlToEscape = (html) => {
21 return html.replace(/[<>&"]/g, (e) => { 21 return html.replace(/[<>&"]/g, (e) => {
22 return _htmlMap[e]; 22 return _htmlMap[e];
23 - }); 23 + });
24 }; 24 };
25 25
26 /** 26 /**
@@ -29,7 +29,7 @@ const htmlToEscape = (html) => { @@ -29,7 +29,7 @@ const htmlToEscape = (html) => {
29 const escapeToHtml = (str) => { 29 const escapeToHtml = (str) => {
30 return str.replace(/&(lt|gt|nbsp|amp|quot);/g, (match, e) => { 30 return str.replace(/&(lt|gt|nbsp|amp|quot);/g, (match, e) => {
31 return _EscapeMap[e]; 31 return _EscapeMap[e];
32 - }); 32 + });
33 }; 33 };
34 34
35 module.exports = { 35 module.exports = {