Authored by 李靖

more

... ... @@ -32,3 +32,13 @@ exports.index = (req, res, next) => {
res.render('guang-new', Object.assign(responseData, result));
}).catch(next);
};
exports.more = (req, res, next) => {
let params = {
page: req.query.page
};
req.ctx(newGuangModel).list(params).then(result => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -22,6 +22,28 @@ class newGuang extends global.yoho.BaseModel {
});
}
list(params) {
let options = {
url: '/guang/api/v1/article/getHomePageList',
data: {
page: params.page || 1,
limit: params.limit || 2
},
api: global.yoho.ServiceAPI
};
return this.get(options).then(result => {
let resu = {
list: []
};
if (_.get(result, 'data.guangList')) {
resu.list = result.data.guangList;
}
return resu;
});
}
index(params) {
return Promise.all([
this._indexRes(params)
... ... @@ -48,9 +70,6 @@ class newGuang extends global.yoho.BaseModel {
if (val.template_name === 'GuangHhFloor') {
resu.floorRes.haoHuo = _.get(val, 'data.list');
}
if (val.template_name === 'GuangShowOrderFloor') {
resu.floorRes.show = _.get(val, 'data.list');
}
});
}
... ...
... ... @@ -78,5 +78,6 @@ router.get('/plusstar/brandList', brand.brandList);
router.get('/sitemap.xml', sitemap.siteMap);
router.get('/guang-new', guangNew.index);
router.get('/guang-new/more', guangNew.more);
module.exports = router;
... ...
... ... @@ -130,45 +130,29 @@
<p class="eps">马思唯:有趣的人会买东西</p>
</div>
</div>
{{#if floorRes.show}}
<div class="big-title">
<div class="big-title hide">
SHOW
<span class="iconfont">MORE&nbsp;&#xe604;</span>
</div>
<div class="swiper-show">
<div class="swiper-show hide">
<div class="swiper-container">
<div class="swiper-wrapper">
{{# floorRes.show}}
<div class="swiper-slide">
<a href="//m.yohobuy.com/product/{{productSkn}}.html">
<img src="{{image2 url w=358 h=358 q=30}}" />
<p class="words eps-2">{{content}}</p>
<div class="auther">
<span class="name">来自#{{userName}}#</span>
<span class="iconfont hide">&#xe601;</span>
</div>
</a>
<img src="" />
<p class="words eps-2"></p>
<div class="auther">
<span class="name"></span>
<span class="iconfont">&#xe601;</span>
</div>
</div>
{{/ floorRes.show}}
</div>
</div>
</div>
{{/if}}
<div class="big-title hide">
<div class="big-title">
<span class="iconfont">MORE&nbsp;&#xe604;</span>
</div>
<div class="guang-list hide">
<div class="guang-item">
<div class="page-c">
<img src="http://img11.static.yhbimg.com/yhb-img01/2017/10/27/11/01ea9512175a0c5795bfd01048271b654e.jpg" />
<div class="info">
<p class="name eps-2">DICKIES从诞生之日起就旨在出品高品质DICKIES从诞生之日起就旨在出品就旨在出品就旨在出品高品质</p>
<p class="type">3潮流</p>
</div>
</div>
</div>
<a class="iconfont" href="//guang.m.yohobuy.com/?gender={{gender}}">MORE&nbsp;&#xe604;</a>
</div>
<div class="guang-list"></div>
<div class="trend-list hide">
<div class="trend-item">
<img src="http://img11.static.yhbimg.com/yhb-img01/2017/10/27/11/01ea9512175a0c5795bfd01048271b654e.jpg" />
... ...
... ... @@ -11,14 +11,18 @@ const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const domains = {
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api',
global: 'http://api-global.yohobuy.com',
store: 'http://192.168.102.47:8080/portal-gateway/',
platformApi: 'http://192.168.102.48:8088/',
store: 'http://192.168.102.47:8080/portal-gateway/wechat/',
extstore: 'http://extstore-test1.yohops.com',
family: 'http://192.168.103.73:8096/uic/',
yohoNowApi: 'http://yohonow-test.yohops.com:9999/'
... ... @@ -74,7 +78,7 @@ module.exports = {
maxFiles: 7
},
console: {
level: 'info',
level: 'debug',
colorize: 'all',
prettyPrint: true
}
... ...
... ... @@ -3,16 +3,26 @@ import $ from 'yoho-jquery';
import Page from 'yoho-page';
import Swiper from 'yoho-swiper';
import moreRender from 'guang/list.hbs';
class GuangNew extends Page {
constructor() {
super();
this.selector = {
$parentObj: $('.swiper-tab'),
$fixed: $('.fixed')
$fixed: $('.fixed'),
$guangList: $('.guang-list')
};
this.view = {
moreRender
};
this.fixedTop = 0;
this.page = 0;
this.end = false;
this.loading = false;
this.init();
}
... ... @@ -25,6 +35,45 @@ class GuangNew extends Page {
this.swiperShow();
this.fixed();
this.fixedRetop();
this.list();
}
list() {
$(window).scroll(() => {
window.requestAnimationFrame(this.scrollHandler.bind(this));
});
}
scrollHandler() {
if (($(window).scrollTop() + $(window).height() >= $(document).height() * 0.8)) {
this.doMore();
}
}
doMore() {
if (!this.end && !this.loading) {
this.page++;
this.moreList(this.page);
}
}
moreList() {
this.loading = true;
this.ajax({
url: '/guang/guang-new/more',
data: {
page: this.page
},
}).then(result => {
if (result && result.list.length > 0) {
this.selector.$guangList.append(this.view.moreRender(result));
this.loading = false;
} else {
this.end = true;
}
}).catch(error => {
console.error(error);
});
}
// 返回顶部,最新资讯
... ...