lazyload,app跳转,添加platform
Showing
6 changed files
with
46 additions
and
22 deletions
@@ -18,7 +18,8 @@ exports.index = (req, res, next) => { | @@ -18,7 +18,8 @@ exports.index = (req, res, next) => { | ||
18 | 18 | ||
19 | let params = { | 19 | let params = { |
20 | page: 1, | 20 | page: 1, |
21 | - limit: 10 | 21 | + limit: 10, |
22 | + isApp: req.query.app_version || req.query.appVersion ? true : false, | ||
22 | }; | 23 | }; |
23 | 24 | ||
24 | if (req.user.uid || req.query.uid) { | 25 | if (req.user.uid || req.query.uid) { |
@@ -41,7 +42,8 @@ exports.index = (req, res, next) => { | @@ -41,7 +42,8 @@ exports.index = (req, res, next) => { | ||
41 | exports.moreGoods = (req, res, next) => { | 42 | exports.moreGoods = (req, res, next) => { |
42 | let params = { | 43 | let params = { |
43 | page: req.query.page || 1, | 44 | page: req.query.page || 1, |
44 | - limit: 10 | 45 | + limit: 10, |
46 | + isApp: req.query.isApp | ||
45 | }; | 47 | }; |
46 | 48 | ||
47 | if (req.user.uid || req.query.uid) { | 49 | if (req.user.uid || req.query.uid) { |
@@ -11,7 +11,8 @@ module.exports = class extends global.yoho.BaseModel { | @@ -11,7 +11,8 @@ module.exports = class extends global.yoho.BaseModel { | ||
11 | let options = { | 11 | let options = { |
12 | url: 'operations/api/v5/resource/home', | 12 | url: 'operations/api/v5/resource/home', |
13 | data: { | 13 | data: { |
14 | - content_code: '8512bf0755cc549ac323f852c9fd945d' | 14 | + content_code: '8512bf0755cc549ac323f852c9fd945d', |
15 | + platform: 'iphone' | ||
15 | }, | 16 | }, |
16 | param: { | 17 | param: { |
17 | cache: true, | 18 | cache: true, |
@@ -73,13 +74,17 @@ module.exports = class extends global.yoho.BaseModel { | @@ -73,13 +74,17 @@ module.exports = class extends global.yoho.BaseModel { | ||
73 | 74 | ||
74 | _.forEach(data, (val) => { | 75 | _.forEach(data, (val) => { |
75 | let discount = this.getDiscound(val.sales_price, val.market_price); | 76 | let discount = this.getDiscound(val.sales_price, val.market_price); |
77 | + let url = `//m.yohobuy.com/product/${val.product_skn}.html`; | ||
76 | 78 | ||
79 | + if (params.isApp) { | ||
80 | + url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}"}}`; // eslint-disable-line | ||
81 | + } | ||
77 | build.push({ | 82 | build.push({ |
78 | productName: val.product_name, | 83 | productName: val.product_name, |
79 | salesPrice: val.sales_price, | 84 | salesPrice: val.sales_price, |
80 | marketPrice: val.market_price === val.sales_price ? '' : val.market_price, | 85 | marketPrice: val.market_price === val.sales_price ? '' : val.market_price, |
81 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', | 86 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', |
82 | - productSkn: val.product_skn, | 87 | + url: url, |
83 | discount: discount | 88 | discount: discount |
84 | }); | 89 | }); |
85 | }); | 90 | }); |
@@ -116,13 +121,18 @@ module.exports = class extends global.yoho.BaseModel { | @@ -116,13 +121,18 @@ module.exports = class extends global.yoho.BaseModel { | ||
116 | 121 | ||
117 | _.forEach(data, (val) => { | 122 | _.forEach(data, (val) => { |
118 | let discount = this.getDiscound(val.sales_price, val.market_price); | 123 | let discount = this.getDiscound(val.sales_price, val.market_price); |
124 | + let url = `//m.yohobuy.com/product/${val.product_skn}.html`; | ||
125 | + | ||
126 | + if (params.isApp) { | ||
127 | + url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}"}}`; // eslint-disable-line | ||
128 | + } | ||
119 | 129 | ||
120 | build.push({ | 130 | build.push({ |
121 | productName: val.product_name, | 131 | productName: val.product_name, |
122 | salesPrice: val.sales_price, | 132 | salesPrice: val.sales_price, |
123 | marketPrice: val.market_price === val.sales_price ? '' : val.market_price, | 133 | marketPrice: val.market_price === val.sales_price ? '' : val.market_price, |
124 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', | 134 | defaultImages: val.default_images ? val.default_images.split(',')[0] : '', |
125 | - productSkn: val.product_skn, | 135 | + url: url, |
126 | discount: discount | 136 | discount: discount |
127 | }); | 137 | }); |
128 | }); | 138 | }); |
@@ -25,20 +25,22 @@ | @@ -25,20 +25,22 @@ | ||
25 | <div class="big-title">潮流优选</div> | 25 | <div class="big-title">潮流优选</div> |
26 | <div class="goods clearfix"> | 26 | <div class="goods clearfix"> |
27 | {{# goodList}} | 27 | {{# goodList}} |
28 | - <a class="good-item" href="//m.yohobuy.com/product/{{productSkn}}.html"> | 28 | + <a class="good-item" href="{{url}}"> |
29 | <div class="pic"> | 29 | <div class="pic"> |
30 | - <img src="{{image2 defaultImages w=330 h=379 q=90}}" /> | 30 | + <img class="lazy" data-original="{{image2 defaultImages w=330 h=379 q=90}}" /> |
31 | </div> | 31 | </div> |
32 | <div class="price">¥{{salesPrice}} | 32 | <div class="price">¥{{salesPrice}} |
33 | {{#if marketPrice}} | 33 | {{#if marketPrice}} |
34 | <span>¥{{marketPrice}}</span> | 34 | <span>¥{{marketPrice}}</span> |
35 | {{/if}} | 35 | {{/if}} |
36 | </div> | 36 | </div> |
37 | - <div class="tip"> | ||
38 | - <div class="tip-c"> | ||
39 | - <div>{{productName}}</div> | 37 | + <div class="tip-bg"> |
38 | + <div class="tip"> | ||
39 | + <div class="tip-c"> | ||
40 | + <div>{{productName}}</div> | ||
41 | + </div> | ||
42 | + <div class="ico"></div> | ||
40 | </div> | 43 | </div> |
41 | - <div class="ico"></div> | ||
42 | </div> | 44 | </div> |
43 | <div class="discount">{{{discount}}}</div> | 45 | <div class="discount">{{{discount}}}</div> |
44 | </a> | 46 | </a> |
1 | {{# goodList}} | 1 | {{# goodList}} |
2 | -<a class="good-item" href="//m.yohobuy.com/product/{{productSkn}}.html"> | 2 | +<a class="good-item" href="{{url}}"> |
3 | <div class="pic"> | 3 | <div class="pic"> |
4 | - <img src="{{image2 defaultImages w=330 h=379 q=90}}" /> | 4 | + <img class="lazy" data-original="{{image2 defaultImages w=330 h=379 q=90}}" /> |
5 | </div> | 5 | </div> |
6 | <div class="price">¥{{salesPrice}} | 6 | <div class="price">¥{{salesPrice}} |
7 | {{#if marketPrice}} | 7 | {{#if marketPrice}} |
8 | <span>¥{{marketPrice}}</span> | 8 | <span>¥{{marketPrice}}</span> |
9 | {{/if}} | 9 | {{/if}} |
10 | </div> | 10 | </div> |
11 | - <div class="tip"> | ||
12 | - <div class="tip-c"> | ||
13 | - <div>{{productName}}</div> | 11 | + <div class="tip-bg"> |
12 | + <div class="tip"> | ||
13 | + <div class="tip-c"> | ||
14 | + <div>{{productName}}</div> | ||
15 | + </div> | ||
16 | + <div class="ico"></div> | ||
14 | </div> | 17 | </div> |
15 | - <div class="ico"></div> | ||
16 | </div> | 18 | </div> |
17 | <div class="discount">{{{discount}}}</div> | 19 | <div class="discount">{{{discount}}}</div> |
18 | </a> | 20 | </a> |
@@ -12,13 +12,14 @@ import { | @@ -12,13 +12,14 @@ import { | ||
12 | moreGoods as getMore | 12 | moreGoods as getMore |
13 | } from './model'; | 13 | } from './model'; |
14 | 14 | ||
15 | -let $ = require('yoho-jquery'); | ||
16 | - | ||
17 | -let goodContent = require('activity/user-recommend/recommend-goods.hbs'); | 15 | +const $ = require('yoho-jquery'); |
16 | +const goodContent = require('activity/user-recommend/recommend-goods.hbs'); | ||
17 | +const lazyLoad = require('yoho-jquery-lazyload'); | ||
18 | 18 | ||
19 | class ActController extends Controller { | 19 | class ActController extends Controller { |
20 | constructor() { | 20 | constructor() { |
21 | super(); | 21 | super(); |
22 | + lazyLoad($('img.lazy')); | ||
22 | this.more = new GetMore(); | 23 | this.more = new GetMore(); |
23 | this.more.on('more', this.doMore.bind(this)); | 24 | this.more.on('more', this.doMore.bind(this)); |
24 | this.page = 1; | 25 | this.page = 1; |
@@ -35,10 +36,14 @@ class ActController extends Controller { | @@ -35,10 +36,14 @@ class ActController extends Controller { | ||
35 | 36 | ||
36 | moreGood(page) { | 37 | moreGood(page) { |
37 | this.loading = true; | 38 | this.loading = true; |
39 | + this.isApp = window.queryString.app_version || window.queryString.appVersion ? true : false; | ||
38 | $('.gdt-c').append('<p class="show-more">加载更多...</p>'); | 40 | $('.gdt-c').append('<p class="show-more">加载更多...</p>'); |
39 | - getMore('//m.yohobuy.com/activity/user-recommend/moreGoods', {page: page}).then(data => { | 41 | + getMore('//m.yohobuy.com/activity/user-recommend/moreGoods', {page: page, isApp: this.isApp}).then(data => { |
40 | if (data.goodList.length > 0) { | 42 | if (data.goodList.length > 0) { |
41 | $('.goods').append(goodContent(data)); | 43 | $('.goods').append(goodContent(data)); |
44 | + | ||
45 | + // 每次只lazyload倒数10 | ||
46 | + lazyLoad($('.goods img:gt(-11)')); | ||
42 | } else { | 47 | } else { |
43 | $('.gdt-c').append('<p class="show-more">没有更多了...</p>'); | 48 | $('.gdt-c').append('<p class="show-more">没有更多了...</p>'); |
44 | this.end = true; | 49 | this.end = true; |
@@ -7,6 +7,10 @@ | @@ -7,6 +7,10 @@ | ||
7 | font-size: 28px; | 7 | font-size: 28px; |
8 | } | 8 | } |
9 | 9 | ||
10 | + .tip-bg { | ||
11 | + background-color: #292929; | ||
12 | + } | ||
13 | + | ||
10 | .big-pic { | 14 | .big-pic { |
11 | width: 750px; | 15 | width: 750px; |
12 | display: block; | 16 | display: block; |
@@ -102,7 +106,6 @@ | @@ -102,7 +106,6 @@ | ||
102 | float: left; | 106 | float: left; |
103 | margin-bottom: 50px; | 107 | margin-bottom: 50px; |
104 | position: relative; | 108 | position: relative; |
105 | - background-color: #292929; | ||
106 | display: block; | 109 | display: block; |
107 | 110 | ||
108 | &:nth-child(odd) { | 111 | &:nth-child(odd) { |
-
Please register or login to post a comment