Authored by biao

update for outlet

... ... @@ -6,6 +6,7 @@
'use strict';
const outletModel = require('../models/outlet');
const headerModel = require('../../../doraemon/models/header');
const renderData = {
module: 'product',
... ... @@ -13,14 +14,26 @@ const renderData = {
};
exports.index = (req, res) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
let headerData = headerModel.setNavHeader('OUTLET', channel, true, '', null);
outletModel.getContent().then(result => {
res.render('outlet', Object.assign(renderData, result));
res.render('outlet', Object.assign({
pageHeader: headerData,
pageFooter: true
}, renderData, result));
});
};
exports.activity = (req, res) => {
renderData.page = 'outlet-detail';
let channel = req.query.channel || req.cookies._Channel || 'boys';
let headerData = headerModel.setNavHeader('OUTLET', channel, true, '', null);
outletModel.getActivity(req.query.id).then(result => {
res.render('outlet/activity', Object.assign(renderData, result));
res.render('outlet/activity', Object.assign({
page: 'outlet-detail',
pageHeader: headerData,
pageFooter: true
}, renderData, result));
});
};
... ...
... ... @@ -4,6 +4,7 @@
* @date: 2016/05/09
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
... ... @@ -20,6 +21,7 @@ const log = require(`${library}/logger`);
const serviceApi = new ServiceAPI();
const api = new API();
const getOutletResource = () => {
const params = {
content_code: 'c19ffa03f053f4cac3690b22c8da26b7',
... ... @@ -112,14 +114,62 @@ const getActivityDetail = (id) => {
});
};
const convertActicityData = (data) => {
const formatData = [];
var showMore = false;
var i;
data = data || [];
_.forEach(data, (item) => {
formatData.push({
activityUrl: 'outlet/activity?id=' + item.id,
coverUrl: item.coverUrl,
logoUrl: item.logoUrl,
title: item.title,
promotionName: item.promotionName,
startLeftTime: item.startLeftTime,
hide: false
});
});
if (formatData.length > 10) {
for (i = 10; i < formatData.length; i++) {
formatData[i].hide = true;
}
showMore = true;
}
return {data: formatData, showMore: showMore};
};
const getHomeActivity = (id) => {
var params = {
method: 'app.outlets.activityGet',
platform: 2,
size: 0,
yh_channel: 1,
type: id,
sort: 2,
client_type: 'h5'
};
return api.get('', sign.apiSign(params)).then(res => {
if (id === 0) {
return convertActicityData(res.data);
}
return res.data;
});
};
exports.getContent = () => {
let floorsData = {};
return Promise.all([getNavData(), getOutletResource(), getGoodsList()]).then(data => {
return Promise.all([getNavData(), getOutletResource(), getHomeActivity(0), getGoodsList()]).then(data => {
floorsData.nav = data[0] || [];
floorsData.content = data[1] || [];
floorsData.goods = data[2];
floorsData.activity = data[2] || [];
floorsData.goods = data[3];
return floorsData;
});
... ... @@ -135,3 +185,21 @@ exports.getActivity = (id) => {
return data;
});
};
exports.willBeEnd = () => {
return getHomeActivity(3).then(res => {
var data = {};
data.activity = res;
return data;
});
};
exports.willBeCome = () => {
return getHomeActivity(4).then(res => {
var data = {};
data.activity = res;
return res;
});
};
... ...
<div class="goods-page yoho-page">
<div class="outlet-page goods-page yoho-page">
{{> product/sale/banner}}
{{> common/filter-nav}}
{{> product/sale/common}}
... ...
/**
* router of sub app guang
* common head model
* @author: biao<bill.zhao@yoho.cn>
* @date: 2016/05/12
*/
... ...
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload');
// var nav = require('./outlet/nav');
var search = require('./sale/search');
require('./sale/search');
lazyLoad($('img.lazy'));
... ... @@ -15,6 +14,7 @@ lazyLoad($('img.lazy'));
if ($('.swiper-container .swiper-slide').length > 1) {
new Swiper('.swiper-container', {
lazyLoading: true,
... ... @@ -44,5 +44,24 @@ $('.outlet-category-nav').on('click', 'a', function(e) {
query[key] = val;
});
search(null, query);
// search(null, query);
});
if (('.outlet-page').length > 0) {
$('.more-activity').on('click', function() {
$('.more-activity').addClass('hidden');
$('.back-ground-white').removeClass('hidden');
});
}
if (('.outlet-page').length > 0) {
$('.outlet-nav').find('li').each(function() {
// $(this).on('click', function() {
// });
});
}
... ...
... ... @@ -4,7 +4,7 @@
'use strict';
const library = '../../../library';
const library = '../library';
const helpers = require(`${library}/helpers`);
const timeFormat = {
... ...