Authored by 王水玲

sale outlet 倒计时ajax获取

... ... @@ -56,6 +56,13 @@ exports.activityDetail = (req, res, next) => {
}).catch(next);
};
// 奥莱活动倒计时时间
exports.activityTime = (req, res, next) => {
outletModel.getActivityTime(req.query).then(times => {
res.json(times);
}).catch(next);
};
// 奥莱活动频道列表页
exports.activityList = (req, res, next) => {
let headerData = headerModel.setNav({
... ...
... ... @@ -139,6 +139,14 @@ let discountDetail = (req, res, next) => {
}).catch(next);
};
let getTime = (req, res, next) => {
let id = req.query.id;
saleModel.getDiscountTime(id, req.yoho.channel).then((time) => {
res.json(time);
}).catch(next);
};
/**
* vip 会员专享
* @param {[object]} req
... ... @@ -222,5 +230,6 @@ module.exports = {
discountDetail,
vip,
filter,
search
search,
getTime
};
... ...
... ... @@ -123,6 +123,7 @@ const _convertActicityData = (data) => {
discountText = 0;
data = data || [];
_.forEach(data, (item) => {
if (item.promotionName) {
discountArr = item.promotionName.split('~');
... ... @@ -254,8 +255,29 @@ const getRecentActivity = (type, categoryId) => {
});
};
// pageCache 单独获取活动时间
const getActivityTime = (params) => {
return api.get('', _.assign({
method: 'app.outlets.activityGet',
platform: 3 // h5平台代号
}, params)).then(res => {
var times = [];
if (res && res.code === 200) {
_.forEach(res.data, item => {
times.push(item.startLeftTime > 0 ? dateFormate(item.startTime) : item.endLeftTime);
});
return times;
} else {
log.error('the response code of "app.outlets.activityGet" is NOT 200', res);
return {};
}
});
};
module.exports = {
getContent: getContent,
getActivity: getActivity,
getRecentActivity: getRecentActivity
getRecentActivity: getRecentActivity,
getActivityTime: getActivityTime
};
... ...
... ... @@ -383,8 +383,9 @@ const getDiscountDetailData = (id, yhChannel) => {
title: res[0] && res[0].title,
productPool: res[0] && res[0].productPool,
activity: {
coverUrl: res[0] && res[0].coverUrl,
leftTime: res[0] && res[0].leftTime
coverUrl: res[0] && res[0].coverUrl
// leftTime: res[0] && res[0].leftTime
}
};
} else {
... ... @@ -394,6 +395,22 @@ const getDiscountDetailData = (id, yhChannel) => {
});
};
const getDiscountTime = (id, yhChannel) => {
let param = {
id: id,
yh_channel: channelType[yhChannel] || '1'
};
return _discount(param).then((result) => {
if (result && result.code === 200) {
return result.data[0].left_time;
} else {
logger.error('get discount time code no 200');
return {};
}
});
};
module.exports = {
getSaleData,
getBreakCodeData,
... ... @@ -402,5 +419,6 @@ module.exports = {
getVipData,
getFilterData,
getSearchData,
saleNav
saleNav,
getDiscountTime
};
... ...
... ... @@ -63,12 +63,14 @@ router.get('/sale/discount', sale.discount);
router.get('/sale/discount/detail', sale.discountDetail);
router.get('/sale/breakingYards', sale.breakingYards);
router.get('/sale/vip', sale.vip);
router.get('/sale/discount/getTime', sale.getTime);
router.get('/sale/search', sale.search);
router.get('/sale/filter', sale.filter);
router.get('/outlet', outlet.index);
router.get('/outlet/activity', outlet.activityDetail);
router.get('/outlet/activityTime', outlet.activityTime);
router.get('/outlet/activityinfo', outlet.activityList);
... ...
... ... @@ -7,7 +7,7 @@
{{# activity}}
<img src="{{image coverUrl 640 200}}"/>
<p class="activity-time" data-time-s="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p>
<p class="activity-time" data-time-s=""><i class="iconfont time-ico">&#xe603;</i><span></span></p>
{{/ activity}}
</div>
... ...
... ... @@ -4,6 +4,7 @@
* @date: 2016/5/20
*/
var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
lazyLoad = require('yoho-jquery-lazyload');
var countDown = require('../plugin/countdown'),
... ... @@ -13,4 +14,24 @@ search.start();
lazyLoad($('img.lazy'));
countDown();
$.ajax({
type: 'GET',
url: '/product/sale/discount/getTime',
data: {
id: window.queryString.id
},
success: function(data) {
if (data) {
// $('.activity-time').attr('data-time-s', data);
countDown({
endTime: [data]
});
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
... ...
var $ = require('yoho-jquery'),
Countdown = require('./outlet/countdown');
// Countdown = require('./outlet/countdown'),
ajaxActivityTime = require('./outlet/ajaxActivityTime');
var search = require('./sale/search');
var el = $('.cd-lite');
// var el = $('.cd-lite');
search.start();
new Countdown.Countdown({
el: el
ajaxActivityTime({
sort: 1, // 接口规定传1
id: window.queryString.id,
type: 0 // 接口规定传0
});
// new Countdown.Countdown({
// el: el
// });
$('.back-ground-white').css('padding', '0');
... ...
... ... @@ -2,27 +2,26 @@
* Created by runner on 16/6/14.
*/
var $ = require('yoho-jquery'),
Countdown = require('./outlet/countdown'),
iscroll = require('./outlet/nav');
iscroll = require('./outlet/nav'),
ajaxActivityTime = require('./outlet/ajaxActivityTime');
var $el = $('.cd-lite');
var $el = $('.cd-lite'),
$indexNav = $('#index_nav');
require('../common');
require('./outlet/set-backurl');
if ($el.length > 0) {
$el.each(function() {
new Countdown.Countdown({
el: $(this)
});
ajaxActivityTime({
type: window.queryString.type || 2
});
}
// 导航滚动
if ($('#index_nav').length > 0) {
if ($indexNav.length > 0) {
iscroll({
el: '#index_nav'
}).goto($('#index_nav').find('.active').index());
}).goto($indexNav.find('.active').index());
}
if ($('.back-ground-white').length < 1) {
... ...
... ... @@ -5,23 +5,46 @@ var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
iscroll = require('./outlet/nav');
var $bgw = $('.back-ground-white'),
$indexNav = $('#index_nav');
require('../common');
require('./outlet/set-backurl');
// 导航滚动
if ($('#index_nav').length > 0) {
if ($indexNav.length > 0) {
iscroll({
el: '#index_nav'
}).goto($('#index_nav').find('.active').index());
}).goto($indexNav.find('.active').index());
}
if ($('.back-ground-white').length < 1) {
if ($bgw.length < 1) {
$('.empty').show();
}
$('.back-ground-white').on('click', function() {
$bgw.on('click', function() {
tip.show('活动即将开始,敬请期待!');
return false;
});
$('.cd-medium').show();
$.ajax({
type: 'GET',
url: '/product/outlet/activityTime',
data: {
type: window.queryString.type || 3
},
success: function(data) {
var $cdMedium = $('.cd-medium');
if (data) {
$cdMedium.each(function(key, item) {
$(item).html(data[key]);
});
$cdMedium.show();
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
... ...
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload'),
Countdown = require('./outlet/countdown');
ajaxActivityTime = require('./outlet/ajaxActivityTime');
var $el = $('.cd-lite');
var $categoryNavItem = $('.outlet-category-nav a');
... ... @@ -39,10 +39,9 @@ function searchInitParam(dom) {
}
if ($el.length > 0) {
$el.each(function() {
new Countdown.Countdown({
el: $(this)
});
ajaxActivityTime({
type: 0, // 获取全部奥莱活动列表, 不区分是否将开始或结束
yh_channel: window.queryString.yh_channel
});
}
... ...
/**
* 获取奥莱活动时间
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/10/10
*/
var $ = require('yoho-jquery'),
Countdown = require('../outlet/countdown'),
tip = require('../../plugin/tip');
var $el = $('.cd-lite');
module.exports = function(params) {
$.ajax({
type: 'GET',
url: '/product/outlet/activityTime',
data: params,
success: function(data) {
if (data) {
$el.each(function(key, item) {
$(item).attr('data-config', '{"leftTime": ' + data[key] + ' }');
new Countdown.Countdown({
el: $(item)
});
});
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
};
... ...