Merge branch 'hotfix/plusstar' into feature/plusstarSpeck
Showing
17 changed files
with
139 additions
and
59 deletions
@@ -62,3 +62,21 @@ exports.resourcesTemplate = (req, res, next) => { | @@ -62,3 +62,21 @@ exports.resourcesTemplate = (req, res, next) => { | ||
62 | }); | 62 | }); |
63 | }).catch(next); | 63 | }).catch(next); |
64 | }; | 64 | }; |
65 | + | ||
66 | +/** | ||
67 | + * 潮流优选首页-资源位-商品列表 | ||
68 | + */ | ||
69 | +exports.resourcesGoodsList = (req, res, next) => { | ||
70 | + let productSkn = req.body.productSkn || ''; | ||
71 | + let isApp = req.body.app_version || req.body.appVersion || false; | ||
72 | + | ||
73 | + plusstarModel.getProductBatch(productSkn.split(','), { | ||
74 | + isApp: isApp | ||
75 | + }).then(result => { | ||
76 | + res.render('plusstar/resources-goodsList', { | ||
77 | + layout: false, | ||
78 | + goods: result, | ||
79 | + title: '潮流优选' | ||
80 | + }); | ||
81 | + }).catch(next); | ||
82 | +}; |
@@ -138,14 +138,7 @@ const getResources = (params, options) => { | @@ -138,14 +138,7 @@ const getResources = (params, options) => { | ||
138 | } | 138 | } |
139 | }); | 139 | }); |
140 | 140 | ||
141 | - if (_.isEmpty(data.goods.productSkns)) { | ||
142 | - return data; | ||
143 | - } | ||
144 | - | ||
145 | - return getProductBatch(data.goods.productSkns, options).then(res => { | ||
146 | - data.goods.data = res; | ||
147 | - return data; | ||
148 | - }); | 141 | + return data; |
149 | }); | 142 | }); |
150 | }; | 143 | }; |
151 | 144 |
@@ -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 |
@@ -76,13 +76,12 @@ | @@ -76,13 +76,12 @@ | ||
76 | <a class="more" href="{{result.goods.title.moreUrl}}"> | 76 | <a class="more" href="{{result.goods.title.moreUrl}}"> |
77 | {{result.goods.title.moreName}} | 77 | {{result.goods.title.moreName}} |
78 | </a> | 78 | </a> |
79 | + <input type='hidden' value='{{result.goods.productSkns}}' class='product-skns' /> | ||
79 | </div> | 80 | </div> |
80 | 81 | ||
81 | <div class="goods clearfix"> | 82 | <div class="goods clearfix"> |
82 | <!--商品---> | 83 | <!--商品---> |
83 | - {{#each result.goods.data}} | ||
84 | - {{> common/goods}} | ||
85 | - {{/each}} | 84 | + |
86 | </div><!--/goods--> | 85 | </div><!--/goods--> |
87 | {{/if}} | 86 | {{/if}} |
88 | 87 |
@@ -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,24 @@ var $ = require('yoho-jquery'), | @@ -2,16 +2,24 @@ 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 | + | ||
10 | require('../common'); | 15 | require('../common'); |
11 | 16 | ||
12 | plusstar = { | 17 | plusstar = { |
13 | common: { | 18 | common: { |
14 | - codeDefault: '' | 19 | + codeDefault: '', |
20 | + page: 1, | ||
21 | + pagesize: 20, | ||
22 | + productSkns: [] | ||
15 | }, | 23 | }, |
16 | init: function() { | 24 | init: function() { |
17 | var that = this, | 25 | var that = this, |
@@ -60,6 +68,7 @@ plusstar = { | @@ -60,6 +68,7 @@ plusstar = { | ||
60 | var that = this; | 68 | var that = this; |
61 | 69 | ||
62 | this.common.codeDefault = code;// 记住最后一次的tab code | 70 | this.common.codeDefault = code;// 记住最后一次的tab code |
71 | + this.common.page = 1;// 商品列表从第一页开始 | ||
63 | 72 | ||
64 | loading.showLoadingMask(); | 73 | loading.showLoadingMask(); |
65 | 74 | ||
@@ -72,6 +81,8 @@ plusstar = { | @@ -72,6 +81,8 @@ plusstar = { | ||
72 | }, | 81 | }, |
73 | dataType: 'html', | 82 | dataType: 'html', |
74 | success: function(data) { | 83 | success: function(data) { |
84 | + var productSkns = ''; | ||
85 | + | ||
75 | $('.plusstar-resources').html(data); | 86 | $('.plusstar-resources').html(data); |
76 | 87 | ||
77 | if (data === '') { | 88 | if (data === '') { |
@@ -97,6 +108,13 @@ plusstar = { | @@ -97,6 +108,13 @@ plusstar = { | ||
97 | if (window.localStorage) { | 108 | if (window.localStorage) { |
98 | $(document).scrollTop(localStorage.getItem(code) || 0); | 109 | $(document).scrollTop(localStorage.getItem(code) || 0); |
99 | } | 110 | } |
111 | + | ||
112 | + productSkns = $(data).find('.product-skns').val(); | ||
113 | + | ||
114 | + if (productSkns) { | ||
115 | + that.common.productSkns = productSkns.split(','); | ||
116 | + } | ||
117 | + | ||
100 | }, | 118 | }, |
101 | error: function() { | 119 | error: function() { |
102 | tip.show('网络断开连接了~'); | 120 | tip.show('网络断开连接了~'); |
@@ -118,11 +136,59 @@ plusstar = { | @@ -118,11 +136,59 @@ plusstar = { | ||
118 | pagination: '.banner-top .pagination-inner' | 136 | pagination: '.banner-top .pagination-inner' |
119 | }); | 137 | }); |
120 | } | 138 | } |
139 | + }, | ||
140 | + goodsList: function() { | ||
141 | + var that = this, | ||
142 | + skn = [], | ||
143 | + len = 0; | ||
144 | + | ||
145 | + len = (that.common.page - 1) * that.common.pagesize; | ||
146 | + skn = that.common.productSkns.slice(len, len + that.common.pagesize); | ||
147 | + | ||
148 | + if (skn.length < 1) { | ||
149 | + return false; | ||
150 | + } | ||
151 | + | ||
152 | + loading.showLoadingMask(); | ||
153 | + that.common.page++; | ||
154 | + $.ajax({ | ||
155 | + type: 'POST', | ||
156 | + url: '/guang/plusstar/resources-goodsList', | ||
157 | + data: { | ||
158 | + productSkn: skn.join(','), | ||
159 | + app_version: window.queryString.app_version || window.queryString.appVersion | ||
160 | + }, | ||
161 | + dataType: 'html', | ||
162 | + success: function(data) { | ||
163 | + if (data === '') { | ||
164 | + return true; | ||
165 | + } | ||
166 | + | ||
167 | + $('.plusstar-resources .goods').append(data); | ||
168 | + | ||
169 | + lazyLoad($('.plusstar-resources .goods').find('img.lazy:not([src])')); | ||
170 | + | ||
171 | + loading.hideLoadingMask(); | ||
172 | + } | ||
173 | + }); | ||
121 | } | 174 | } |
122 | }; | 175 | }; |
123 | 176 | ||
124 | -$(function() { | 177 | +scrollFn = debounce(function() { |
178 | + scrollTop = $(document).scrollTop(); | ||
179 | + | ||
180 | + // 当scroll到最后一列商品的高度后继续请求下一页数据 | ||
181 | + if (400 + scrollTop >= $(document).height() - windowHeight) { | ||
182 | + plusstar.goodsList(); | ||
183 | + } | ||
184 | + | ||
185 | + if (window.localStorage) { | ||
186 | + localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop()); | ||
187 | + } | ||
188 | + | ||
189 | +}, 200); | ||
125 | 190 | ||
191 | +$(function() { | ||
126 | if (!(window.queryString.app_version || window.queryString.appVersion)) { | 192 | if (!(window.queryString.app_version || window.queryString.appVersion)) { |
127 | $('.tab-nav').css({ | 193 | $('.tab-nav').css({ |
128 | position: 'relative' | 194 | position: 'relative' |
@@ -137,9 +203,9 @@ $(function() { | @@ -137,9 +203,9 @@ $(function() { | ||
137 | 203 | ||
138 | plusstar.init(); | 204 | plusstar.init(); |
139 | 205 | ||
140 | - if (window.localStorage) { | ||
141 | - $(document).scroll(function() { | ||
142 | - localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop()); | ||
143 | - }); | ||
144 | - } | 206 | + // 滚动翻页 |
207 | + $(window).scroll(function() { | ||
208 | + scrollFn(); | ||
209 | + }); | ||
210 | + | ||
145 | }); | 211 | }); |
@@ -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 | +}); |
@@ -135,8 +135,8 @@ function initFilter(opt) { | @@ -135,8 +135,8 @@ function initFilter(opt) { | ||
135 | var $this = $(e.target), | 135 | var $this = $(e.target), |
136 | $cur; | 136 | $cur; |
137 | 137 | ||
138 | - //这行不能注释,iphone下会出现穿透 | ||
139 | - e.preventDefault();//防止透点 | 138 | + // 这行不能注释,iphone下会出现穿透 |
139 | + e.preventDefault();// 防止透点 | ||
140 | 140 | ||
141 | if ($this.closest('.filter-body').length > 0) { | 141 | if ($this.closest('.filter-body').length > 0) { |
142 | $cur = $this.closest('.sub-item'); | 142 | $cur = $this.closest('.sub-item'); |
@@ -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: { |
@@ -36,7 +36,7 @@ var $subNav = $('.home-sub-nav'), | @@ -36,7 +36,7 @@ var $subNav = $('.home-sub-nav'), | ||
36 | brand = $('input[name="brand"]').val(), | 36 | brand = $('input[name="brand"]').val(), |
37 | coverChannel = $('input[name="coverChannel"]').val(), | 37 | coverChannel = $('input[name="coverChannel"]').val(), |
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 | var winH = $(window).height(), | 41 | var winH = $(window).height(), |
42 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; | 42 | noResult = '<p class="no-result">未找到相关搜索结果</p>'; |
@@ -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 = { |
-
Please register or login to post a comment