Showing
11 changed files
with
126 additions
and
10 deletions
@@ -6,17 +6,64 @@ | @@ -6,17 +6,64 @@ | ||
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -// const mRoot = '../models'; | ||
10 | - | 9 | +const mRoot = '../models'; |
10 | +const cookie = require('../../../library/cookie'); | ||
11 | const headerModel = require('../../../doraemon/models/header'); | 11 | const headerModel = require('../../../doraemon/models/header'); |
12 | +const log = require('../../../library/logger'); | ||
13 | +const sale = require(`${mRoot}/sale`); | ||
12 | 14 | ||
13 | -// sale model | ||
14 | -// const sale = require(`${mRoot}/sale`); | 15 | +const saleLogger = (err, res) => { |
16 | + log.error('sale页面渲染错误:' + JSON.stringify(err)); | ||
17 | + res.send('error'); | ||
18 | +}; | ||
15 | 19 | ||
16 | exports.index = (req, res) => { | 20 | exports.index = (req, res) => { |
17 | - res.render('sale', { | ||
18 | - devEnv: true, | ||
19 | - pageHeader: headerModel.setNavHeader('SALE'), | 21 | + let headerData = headerModel.setNavHeader('SALE'); |
22 | + let renderData = { | ||
23 | + module: 'product', | ||
24 | + page: 'sale', | ||
25 | + pageHeader: headerData, | ||
20 | pageFooter: true | 26 | pageFooter: true |
27 | + }; | ||
28 | + | ||
29 | + // res.render('sale', renderData); | ||
30 | + | ||
31 | + sale.getSaleDate({ | ||
32 | + uid: cookie.getUid(req) | ||
33 | + }).then(result => { | ||
34 | + result = { | ||
35 | + headerBanner: { | ||
36 | + list: [ | ||
37 | + { | ||
38 | + url: '', | ||
39 | + src: 'http://img11.static.yhbimg.com/yhb-img01/2016/04/18/06/01abda0859d64f9af63a434ca281d213c5.jpg?imageView2/2/w/640/h/240' | ||
40 | + }, | ||
41 | + { | ||
42 | + url: '', | ||
43 | + src: 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/05/0239e814b8121913aa67b9ad509bd4e310.jpg?imageView2/2/w/640/h/240' | ||
44 | + } | ||
45 | + ] | ||
46 | + }, | ||
47 | + smallPic: { | ||
48 | + data: [ | ||
49 | + { | ||
50 | + url: '', | ||
51 | + src: 'http://img11.static.yhbimg.com/yhb-img01/2016/05/12/15/011684760312d139ac2429c3678951ebd0.jpg?imageView2/2/w/640/h/403' | ||
52 | + }, | ||
53 | + { | ||
54 | + url: '', | ||
55 | + src: 'http://img11.static.yhbimg.com/yhb-img01/2016/05/12/15/011684760312d139ac2429c3678951ebd0.jpg?imageView2/2/w/640/h/403' | ||
56 | + }, | ||
57 | + { | ||
58 | + url: '', | ||
59 | + src: 'http://img11.static.yhbimg.com/yhb-img01/2016/05/12/15/011684760312d139ac2429c3678951ebd0.jpg?imageView2/2/w/275/h/160' | ||
60 | + } | ||
61 | + ] | ||
62 | + } | ||
63 | + }; | ||
64 | + | ||
65 | + res.render('sale', Object.assign(renderData, result)); | ||
66 | + }).catch((err) => { | ||
67 | + saleLogger(err, res); | ||
21 | }); | 68 | }); |
22 | }; | 69 | }; |
@@ -13,6 +13,11 @@ var app = express(); | @@ -13,6 +13,11 @@ var app = express(); | ||
13 | // set view engin | 13 | // set view engin |
14 | var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root | 14 | var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root |
15 | 15 | ||
16 | +app.on('mount', function(parent) { | ||
17 | + delete parent.locals.settings; // 不继承父 App 的设置 | ||
18 | + Object.assign(app.locals, parent.locals); | ||
19 | +}); | ||
20 | + | ||
16 | app.set('views', path.join(__dirname, 'views/action')); | 21 | app.set('views', path.join(__dirname, 'views/action')); |
17 | app.engine('.hbs', hbs({ | 22 | app.engine('.hbs', hbs({ |
18 | extname: '.hbs', | 23 | extname: '.hbs', |
1 | +/** | ||
2 | + * 频道页面 model | ||
3 | + * @author: wsl<shuiling.wang@yoho.cn> | ||
4 | + * @date: 2016/05/17 | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | +const library = '../../../library'; | ||
8 | +const API = require(`${library}/api`).API; | ||
9 | +const sign = require(`${library}/sign`); | ||
10 | +const api = new API(); | ||
11 | + | ||
12 | +/** | ||
13 | + * 获取首页数据 | ||
14 | + * @param {[object]} params | ||
15 | + * @return {[object]} | ||
16 | + */ | ||
17 | +exports.getSaleDate = (params) => { | ||
18 | + | ||
19 | + return api.get('', sign.apiSign(Object.assign({ | ||
20 | + method: 'app.activity.get' | ||
21 | + }, params))); | ||
22 | +}; |
1 | -<div class="discount-page yoho-page"> | 1 | +<div class="discount-page sale-page yoho-page"> |
2 | {{# headerBanner}} | 2 | {{# headerBanner}} |
3 | {{> product/banner-swipe-and-single}} | 3 | {{> product/banner-swipe-and-single}} |
4 | {{/ headerBanner}} | 4 | {{/ headerBanner}} |
5 | + | ||
6 | + {{# smallPic}} | ||
7 | + {{> product/thumb-row}} | ||
8 | + {{/ smallPic}} | ||
5 | </div> | 9 | </div> |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | {{# list}} | 5 | {{# list}} |
6 | <li class="swiper-slide"> | 6 | <li class="swiper-slide"> |
7 | <a href="{{url}}"> | 7 | <a href="{{url}}"> |
8 | - <img class="swiper-lazy" data-src="{{img}}"> | 8 | + <img class="swiper-lazy" data-src="{{src}}"> |
9 | </a> | 9 | </a> |
10 | <div class="swiper-lazy-preloader"></div> | 10 | <div class="swiper-lazy-preloader"></div> |
11 | </li> | 11 | </li> |
@@ -12,7 +12,7 @@ const isTest = process.env.NODE_ENV === 'test'; | @@ -12,7 +12,7 @@ const isTest = process.env.NODE_ENV === 'test'; | ||
12 | module.exports = { | 12 | module.exports = { |
13 | siteUrl: 'http://m.yohobuy.com', | 13 | siteUrl: 'http://m.yohobuy.com', |
14 | domains: { | 14 | domains: { |
15 | - api: 'http://testapi.yoho.cn:28078/', // http://devapi.yoho.cn:58078/ http://testapi.yoho.cn:28078/ | 15 | + api: 'http://192.168.102.207:8080/gateway/', // http://devapi.yoho.cn:58078/ http://testapi.yoho.cn:28078/ |
16 | service: 'http://devapi.yoho.cn:58078/' | 16 | service: 'http://devapi.yoho.cn:58078/' |
17 | }, | 17 | }, |
18 | loggers: { | 18 | loggers: { |
public/js/product/sale.js
0 → 100644
1 | +/** | ||
2 | + * sale | ||
3 | + * @author: wsl<shuiling.wang@yoho.cn> | ||
4 | + * @date: 2016/5/17 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'), | ||
7 | + Swiper = require('yoho-swiper'); | ||
8 | + | ||
9 | +if ($('.swiper-container .swiper-slide').length > 1) { | ||
10 | + new Swiper('.swiper-container', { | ||
11 | + lazyLoading: true, | ||
12 | + lazyLoadingInPrevNext: true, | ||
13 | + loop: true, | ||
14 | + autoplay: 3000, | ||
15 | + autoplayDisableOnInteraction: true, | ||
16 | + paginationClickable: true, | ||
17 | + pagination: '.banner-top .pagination-inner' | ||
18 | + }); | ||
19 | +} |
public/js/product/sale.page.js
0 → 100644
1 | +require('./sale'); |
@@ -10,4 +10,5 @@ | @@ -10,4 +10,5 @@ | ||
10 | @import "product/comments-consults"; | 10 | @import "product/comments-consults"; |
11 | @import "product/product-description"; | 11 | @import "product/product-description"; |
12 | @import "product/recommend-for-you"; | 12 | @import "product/recommend-for-you"; |
13 | +@import "product/sale"; | ||
13 | @import "cart/chose-panel"; | 14 | @import "cart/chose-panel"; |
-
Please register or login to post a comment