Authored by biao

update for outlet

@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 'use strict'; 6 'use strict';
7 7
8 const outletModel = require('../models/outlet'); 8 const outletModel = require('../models/outlet');
  9 +const headerModel = require('../../../doraemon/models/header');
9 10
10 const renderData = { 11 const renderData = {
11 module: 'product', 12 module: 'product',
@@ -13,14 +14,26 @@ const renderData = { @@ -13,14 +14,26 @@ const renderData = {
13 }; 14 };
14 15
15 exports.index = (req, res) => { 16 exports.index = (req, res) => {
  17 + let channel = req.query.channel || req.cookies._Channel || 'boys';
  18 + let headerData = headerModel.setNavHeader('OUTLET', channel, true, '', null);
  19 +
16 outletModel.getContent().then(result => { 20 outletModel.getContent().then(result => {
17 - res.render('outlet', Object.assign(renderData, result)); 21 + res.render('outlet', Object.assign({
  22 + pageHeader: headerData,
  23 + pageFooter: true
  24 + }, renderData, result));
18 }); 25 });
19 }; 26 };
20 27
21 exports.activity = (req, res) => { 28 exports.activity = (req, res) => {
22 - renderData.page = 'outlet-detail'; 29 + let channel = req.query.channel || req.cookies._Channel || 'boys';
  30 + let headerData = headerModel.setNavHeader('OUTLET', channel, true, '', null);
  31 +
23 outletModel.getActivity(req.query.id).then(result => { 32 outletModel.getActivity(req.query.id).then(result => {
24 - res.render('outlet/activity', Object.assign(renderData, result)); 33 + res.render('outlet/activity', Object.assign({
  34 + page: 'outlet-detail',
  35 + pageHeader: headerData,
  36 + pageFooter: true
  37 + }, renderData, result));
25 }); 38 });
26 }; 39 };
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 * @date: 2016/05/09 4 * @date: 2016/05/09
5 */ 5 */
6 'use strict'; 6 'use strict';
  7 +
7 const library = '../../../library'; 8 const library = '../../../library';
8 const utils = '../../../utils'; 9 const utils = '../../../utils';
9 10
@@ -20,6 +21,7 @@ const log = require(`${library}/logger`); @@ -20,6 +21,7 @@ const log = require(`${library}/logger`);
20 const serviceApi = new ServiceAPI(); 21 const serviceApi = new ServiceAPI();
21 const api = new API(); 22 const api = new API();
22 23
  24 +
23 const getOutletResource = () => { 25 const getOutletResource = () => {
24 const params = { 26 const params = {
25 content_code: 'c19ffa03f053f4cac3690b22c8da26b7', 27 content_code: 'c19ffa03f053f4cac3690b22c8da26b7',
@@ -112,14 +114,62 @@ const getActivityDetail = (id) => { @@ -112,14 +114,62 @@ const getActivityDetail = (id) => {
112 }); 114 });
113 }; 115 };
114 116
  117 +const convertActicityData = (data) => {
  118 + const formatData = [];
  119 + var showMore = false;
  120 + var i;
  121 +
  122 + data = data || [];
  123 + _.forEach(data, (item) => {
  124 + formatData.push({
  125 + activityUrl: 'outlet/activity?id=' + item.id,
  126 + coverUrl: item.coverUrl,
  127 + logoUrl: item.logoUrl,
  128 + title: item.title,
  129 + promotionName: item.promotionName,
  130 + startLeftTime: item.startLeftTime,
  131 + hide: false
  132 + });
  133 + });
  134 +
  135 +
  136 + if (formatData.length > 10) {
  137 + for (i = 10; i < formatData.length; i++) {
  138 + formatData[i].hide = true;
  139 + }
  140 + showMore = true;
  141 + }
  142 +
  143 + return {data: formatData, showMore: showMore};
  144 +};
  145 +
  146 +const getHomeActivity = (id) => {
  147 + var params = {
  148 + method: 'app.outlets.activityGet',
  149 + platform: 2,
  150 + size: 0,
  151 + yh_channel: 1,
  152 + type: id,
  153 + sort: 2,
  154 + client_type: 'h5'
  155 + };
  156 +
  157 + return api.get('', sign.apiSign(params)).then(res => {
  158 + if (id === 0) {
  159 + return convertActicityData(res.data);
  160 + }
  161 + return res.data;
  162 + });
  163 +};
115 164
116 exports.getContent = () => { 165 exports.getContent = () => {
117 let floorsData = {}; 166 let floorsData = {};
118 167
119 - return Promise.all([getNavData(), getOutletResource(), getGoodsList()]).then(data => { 168 + return Promise.all([getNavData(), getOutletResource(), getHomeActivity(0), getGoodsList()]).then(data => {
120 floorsData.nav = data[0] || []; 169 floorsData.nav = data[0] || [];
121 floorsData.content = data[1] || []; 170 floorsData.content = data[1] || [];
122 - floorsData.goods = data[2]; 171 + floorsData.activity = data[2] || [];
  172 + floorsData.goods = data[3];
123 173
124 return floorsData; 174 return floorsData;
125 }); 175 });
@@ -135,3 +185,21 @@ exports.getActivity = (id) => { @@ -135,3 +185,21 @@ exports.getActivity = (id) => {
135 return data; 185 return data;
136 }); 186 });
137 }; 187 };
  188 +
  189 +exports.willBeEnd = () => {
  190 + return getHomeActivity(3).then(res => {
  191 + var data = {};
  192 +
  193 + data.activity = res;
  194 + return data;
  195 + });
  196 +};
  197 +
  198 +exports.willBeCome = () => {
  199 + return getHomeActivity(4).then(res => {
  200 + var data = {};
  201 +
  202 + data.activity = res;
  203 + return res;
  204 + });
  205 +};
