Authored by 王水玲

sale 首页

... ... @@ -6,17 +6,64 @@
'use strict';
// const mRoot = '../models';
const mRoot = '../models';
const cookie = require('../../../library/cookie');
const headerModel = require('../../../doraemon/models/header');
const log = require('../../../library/logger');
const sale = require(`${mRoot}/sale`);
// sale model
// const sale = require(`${mRoot}/sale`);
const saleLogger = (err, res) => {
log.error('sale页面渲染错误:' + JSON.stringify(err));
res.send('error');
};
exports.index = (req, res) => {
res.render('sale', {
devEnv: true,
pageHeader: headerModel.setNavHeader('SALE'),
let headerData = headerModel.setNavHeader('SALE');
let renderData = {
module: 'product',
page: 'sale',
pageHeader: headerData,
pageFooter: true
};
// res.render('sale', renderData);
sale.getSaleDate({
uid: cookie.getUid(req)
}).then(result => {
result = {
headerBanner: {
list: [
{
url: '',
src: 'http://img11.static.yhbimg.com/yhb-img01/2016/04/18/06/01abda0859d64f9af63a434ca281d213c5.jpg?imageView2/2/w/640/h/240'
},
{
url: '',
src: 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/05/0239e814b8121913aa67b9ad509bd4e310.jpg?imageView2/2/w/640/h/240'
}
]
},
smallPic: {
data: [
{
url: '',
src: 'http://img11.static.yhbimg.com/yhb-img01/2016/05/12/15/011684760312d139ac2429c3678951ebd0.jpg?imageView2/2/w/640/h/403'
},
{
url: '',
src: 'http://img11.static.yhbimg.com/yhb-img01/2016/05/12/15/011684760312d139ac2429c3678951ebd0.jpg?imageView2/2/w/640/h/403'
},
{
url: '',
src: 'http://img11.static.yhbimg.com/yhb-img01/2016/05/12/15/011684760312d139ac2429c3678951ebd0.jpg?imageView2/2/w/275/h/160'
}
]
}
};
res.render('sale', Object.assign(renderData, result));
}).catch((err) => {
saleLogger(err, res);
});
};
... ...
... ... @@ -13,6 +13,11 @@ var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
... ...
/**
* 频道页面 model
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/05/17
*/
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const api = new API();
/**
* 获取首页数据
* @param {[object]} params
* @return {[object]}
*/
exports.getSaleDate = (params) => {
return api.get('', sign.apiSign(Object.assign({
method: 'app.activity.get'
}, params)));
};
... ...
<div class="discount-page yoho-page">
<div class="discount-page sale-page yoho-page">
{{# headerBanner}}
{{> product/banner-swipe-and-single}}
{{/ headerBanner}}
{{# smallPic}}
{{> product/thumb-row}}
{{/ smallPic}}
</div>
\ No newline at end of file
... ...
... ... @@ -5,7 +5,7 @@
{{# list}}
<li class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
<img class="swiper-lazy" data-src="{{src}}">
</a>
<div class="swiper-lazy-preloader"></div>
</li>
... ...
<div id="thumb-row">
{{# data}}
<a href="{{url}}">
<div class="thumb-row-box" style="background-image:url({{image src 275 160}})"></div>
</a>
{{/ data}}
</div>
... ...
... ... @@ -12,7 +12,7 @@ const isTest = process.env.NODE_ENV === 'test';
module.exports = {
siteUrl: 'http://m.yohobuy.com',
domains: {
api: 'http://testapi.yoho.cn:28078/', // http://devapi.yoho.cn:58078/ http://testapi.yoho.cn:28078/
api: 'http://192.168.102.207:8080/gateway/', // http://devapi.yoho.cn:58078/ http://testapi.yoho.cn:28078/
service: 'http://devapi.yoho.cn:58078/'
},
loggers: {
... ...
/**
* sale
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/5/17
*/
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper');
if ($('.swiper-container .swiper-slide').length > 1) {
new Swiper('.swiper-container', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: true,
paginationClickable: true,
pagination: '.banner-top .pagination-inner'
});
}
... ...
require('./sale');
... ...
... ... @@ -10,4 +10,5 @@
@import "product/comments-consults";
@import "product/product-description";
@import "product/recommend-for-you";
@import "product/sale";
@import "cart/chose-panel";
... ...
.sale-page {
#thumb-row {
text-align: left;
.thumb-row-box {
border-radius: 20px;
}
}
}
... ...