...
|
...
|
@@ -2,18 +2,10 @@ |
|
|
|
|
|
let $ = require('yoho-jquery');
|
|
|
|
|
|
// tip = require('plugin/tip');
|
|
|
|
|
|
let $activityTime = $('.activity-time'),
|
|
|
endTime = $activityTime ? $activityTime.data('time-s') : '';
|
|
|
let $news = $('.news'),
|
|
|
newsLiL = $news.find('li').length;
|
|
|
|
|
|
let params = {
|
|
|
anHour: 3600, // 1小时=?秒
|
|
|
aMinute: 60, // 1分钟=?秒
|
|
|
aSecond: 1, // 1秒=?秒
|
|
|
timeDom: $activityTime, // 时间对象数组
|
|
|
endTime: [endTime] // 时间差数组
|
|
|
};
|
|
|
// tip = require('plugin/tip');
|
|
|
|
|
|
require('activity/share-buy.page.css');
|
|
|
|
...
|
...
|
@@ -21,89 +13,22 @@ if ($('.share-buy-page').height() < $(window).height()) { |
|
|
$('.share-buy-page').height($(window).height());
|
|
|
}
|
|
|
|
|
|
function division(time) {
|
|
|
time = time > 10 ? time + '' : '0' + time;
|
|
|
|
|
|
let timeArr = time.split('');
|
|
|
|
|
|
return timeArr;
|
|
|
}
|
|
|
|
|
|
// 倒计时
|
|
|
function getRTime(conf) {
|
|
|
let d = 0,
|
|
|
h = 0,
|
|
|
m = 0,
|
|
|
s = 0;
|
|
|
|
|
|
conf.timeDom.each(function(key, item) {
|
|
|
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;
|
|
|
// }
|
|
|
|
|
|
// console.log(m, division(m));
|
|
|
|
|
|
$(item).find('span').eq(0).html(division(d)[0]);
|
|
|
$(item).find('span').eq(1).html(division(d)[1]);
|
|
|
$(item).find('span').eq(2).html(division(h)[0]);
|
|
|
$(item).find('span').eq(3).html(division(h)[1]);
|
|
|
$(item).find('span').eq(4).html(division(m)[0]);
|
|
|
$(item).find('span').eq(5).html(division(m)[1]);
|
|
|
$(item).find('span').eq(6).html(division(s)[0]);
|
|
|
$(item).find('span').eq(7).html(division(s)[1]);
|
|
|
|
|
|
$(item).fadeIn();
|
|
|
} else {
|
|
|
$(item).hide();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function Marquee() {
|
|
|
let diff,
|
|
|
newsHeight = $news.find('li:first').height() * newsLiL;
|
|
|
|
|
|
function startCountDown(p) {
|
|
|
$.extend(params, p || {});
|
|
|
setInterval(function() {
|
|
|
getRTime(params);
|
|
|
}, 1000);
|
|
|
}
|
|
|
$news.scrollTop($news.scrollTop() + 1);
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/sale/discount/getTime',
|
|
|
data: {
|
|
|
id: 3919
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data) {
|
|
|
diff = newsHeight - $news.scrollTop();
|
|
|
|
|
|
startCountDown({
|
|
|
endTime: [data]
|
|
|
});
|
|
|
}
|
|
|
if (diff <= 0) {
|
|
|
$news.scrollTop(Math.abs(diff));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function Marquee() {
|
|
|
$('.news').animate({
|
|
|
marginTop: '-' + $('.news').find('li:first').height() + 'px'
|
|
|
}, 1000, function() {
|
|
|
$(this).css({ marginTop: '0px' }).find('li:first').appendTo(this);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if ($('.news').find('li').length > 1) {
|
|
|
if (newsLiL > 1) {
|
|
|
|
|
|
$news.append('<li>' + $news.find('li:first').html() + '</li>');
|
|
|
|
|
|
setInterval(Marquee, 2000);
|
|
|
setInterval(Marquee, 100);
|
|
|
} |
...
|
...
|
|