1 -<div class="goods-page yoho-page"> 1 +<div class="outlet-page goods-page yoho-page">
2 {{> product/sale/banner}} 2 {{> product/sale/banner}}
3 {{> common/filter-nav}} 3 {{> common/filter-nav}}
4 {{> product/sale/common}} 4 {{> product/sale/common}}
1 /** 1 /**
2 - * router of sub app guang 2 + * common head model
3 * @author: biao<bill.zhao@yoho.cn> 3 * @author: biao<bill.zhao@yoho.cn>
4 * @date: 2016/05/12 4 * @date: 2016/05/12
5 */ 5 */
1 -  
2 var $ = require('yoho-jquery'), 1 var $ = require('yoho-jquery'),
3 Swiper = require('yoho-swiper'), 2 Swiper = require('yoho-swiper'),
4 lazyLoad = require('yoho-jquery-lazyload'); 3 lazyLoad = require('yoho-jquery-lazyload');
5 4
6 // var nav = require('./outlet/nav'); 5 // var nav = require('./outlet/nav');
7 6
8 -var search = require('./sale/search'); 7 +require('./sale/search');
9 8
10 lazyLoad($('img.lazy')); 9 lazyLoad($('img.lazy'));
11 10
@@ -15,6 +14,7 @@ lazyLoad($('img.lazy')); @@ -15,6 +14,7 @@ lazyLoad($('img.lazy'));
15 14
16 15
17 16
  17 +
18 if ($('.swiper-container .swiper-slide').length > 1) { 18 if ($('.swiper-container .swiper-slide').length > 1) {
19 new Swiper('.swiper-container', { 19 new Swiper('.swiper-container', {
20 lazyLoading: true, 20 lazyLoading: true,
@@ -44,5 +44,24 @@ $('.outlet-category-nav').on('click', 'a', function(e) { @@ -44,5 +44,24 @@ $('.outlet-category-nav').on('click', 'a', function(e) {
44 query[key] = val; 44 query[key] = val;
45 }); 45 });
46 46
47 - search(null, query); 47 + // search(null, query);
48 }); 48 });
  49 +
  50 +if (('.outlet-page').length > 0) {
  51 + $('.more-activity').on('click', function() {
  52 + $('.more-activity').addClass('hidden');
  53 + $('.back-ground-white').removeClass('hidden');
  54 + });
  55 +}
  56 +
  57 +
  58 +if (('.outlet-page').length > 0) {
  59 +
  60 + $('.outlet-nav').find('li').each(function() {
  61 + // $(this).on('click', function() {
  62 +
  63 + // });
  64 + });
  65 +
  66 +
  67 +}
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 'use strict'; 5 'use strict';
6 6
7 -const library = '../../../library'; 7 +const library = '../library';
8 const helpers = require(`${library}/helpers`); 8 const helpers = require(`${library}/helpers`);
9 9
10 const timeFormat = { 10 const timeFormat = {