Authored by lijing

lazyload,app跳转,添加platform

... ... @@ -18,7 +18,8 @@ exports.index = (req, res, next) => {
let params = {
page: 1,
limit: 10
limit: 10,
isApp: req.query.app_version || req.query.appVersion ? true : false,
};
if (req.user.uid || req.query.uid) {
... ... @@ -41,7 +42,8 @@ exports.index = (req, res, next) => {
exports.moreGoods = (req, res, next) => {
let params = {
page: req.query.page || 1,
limit: 10
limit: 10,
isApp: req.query.isApp
};
if (req.user.uid || req.query.uid) {
... ...
... ... @@ -11,7 +11,8 @@ module.exports = class extends global.yoho.BaseModel {
let options = {
url: 'operations/api/v5/resource/home',
data: {
content_code: '8512bf0755cc549ac323f852c9fd945d'
content_code: '8512bf0755cc549ac323f852c9fd945d',
platform: 'iphone'
},
param: {
cache: true,
... ... @@ -73,13 +74,17 @@ module.exports = class extends global.yoho.BaseModel {
_.forEach(data, (val) => {
let discount = this.getDiscound(val.sales_price, val.market_price);
let url = `//m.yohobuy.com/product/${val.product_skn}.html`;
if (params.isApp) {
url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}"}}`; // eslint-disable-line
}
build.push({
productName: val.product_name,
salesPrice: val.sales_price,
marketPrice: val.market_price === val.sales_price ? '' : val.market_price,
defaultImages: val.default_images ? val.default_images.split(',')[0] : '',
productSkn: val.product_skn,
url: url,
discount: discount
});
});
... ... @@ -116,13 +121,18 @@ module.exports = class extends global.yoho.BaseModel {
_.forEach(data, (val) => {
let discount = this.getDiscound(val.sales_price, val.market_price);
let url = `//m.yohobuy.com/product/${val.product_skn}.html`;
if (params.isApp) {
url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}"}}`; // eslint-disable-line
}
build.push({
productName: val.product_name,
salesPrice: val.sales_price,
marketPrice: val.market_price === val.sales_price ? '' : val.market_price,
defaultImages: val.default_images ? val.default_images.split(',')[0] : '',
productSkn: val.product_skn,
url: url,
discount: discount
});
});
... ...
... ... @@ -25,20 +25,22 @@
<div class="big-title">潮流优选</div>
<div class="goods clearfix">
{{# goodList}}
<a class="good-item" href="//m.yohobuy.com/product/{{productSkn}}.html">
<a class="good-item" href="{{url}}">
<div class="pic">
<img src="{{image2 defaultImages w=330 h=379 q=90}}" />
<img class="lazy" data-original="{{image2 defaultImages w=330 h=379 q=90}}" />
</div>
<div class="price">¥{{salesPrice}}
{{#if marketPrice}}
<span>¥{{marketPrice}}</span>
{{/if}}
</div>
<div class="tip">
<div class="tip-c">
<div>{{productName}}</div>
<div class="tip-bg">
<div class="tip">
<div class="tip-c">
<div>{{productName}}</div>
</div>
<div class="ico"></div>
</div>
<div class="ico"></div>
</div>
<div class="discount">{{{discount}}}</div>
</a>
... ...
{{# goodList}}
<a class="good-item" href="//m.yohobuy.com/product/{{productSkn}}.html">
<a class="good-item" href="{{url}}">
<div class="pic">
<img src="{{image2 defaultImages w=330 h=379 q=90}}" />
<img class="lazy" data-original="{{image2 defaultImages w=330 h=379 q=90}}" />
</div>
<div class="price">¥{{salesPrice}}
{{#if marketPrice}}
<span>¥{{marketPrice}}</span>
{{/if}}
</div>
<div class="tip">
<div class="tip-c">
<div>{{productName}}</div>
<div class="tip-bg">
<div class="tip">
<div class="tip-c">
<div>{{productName}}</div>
</div>
<div class="ico"></div>
</div>
<div class="ico"></div>
</div>
<div class="discount">{{{discount}}}</div>
</a>
... ...
... ... @@ -12,13 +12,14 @@ import {
moreGoods as getMore
} from './model';
let $ = require('yoho-jquery');
let goodContent = require('activity/user-recommend/recommend-goods.hbs');
const $ = require('yoho-jquery');
const goodContent = require('activity/user-recommend/recommend-goods.hbs');
const lazyLoad = require('yoho-jquery-lazyload');
class ActController extends Controller {
constructor() {
super();
lazyLoad($('img.lazy'));
this.more = new GetMore();
this.more.on('more', this.doMore.bind(this));
this.page = 1;
... ... @@ -35,10 +36,14 @@ class ActController extends Controller {
moreGood(page) {
this.loading = true;
this.isApp = window.queryString.app_version || window.queryString.appVersion ? true : false;
$('.gdt-c').append('<p class="show-more">加载更多...</p>');
getMore('//m.yohobuy.com/activity/user-recommend/moreGoods', {page: page}).then(data => {
getMore('//m.yohobuy.com/activity/user-recommend/moreGoods', {page: page, isApp: this.isApp}).then(data => {
if (data.goodList.length > 0) {
$('.goods').append(goodContent(data));
// 每次只lazyload倒数10
lazyLoad($('.goods img:gt(-11)'));
} else {
$('.gdt-c').append('<p class="show-more">没有更多了...</p>');
this.end = true;
... ...
... ... @@ -7,6 +7,10 @@
font-size: 28px;
}
.tip-bg {
background-color: #292929;
}
.big-pic {
width: 750px;
display: block;
... ... @@ -102,7 +106,6 @@
float: left;
margin-bottom: 50px;
position: relative;
background-color: #292929;
display: block;
&:nth-child(odd) {
... ...