Authored by zzzzzzz

sale新增倒计时

... ... @@ -5,8 +5,14 @@
<img src="" alt="sale-banner" class="sale-floor-banner" />
</a>
<a href="" class="float-container">
<a href="" class="float-container time-floor">
<img src="" alt="sale-limit" class="sale-floor-limit">
<div class="sale-floor-time">
<p class="limit-title"><i class="icon"></i>限时特卖</p>
<span class="hour">00</span>:
<span class="minute">00</span>:
<span class="second">00</span>
</div>
</a>
<a href="" class="float-container">
... ...
... ... @@ -315,7 +315,6 @@ $.ajax({
channel: 1,
},
success: function(data) {
console.log(data);
var vip = $('.vip-only');
if (data.code === 200 && Number(data.current_vip_level) !== 0) {
vip.show();
... ... @@ -327,4 +326,28 @@ $.ajax({
searching = false;
}
});
// sale倒计时
var saleTime = function(elem, offsetTime) {
var hour = parseInt(offsetTime % (60 * 60 * 24) / (60 * 60), 10),
minute = parseInt(offsetTime % (60 * 60) / 60, 10),
second = offsetTime % 60;
if (offsetTime >= -1) {
$(elem).find('.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
$(elem).find('.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
$(elem).find('.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second));
if (offsetTime <= -1) { // 结束倒计时刷新状态
console.log('time done!');
} else {
setTimeout(function() {
saleTime(elem, --offsetTime);
}, 1000);
}
}
}
saleTime('.sale-floor-time', 10);
require('./maybe-like')();
\ No newline at end of file
... ...
... ... @@ -13,6 +13,48 @@
&-limit {
height: 360px;
width: 269px;
background: black;
}
a.time-floor {
position: relative;
}
&-time {
position: absolute;
top: 25px;
left: 49%;
margin-left: -69px;
color: #fff;
font-size: 28px;
.icon {
display: inline-block;
height: 26px;
width: 26px;
background: resolve("channel/sale-time.png");
background-size: 100% 100%;
vertical-align: text-bottom;
margin-right: 8px;
}
.limit-title {
font-size: 24px;
color: #fff;
margin-bottom: 18px;
}
span {
display: inline-block;
height: 35px;
width: 35px;
background: #fff;
border-radius: 2px;
color: #444;
line-height: 35px;
text-align: center;
margin-right: 7px;
}
}
&-break {
... ...