merage plusstar
Showing
15 changed files
with
331 additions
and
59 deletions
@@ -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 | }; |
@@ -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="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,6 +54,8 @@ | @@ -52,6 +54,8 @@ | ||
52 | {{/if}} | 54 | {{/if}} |
53 | <!--/focus-left-right--> | 55 | <!--/focus-left-right--> |
54 | 56 | ||
57 | + {{#if result.recommend}} | ||
58 | + <div class='speck-title-image' data-fid='{{result.recommend.id}}' data-name='{{result.recommend.title.name}}'> | ||
55 | {{#if result.recommend.title}} | 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}} |
@@ -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 |
@@ -222,7 +222,7 @@ $.extend({ | @@ -222,7 +222,7 @@ $.extend({ | ||
222 | a.async = 1; | 222 | a.async = 1; |
223 | a.src = j; | 223 | a.src = j; |
224 | m.parentNode.insertBefore(a, m); | 224 | m.parentNode.insertBefore(a, m); |
225 | -}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas')); | 225 | +}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.18/yas.js', '_yas')); |
226 | 226 | ||
227 | (function() { | 227 | (function() { |
228 | var uid = getUid(); | 228 | var uid = getUid(); |
@@ -316,22 +316,7 @@ function givePoint(parameter) { | @@ -316,22 +316,7 @@ function givePoint(parameter) { | ||
316 | } | 316 | } |
317 | 317 | ||
318 | // 男:1,女:2,潮童:3,创意生活:4 | 318 | // 男:1,女:2,潮童:3,创意生活:4 |
319 | - switch (cookie('_Channel')) { | ||
320 | - case 'boys': | ||
321 | - CID = 1; | ||
322 | - break; | ||
323 | - case 'girls': | ||
324 | - CID = 2; | ||
325 | - break; | ||
326 | - case 'kids': | ||
327 | - CID = 3; | ||
328 | - break; | ||
329 | - case 'lifestyle': | ||
330 | - CID = 4; | ||
331 | - break; | ||
332 | - default: | ||
333 | - CID = 1; | ||
334 | - } | 319 | + CID = _ChannelVary[cookie('_Channel')] || 1; |
335 | 320 | ||
336 | parameter = $.extend({ | 321 | parameter = $.extend({ |
337 | REC_POSE: '', | 322 | REC_POSE: '', |
@@ -349,7 +334,6 @@ function givePoint(parameter) { | @@ -349,7 +334,6 @@ function givePoint(parameter) { | ||
349 | 334 | ||
350 | window._yas.sendCustomInfo({ | 335 | window._yas.sendCustomInfo({ |
351 | op: 'YB_CHOOSE_FOR_YOU_Y', | 336 | op: 'YB_CHOOSE_FOR_YOU_Y', |
352 | - uid: getUid(), | ||
353 | param: JSON.stringify(parameter) | 337 | param: JSON.stringify(parameter) |
354 | }, true); | 338 | }, true); |
355 | } | 339 | } |
@@ -258,7 +258,7 @@ function loadMore($container, opt, url) { | @@ -258,7 +258,7 @@ 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') | 261 | + console.log('error'); |
262 | tip.show('网络断开连接了~'); | 262 | tip.show('网络断开连接了~'); |
263 | searching = false; | 263 | searching = false; |
264 | delete opt.isTab; | 264 | delete opt.isTab; |
@@ -196,12 +196,12 @@ $('img').on('load', function() { | @@ -196,12 +196,12 @@ $('img').on('load', function() { | ||
196 | 196 | ||
197 | if ($('.guang-detail-page').hasClass('guang-detail')) { | 197 | if ($('.guang-detail-page').hasClass('guang-detail')) { |
198 | useIscroll = true; | 198 | useIscroll = true; |
199 | - } else if($('.guang-detail-page').hasClass('guang-ezine')) { | 199 | + } else if ($('.guang-detail-page').hasClass('guang-ezine')) { |
200 | useIscroll = false; | 200 | useIscroll = false; |
201 | } | 201 | } |
202 | $('.main-wrap').css({ | 202 | $('.main-wrap').css({ |
203 | position: 'static' | 203 | position: 'static' |
204 | - }) | 204 | + }); |
205 | 205 | ||
206 | pageInIscroll = isIphone && useIscroll; | 206 | pageInIscroll = isIphone && useIscroll; |
207 | 207 |
@@ -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,27 @@ plusstar = { | @@ -41,7 +58,27 @@ 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 | + param: JSON.stringify($.extend(speckParamApp, { | ||
69 | + C_ID: CID, | ||
70 | + TAB_ID: $liDom.index() + 1 | ||
71 | + })) | ||
72 | + }, true); | ||
73 | + | ||
74 | + window._yas.sendCustomInfo({ | ||
75 | + op: 'YB_FASHION_HOME_L', | ||
76 | + param: JSON.stringify($.extend(speckParamApp, { | ||
77 | + C_ID: CID, | ||
78 | + TAB_ID: that.ParentLiDom.index() + 1 | ||
79 | + })) | ||
80 | + }, true); | ||
81 | + } | ||
45 | }); | 82 | }); |
46 | 83 | ||
47 | // start -- 默认选中 | 84 | // start -- 默认选中 |
@@ -55,23 +92,97 @@ plusstar = { | @@ -55,23 +92,97 @@ plusstar = { | ||
55 | that.tabNav($liDom.data('code')); | 92 | that.tabNav($liDom.data('code')); |
56 | 93 | ||
57 | // ent -- 默认选中 | 94 | // ent -- 默认选中 |
95 | + that.ParentLiDom = $liDom;// 保留当前tab先中的对象 | ||
96 | + setTimeout(function() { | ||
97 | + that._yas(); | ||
98 | + }, 1000); | ||
99 | + }, | ||
100 | + _yas: function() { | ||
101 | + // http://redmine.yoho.cn/issues/12224 | ||
102 | + var that = this; | ||
103 | + | ||
104 | + if (!window._yas || !window._yas.sendCustomInfo) { | ||
105 | + return false; | ||
106 | + } | ||
107 | + | ||
108 | + RECPOSE = that.ParentLiDom.index() !== 0 ? 100015 : 100014; | ||
109 | + $('.plusstar-resources').bind('click', function(event) { | ||
110 | + var $dom, $domA, index; | ||
111 | + | ||
112 | + if ($(event.target).closest('.good-info').length > 0) { | ||
113 | + // 商品单击埋点 | ||
114 | + $dom = $(event.target).closest('.good-info'); | ||
115 | + index = $dom.index() + 1; | ||
116 | + window.givePoint($.extend(speckParamApp, { | ||
117 | + REC_POSE: RECPOSE, | ||
118 | + PRD_ID: $dom.data('good-id'), | ||
119 | + ORDER_CODE: '', | ||
120 | + PRD_NUM: index % that.common.pagesize === 0 ? that.common.pagesize : index % that.common.pagesize, | ||
121 | + ACTION_ID: 1, | ||
122 | + page_num: Math.ceil(index / that.common.pagesize) | ||
123 | + })); | ||
124 | + } else if ($(event.target).closest('.banner-top').length > 0) { | ||
125 | + // 头部banner楼层埋点 | ||
126 | + $dom = $(event.target).closest('li'); | ||
127 | + index = $dom.index() + 1; | ||
128 | + window._yas.sendCustomInfo({ | ||
129 | + op: 'YB_FASHION_FLR_C', | ||
130 | + param: JSON.stringify($.extend(speckParamApp, { | ||
131 | + C_ID: CID, | ||
132 | + TAB_ID: that.ParentLiDom.index() + 1, | ||
133 | + F_ID: $dom.closest('ul').data('id'), | ||
134 | + F_NAME: '焦点图', | ||
135 | + F_URL: $dom.find('a').attr('href'), | ||
136 | + F_INDEX: 1, | ||
137 | + I_INDEX: index % 2 + 1// banner,li是双倍的 | ||
138 | + })) | ||
139 | + }, true); | ||
140 | + } else if ($(event.target).closest('.speck-title-image a').length > 0) { | ||
141 | + // 各楼层埋点 | ||
142 | + $dom = $(event.target).closest('.speck-title-image'); | ||
143 | + $domA = $(event.target).closest('.speck-title-image a'); | ||
144 | + | ||
145 | + window._yas.sendCustomInfo({ | ||
146 | + op: 'YB_FASHION_FLR_C', | ||
147 | + param: JSON.stringify($.extend(speckParamApp, { | ||
148 | + C_ID: CID, | ||
149 | + TAB_ID: that.ParentLiDom.index() + 1, | ||
150 | + F_ID: $dom.data('fid'), | ||
151 | + F_NAME: $dom.data('name'), | ||
152 | + F_URL: $domA.attr('href'), | ||
153 | + F_INDEX: $dom.index() + 1, | ||
154 | + I_INDEX: $domA.hasClass('more') ? 0 : ($domA.index() + 1) | ||
155 | + })) | ||
156 | + }, true); | ||
157 | + } | ||
158 | + }); | ||
159 | + | ||
160 | + // 潮流优选首页加载时 | ||
161 | + window._yas.sendCustomInfo({ | ||
162 | + op: 'YB_FASHION_HOME_L', | ||
163 | + param: JSON.stringify($.extend(speckParamApp, { | ||
164 | + C_ID: CID, | ||
165 | + TAB_ID: that.ParentLiDom.index() + 1 | ||
166 | + })) | ||
167 | + }, true); | ||
58 | }, | 168 | }, |
59 | tabNav: function(code) { | 169 | tabNav: function(code) { |
60 | var that = this; | 170 | var that = this; |
61 | 171 | ||
62 | this.common.codeDefault = code;// 记住最后一次的tab code | 172 | this.common.codeDefault = code;// 记住最后一次的tab code |
63 | - | ||
64 | - loading.showLoadingMask(); | 173 | + this.common.page = 1;// 商品列表从第一页开始 |
65 | 174 | ||
66 | $.ajax({ | 175 | $.ajax({ |
67 | type: 'GET', | 176 | type: 'GET', |
68 | url: '/guang/plusstar/resources-template', | 177 | url: '/guang/plusstar/resources-template', |
69 | data: { | 178 | data: { |
70 | code: code, | 179 | code: code, |
71 | - app_version: window.queryString.app_version || window.queryString.appVersion | 180 | + app_version: isApp |
72 | }, | 181 | }, |
73 | dataType: 'html', | 182 | dataType: 'html', |
74 | success: function(data) { | 183 | success: function(data) { |
184 | + var productSkns = ''; | ||
185 | + | ||
75 | $('.plusstar-resources').html(data); | 186 | $('.plusstar-resources').html(data); |
76 | 187 | ||
77 | if (data === '') { | 188 | if (data === '') { |
@@ -81,7 +192,6 @@ plusstar = { | @@ -81,7 +192,6 @@ plusstar = { | ||
81 | 192 | ||
82 | that.resInit(); | 193 | that.resInit(); |
83 | 194 | ||
84 | - loading.hideLoadingMask(); | ||
85 | lazyLoad($('img.lazy')); | 195 | lazyLoad($('img.lazy')); |
86 | 196 | ||
87 | // 处理左右滑动,未加载的图片 | 197 | // 处理左右滑动,未加载的图片 |
@@ -97,10 +207,15 @@ plusstar = { | @@ -97,10 +207,15 @@ plusstar = { | ||
97 | if (window.localStorage) { | 207 | if (window.localStorage) { |
98 | $(document).scrollTop(localStorage.getItem(code) || 0); | 208 | $(document).scrollTop(localStorage.getItem(code) || 0); |
99 | } | 209 | } |
210 | + | ||
211 | + productSkns = $(data).find('.product-skns').val(); | ||
212 | + | ||
213 | + if (productSkns) { | ||
214 | + that.common.productSkns = productSkns.split(','); | ||
215 | + } | ||
100 | }, | 216 | }, |
101 | error: function() { | 217 | error: function() { |
102 | tip.show('网络断开连接了~'); | 218 | tip.show('网络断开连接了~'); |
103 | - loading.hideLoadingMask(); | ||
104 | } | 219 | } |
105 | }); | 220 | }); |
106 | }, | 221 | }, |
@@ -118,10 +233,95 @@ plusstar = { | @@ -118,10 +233,95 @@ plusstar = { | ||
118 | pagination: '.banner-top .pagination-inner' | 233 | pagination: '.banner-top .pagination-inner' |
119 | }); | 234 | }); |
120 | } | 235 | } |
236 | + }, | ||
237 | + goodsList: function() { | ||
238 | + var that = this, | ||
239 | + skn = []; | ||
240 | + | ||
241 | + if (that.common.page > that.common.pageTotal) { | ||
242 | + return false; | ||
243 | + } | ||
244 | + | ||
245 | + loading.showLoadingMask(); | ||
246 | + | ||
247 | + $.ajax({ | ||
248 | + type: 'POST', | ||
249 | + url: '/guang/plusstar/resources-goodsList', | ||
250 | + timeout: 5000, | ||
251 | + data: { | ||
252 | + productSkn: that.common.productSkns.join(','), | ||
253 | + app_version: isApp, | ||
254 | + limit: that.common.pagesize, | ||
255 | + page: that.common.page, | ||
256 | + yh_channel: that.ParentLiDom.index() + 1 | ||
257 | + }, | ||
258 | + dataType: 'html', | ||
259 | + success: function(data) { | ||
260 | + skn = []; | ||
261 | + loading.hideLoadingMask(); | ||
262 | + | ||
263 | + if (data === '') { | ||
264 | + return true; | ||
265 | + } | ||
266 | + | ||
267 | + if (that.common.page <= 1) { | ||
268 | + that.common.pageTotal = $(data).siblings('.page-total').val(); | ||
269 | + } | ||
270 | + | ||
271 | + $.each($(data).siblings('.good-info'), function() { | ||
272 | + skn.push($(this).data('good-id')); | ||
273 | + }); | ||
274 | + | ||
275 | + window.givePoint($.extend(speckParamApp, { | ||
276 | + REC_POSE: RECPOSE, | ||
277 | + PRD_ID: skn.join(','), | ||
278 | + ORDER_CODE: '', | ||
279 | + PRD_NUM: that.common.pagesize, | ||
280 | + ACTION_ID: 0, | ||
281 | + page_num: that.common.page++ | ||
282 | + })); | ||
283 | + | ||
284 | + $('.plusstar-resources .goods').append(data); | ||
285 | + | ||
286 | + lazyLoad($('.plusstar-resources .goods').find('img.lazy:not([src])')); | ||
287 | + | ||
288 | + $('.resources .goods .page-total').remove(); | ||
289 | + }, | ||
290 | + error: function() { | ||
291 | + tip.show('网络断开连接了~'); | ||
292 | + loading.hideLoadingMask(); | ||
293 | + } | ||
294 | + }); | ||
121 | } | 295 | } |
122 | }; | 296 | }; |
123 | 297 | ||
298 | +scrollFn = debounce(function() { | ||
299 | + scrollTop = $(document).scrollTop(); | ||
300 | + | ||
301 | + // 当scroll到最后一列商品的高度后继续请求下一页数据 | ||
302 | + if (400 + scrollTop >= $(document).height() - windowHeight) { | ||
303 | + plusstar.goodsList(); | ||
304 | + } | ||
305 | + | ||
306 | + if (window.localStorage) { | ||
307 | + localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop()); | ||
308 | + } | ||
309 | + | ||
310 | +}, 200); | ||
311 | + | ||
124 | $(function() { | 312 | $(function() { |
313 | + isApp = (window.queryString.app_version || window.queryString.appVersion) ? true : false; | ||
314 | + | ||
315 | + if (isApp) { | ||
316 | + speckParamApp = { | ||
317 | + udid: window.queryString.udid || '', | ||
318 | + apt: window.queryString.client_type || '', | ||
319 | + sid: window.queryString.session_id || '', | ||
320 | + }; | ||
321 | + } | ||
322 | + | ||
323 | + // 男:1,女:2,潮童:3,创意生活:4 | ||
324 | + CID = window._ChannelVary[window.cookie('_Channel')] || 1; | ||
125 | 325 | ||
126 | if (!(window.queryString.app_version || window.queryString.appVersion)) { | 326 | if (!(window.queryString.app_version || window.queryString.appVersion)) { |
127 | $('.tab-nav').css({ | 327 | $('.tab-nav').css({ |
@@ -137,9 +337,8 @@ $(function() { | @@ -137,9 +337,8 @@ $(function() { | ||
137 | 337 | ||
138 | plusstar.init(); | 338 | plusstar.init(); |
139 | 339 | ||
140 | - if (window.localStorage) { | ||
141 | - $(document).scroll(function() { | ||
142 | - localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop()); | 340 | + // 滚动翻页 |
341 | + $(window).scroll(function() { | ||
342 | + scrollFn(); | ||
143 | }); | 343 | }); |
144 | - } | ||
145 | }); | 344 | }); |
@@ -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; |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | 'use strict'; | 5 | 'use strict'; |
6 | 6 | ||
7 | const _htmlMap = {'<': '<', '>': '>', '&': '&', '"': '"'}; | 7 | const _htmlMap = {'<': '<', '>': '>', '&': '&', '"': '"'}; |
8 | -const _EscapeMap = {'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"'}; | 8 | +const _EscapeMap = {lt: '<', gt: '>', nbsp: ' ', amp: '&', quot: '"'}; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * [移除html标签] | 11 | * [移除html标签] |
-
Please register or login to post a comment