Authored by 毕凯

Merge branch 'feature/baseAct' into 'release/5.7'

Feature/base act



See merge request !565
@@ -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.yoho.isApp
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.yoho.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>
@@ -50,7 +50,7 @@ module.exports = () => { @@ -50,7 +50,7 @@ module.exports = () => {
50 // 判断请求是否来自app 50 // 判断请求是否来自app
51 yoho.isApp = (req.query.app_version && req.query.app_version !== 'false') || 51 yoho.isApp = (req.query.app_version && req.query.app_version !== 'false') ||
52 (req.query.appVersion && req.query.appVersion !== 'false') || 52 (req.query.appVersion && req.query.appVersion !== 'false') ||
53 - req.cookies.app_version; 53 + req.cookies.app_version || /YohoBuy/i.test(req.get('User-Agent') || '');
54 yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || ''); 54 yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || '');
55 yoho.isWeibo = ua.indexOf('weibo') !== -1; 55 yoho.isWeibo = ua.indexOf('weibo') !== -1;
56 yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || ''); 56 yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || '');
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;
@@ -39,6 +40,9 @@ class ActController extends Controller { @@ -39,6 +40,9 @@ class ActController extends Controller {
39 getMore('//m.yohobuy.com/activity/user-recommend/moreGoods', {page: page}).then(data => { 40 getMore('//m.yohobuy.com/activity/user-recommend/moreGoods', {page: page}).then(data => {
40 if (data.goodList.length > 0) { 41 if (data.goodList.length > 0) {
41 $('.goods').append(goodContent(data)); 42 $('.goods').append(goodContent(data));
  43 +
  44 + // 每次只lazyload倒数10
  45 + lazyLoad($('.goods img:gt(-11)'));
42 } else { 46 } else {
43 $('.gdt-c').append('<p class="show-more">没有更多了...</p>'); 47 $('.gdt-c').append('<p class="show-more">没有更多了...</p>');
44 this.end = true; 48 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) {