Authored by biao

update

... ... @@ -19,7 +19,8 @@ exports.index = (req, res) => {
};
exports.activity = (req, res) => {
outletModel.getActivity().then(result => {
renderData.page = 'outlet-detail';
outletModel.getActivity(req.query.id).then(result => {
res.render('outlet/activity', Object.assign(renderData, result));
});
};
... ...
... ... @@ -54,11 +54,12 @@ const convertNavData = (list) => {
const getNavData = () => {
const params = {
client_type: 'iphone',
os_version: 8.4,
screen_size: '320x568',
// client_type: 'iphone',
// os_version: 8.4,
// screen_size: '320x568',
v: 7,
parent_id: 1107,
// parent_id: 1107,
debug: 'XYZ'
};
... ... @@ -66,7 +67,7 @@ const getNavData = () => {
if (result && result.code === 200) {
return convertNavData(result.data);
} else {
log.error('奥莱资源位接口返回状态码 不是 200');
log.error('奥莱导航接口返回状态码 不是 200', result);
return result;
}
});
... ... @@ -91,13 +92,13 @@ const getGoodsList = () => {
});
};
const getActivityDetail = () => {
const getActivityDetail = (id) => {
var params = {
method: 'app.outlets.activityGet',
sort: 2,
platform: 2,
yh_channel: 1,
id: 170,
id: id,
type: 0
};
... ... @@ -125,11 +126,12 @@ exports.getContent = () => {
};
exports.getActivity = () => {
return getActivityDetail().then(res => {
exports.getActivity = (id) => {
return getActivityDetail(id).then(res => {
var data = {};
data.outletActivity = res;
data.productPool = res[0] && res[0].productPoolId || '';
return data;
});
};
... ...
... ... @@ -10,29 +10,15 @@ const API = require(`${library}/api`).API;
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const sign = require(`${library}/sign`);
const logger = require(`${library}/logger`);
const helpers = require(`${library}/helpers`);
const camelCase = require(`${library}/camel-case`);
const resourcesProcess = require(`${utils}/resources-process`);
const productProcess = require(`${utils}/product-process`);
const processTime = require(`${utils}/time-process`);
const _ = require('lodash');
const api = new API();
const serviceAPI = new ServiceAPI();
const anHour = 3600;
const aDay = anHour * 24;
/**
* 需要格式化的时间格式
*/
const timeFormat = {
d: '剩{d}天',
h: '剩{h}小时',
m: '剩{m}分钟',
s: '剩{s}秒',
dh: '剩{d}天{h}小时',
dhms: '剩{d}天{h}小时{m}分钟{s}秒',
hms: '剩{h}小时{m}分钟{s}秒',
ms: '剩{m}分钟{s}秒'
};
/**
* 排序转换
... ... @@ -71,30 +57,7 @@ const contentCode = {
}
};
/**
* 折扣专场专题列表过期时间处理
* @param {[string]} time
* @return {[object]}
*/
const processTime = (time) => {
let data = {};
let type = '';
if (time < anHour) {
data.warnColor = true;
data.time = '低于1小时';
} else {
if (time > aDay) {
type = 'dh';
} else {
type = 'h';
}
data.time = helpers.dateDiffFormat(timeFormat[type], time, 's');
}
return data;
};
/**
* 折扣专场列表数据处理
... ...
{{>product/sale/banner}}
<div class="goods-page yoho-page">
{{> product/sale/banner}}
{{> common/filter-nav}}
{{> product/sale/common}}
</div>
... ...
<div class="outlet-page">
<div class="outlet-page goods-page yoho-page">
{{> product/outlet/nav }}
{{> product/outlet/resource }}
</div>
... ...
... ... @@ -16,37 +16,7 @@
{{> common/floor-header}}
{{/floorHeader}}
<ul id="list-nav" class="list-nav clearfix">
<li class="new active">
<a href="javascript:void(0);">
<span class="span-test">最新</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="span-test">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount">
<a href="javascript:void(0);">
<span class="span-test">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="span-test">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
{{> common/filter-nav}}
{{> product/sale/common}}
... ...
<nav class="outlet-nav">
<nav id="list-nav" class="outlet-nav outlet-category-nav">
<ul>
<li><a href="{{url}}">全部</a></li>
<li><a href="?gender=1,3">全部</a></li>
{{#data}}
<li><a href="{{url}}">{{categoryName}}</a></li>
{{/data}}
... ...
... ... @@ -48,4 +48,3 @@
{{> resources/plus-star}}
{{/if}}
{{/content}}
{{log goods}}
... ...
... ... @@ -14,7 +14,8 @@
{{# outletActivity}}
<img src="{{image webUrl 640 250}}"/>
<p class="activity-time" data-time-ms="{{startLeftTime}}"><i class="iconfont time-ico">&#xe603;</i><span>{{time}}</span></p>
<p class="outlet-activity-time" data-time-ms="{{endLeftTime}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p>
<p class="outlet-discount">{{promotionName}}</p>
{{/ outletActivity}}
</div>
... ...
... ... @@ -14,4 +14,4 @@
{{> common/query-param}}
{{> common/suspend-cart}}
\ No newline at end of file
{{> common/suspend-cart}}
... ...
<ul id="list-nav" class="list-nav clearfix">
<li class="new active">
<a href="javascript:void(0);">
<span class="span-test">最新</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="span-test">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount">
<a href="javascript:void(0);">
<span class="span-test">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="span-test">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
... ...
... ... @@ -64,4 +64,9 @@
{{#if limit}}
<input class="query-param" type="hidden" data-attr="limit" value="{{limit}}">
{{/if}}
\ No newline at end of file
{{/if}}
{{#if productPool}}
<input class="query-param" type="hidden" data-attr="productPool" value="{{productPool}}">
{{/if}}
... ...
/**
* 倒计时控件
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/5/20
*/
var $ = require('yoho-jquery');
var $activityTime = $('.activity-time'),
endTime = $activityTime ? $activityTime.data('time-ms') : '';
var params = {
anHour: 3600, // 1小时=?秒
aMinute: 60, // 1分钟=?秒
aSecond: 1, // 1秒=?秒
timeDom: $activityTime, // 时间对象数组
endTime: [endTime] // 时间差数组
};
// 倒计时
function getRTime(conf) {
var showTime = '',
d = 0,
h = 0,
m = 0,
s = 0;
conf.timeDom.each(function(key, item) {
showTime = '';
conf.endTime[key] = conf.endTime[key] - conf.aSecond;
if (conf.endTime[key] > conf.aSecond) {
d = Math.floor(conf.endTime[key] / conf.anHour / 24);
h = Math.floor(conf.endTime[key] / conf.anHour % 24);
m = Math.floor(conf.endTime[key] / conf.aMinute % 60);
s = Math.floor(conf.endTime[key] / conf.aSecond % 60);
showTime += d > 0 ? d + '天' : '';
showTime += h > 0 ? h + '小时' : '';
showTime += m + '分钟';
showTime += s > 0 ? s + '秒' : '';
if (showTime.length !== '') {
showTime = '剩' + showTime;
}
$(item).find('span').html(showTime);
$(item).fadeIn();
} else {
$(item).hide();
}
});
}
function startCountDown(p) {
$.extend(params, p || {});
setInterval(function() {
getRTime(params);
}, 1000);
}
module.exports = startCountDown;
... ...
... ... @@ -6,56 +6,12 @@
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var $activityTime = $('.activity-time'),
endTime = $activityTime.data('time-ms');
var params = {
anHour: 3600, // 1小时=?秒
aMinute: 60, // 1分钟=?秒
aSecond: 1, // 1秒=?秒
timeDom: $activityTime, // 时间对象数组
endTime: [endTime] // 时间差数组
};
var countDown = require('../plugin/countdown');
require('./sale/search');
lazyLoad($('img.lazy'));
// 倒计时
function getRTime(conf) {
var showTime = '',
d = 0,
h = 0,
m = 0,
s = 0;
conf.timeDom.each(function(key, item) {
showTime = '';
conf.endTime[key] = conf.endTime[key] - conf.aSecond;
if (conf.endTime[key] > conf.aSecond) {
d = Math.floor(conf.endTime[key] / conf.anHour / 24);
h = Math.floor(conf.endTime[key] / conf.anHour % 24);
m = Math.floor(conf.endTime[key] / conf.aMinute % 60);
s = Math.floor(conf.endTime[key] / conf.aSecond % 60);
showTime += d > 0 ? d + '天' : '';
showTime += h > 0 ? h + '小时' : '';
showTime += m > 0 ? m + '分钟' : '';
showTime += s > 0 ? s + '秒' : '';
if (showTime.length !== '') {
showTime = '剩' + showTime;
}
countDown();
$(item).find('span').html(showTime);
$(item).fadeIn();
} else {
$(item).hide();
}
});
}
setInterval(function() {
getRTime(params);
}, 1000);
... ...
var $ = require('yoho-jquery'),
countDown = require('../plugin/countdown');
var $time = $('.outlet-activity-time'),
endTime = $time.data('time-ms');
require('./sale/search');
countDown({
timeDom: $time,
endTime: [endTime]
});
... ...
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper');
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload');
// var nav = require('./outlet/nav');
var search = require('./sale/search');
lazyLoad($('img.lazy'));
// nav({
// navClass: '.outlet-nav'
// })
require('./outlet/home');
require('./sale/search');
if ($('.swiper-container .swiper-slide').length > 1) {
new Swiper('.swiper-container', {
... ... @@ -17,3 +26,23 @@ if ($('.swiper-container .swiper-slide').length > 1) {
pagination: '.banner-top .pagination-inner'
});
}
$('.outlet-category-nav').on('click', 'a', function(e) {
var href = $(this).attr('href'), // eslint-disable-line
querys = href.split('?')[1].split('&');
var query = {};
e.preventDefault();
querys.forEach(function(value) {
var queryPairs = value.split('='),
key = queryPairs[0],
val = queryPairs[1];
query[key] = val;
});
search(null, query);
});
... ...
var $ = require('yoho-jquery'),
IScroll = require('yoho-iscroll'),
lazyLoad = require('yoho-jquery-lazyload');
IScroll = require('yoho-iscroll');
lazyLoad($('img.lazy'));
var defaultOpt = {
navClass: '.outlet-nav'
};
// nav 滚动
function initNavScroll() {
var $navBox = $('.outlet-nav'),
$lis = $navBox.find('li'),
function initNavScroll(opt) {
var $navBox,
// $lis,
iScroll;
$.extend(opt || {}, defaultOpt);
$navBox = $(opt.navClass);
// $lis = $navBox.find('li');
function scroll(ele) {
var offset;
... ... @@ -21,20 +27,23 @@ function initNavScroll() {
}, 1);
}
iScroll = new IScroll($navBox[0], {
scrollX: true,
scrollY: false
$.each($navBox, function(index) {
iScroll = new IScroll($navBox[index], {
scrollX: true,
scrollY: false
});
});
$navBox.on('click', 'li', function() {
var $this = $(this); // eslint-disable-line
var i = $this.index();
$lis.eq(i).addClass('active').siblings().removeClass('active');
scroll($this[0]);
});
// $navBox.on('click', 'li', function() {
// var $this = $(this); // eslint-disable-line
// var i = $this.index();
// $lis.eq(i).addClass('active').siblings().removeClass('active');
// scroll($this[0]);
// });
scroll($navBox.find('.active')[0]);
}
initNavScroll();
module.exports = initNavScroll;
... ...
... ... @@ -112,7 +112,7 @@ function judgeType(dom) {
* 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
* @param opt {type, id}
*/
function search(opt) {
function search(opt, params) {
var setting = {},
ext,
att,
... ... @@ -184,6 +184,10 @@ function search(opt) {
$.extend(defaultOpt, ext); // 扩展筛选项
}
if (params) {
$.extend(defaultOpt, params);
}
// 导航类别
navType = judgeType($pre);
... ... @@ -355,7 +359,7 @@ $listNav.on('touchend touchcancel', function(e) {
// 导航类别
navType = judgeType($this);
nav = navInfo[navType];
nav = navInfo[navType || 'all'];
if ($this.hasClass('active')) {
... ... @@ -415,7 +419,7 @@ $listNav.on('touchend touchcancel', function(e) {
$this.addClass('active');
}
if (nav.reload) {
if (nav && nav.reload) {
search();
}
}
... ... @@ -446,3 +450,6 @@ $listNav.on('touchstart', 'li', function() {
}).on('touchend touchcancel', function() {
$listNav.find('li').removeClass('bytouch');
});
module.exports = search;
... ...
.banner {
position: relative;
.outlet-activity-time {
position: absolute;
left: 10px;
top: 10px;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 40px;
padding: 0 10px;
display: inline-block;
height: 40px;
line-height: 40px;
.iconfont {
display: inline-block;
margin-right: 5px;
position: relative;
top: -2px;
}
.iconfont,
span {
color: #fff;
font-size: 20px;
}
}
.outlet-discount {
width: 100%;
color: #fff;
background-color: rgba(0, 0, 0, 0.6);
text-align: right;
padding: 3px 60px;
position: absolute;
bottom: 0;
}
}
... ...
@import "nav";
@import "left-right";
@import "activity";
... ...
/**
* 需要格式化的时间格式
*/
'use strict';
const library = '../../../library';
const helpers = require(`${library}/helpers`);
const timeFormat = {
d: '剩{d}天',
h: '剩{h}小时',
m: '剩{m}分钟',
s: '剩{s}秒',
dh: '剩{d}天{h}小时',
dhms: '剩{d}天{h}小时{m}分钟{s}秒',
hms: '剩{h}小时{m}分钟{s}秒',
ms: '剩{m}分钟{s}秒'
};
const anHour = 3600;
const aDay = anHour * 24;
/**
* 折扣专场专题列表过期时间处理
* @param {[string]} time
* @return {[object]}
*/
const processTime = (time) => {
let data = {};
let type = '';
if (time < anHour) {
data.warnColor = true;
data.time = '低于1小时';
} else {
if (time > aDay) {
type = 'dh';
} else {
type = 'h';
}
data.time = helpers.dateDiffFormat(timeFormat[type], time, 's');
}
return data;
};
module.exports = processTime;
... ...