jQuery每日秒杀商品倒计时

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u014789708/article/details/94574499

html & js:

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>jQuery每日秒杀倒计时</title>
<link rel="stylesheet" href="css/zzsc.css">
</head>
<body>
<div class="se-kl">
	<div class="se-cn">倒计时</div>
	<div class="se-en">COUNT DOWN</div>
	<i class="se-io"></i>
	<div class="se-info">距离结束还剩</div>
	<div class="se-count">
		<div class="se-day"></div>
		<div class="se-hour"><span class="se-txt">00</span></div>
		<div class="se-min"><span class="se-txt">00</span></div>
		<div class="se-sec"><span class="se-txt">00</span></div>
	</div>
</div>
<script src="js/jquery.min.js"></script>  <!-- 依赖条件1 -->
<script type="text/javascript">
	$(document).ready(function () {
		var oDate = new Date();
		var nowTime = oDate.getTime(); //现在的毫秒数
		oDate.setDate(oDate.getDate() + 1); // 设定截止时间为第二天
		var targetDate = new Date(oDate.toLocaleDateString());
		run(targetDate);
	});

	function run(enddate) {
		getDate(enddate);
		setInterval("getDate('" + enddate + "')", 500);
	}

	function getDate(enddate) {
		var oDate = new Date(); //获取日期对象

		var nowTime = oDate.getTime(); //现在的毫秒数
		var enddate = new Date(enddate);
		var targetTime = enddate.getTime(); // 截止时间的毫秒数
		var second = Math.floor((targetTime - nowTime) / 1000); //截止时间距离现在的秒数

		var day = Math.floor(second / 24 * 60 * 60); //整数部分代表的是天;一天有24*60*60=86400秒 ;
		second = second % 86400; //余数代表剩下的秒数;
		var hour = Math.floor(second / 3600); //整数部分代表小时;
		second %= 3600; //余数代表 剩下的秒数;
		var minute = Math.floor(second / 60);
		second %= 60;
		var spanH = $('.se-txt')[0];
		var spanM = $('.se-txt')[1];
		var spanS = $('.se-txt')[2];

		spanH.innerHTML = tow(hour);
		spanM.innerHTML = tow(minute);
		spanS.innerHTML = tow(second);
	}

	function tow(n) {
		return n >= 0 && n < 10 ? '0' + n : '' + n;
	}
</script>
</body>
</html>

css:

(zzsc.cs)

* {
    margin: 0;
    padding: 0;
}

.se-kl {
    width: 190px;
    height: 275px;
    background-color: #e83632;
    margin: 100px auto;
    position: relative;
}

.se-cn {
    position: absolute;
    top: 42px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 34px;
    color: #fff;
}

.se-en {
    position: absolute;
    top: 90px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 20px;
    color: rgba(255, 255, 255, 0.5);
}

.se-io {
    width: 20px;
    height: 33px;
    position: absolute;
    background: url(../imgs/seckill.png) no-repeat;
    background-position: -32.5px 0;
    background-size: 52.5px 40px;
    left: 85px;
    top: 126px;
    display: block;
}

.se-info {
    position: absolute;
    top: 170px;
    text-align: center;
    width: 100%;
    font-size: 16px;
    color: #fff;
}

.se-count {
    position: absolute;
    top: 212px;
    left: 30px;
    height: 40px;
}

.se-day {
    display: none;
}

.se-hour,
.se-min,
.se-sec {
    position: relative;
    background-color: #2f3430;
    width: 40px;
    height: 40px;
    float: left;
    text-align: center;
    line-height: 40px;
    margin-right: 5px;
}

.se-txt {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
}

.se-txt:before {
    content: "";
    display: block;
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #e83632;
}

示例图1:

注:本程序依赖于jquery库,请自行下载并选择合适路径或使用远程cdn地址:https://cdn.bootcss.com/jquery/3.4.1/jquery.js

展开阅读全文

商品秒杀实战

07-03

<p>n <span style="font-size:18px;">本课程是一门具有很强实践性质的“项目实战”课程,俗称“</span><span style="font-size:18px;">Java</span><span style="font-size:18px;">商城秒杀系统”,主要介绍了当前一些电商平台或者商城在举办一些商品秒杀、抢购活动时所涉及的相关业务流程,其中,主要包括“秒杀活动列表的展示”、“秒杀活动详情的获取”、“用户登录认证服务”、“高并发秒杀</span><span style="font-size:18px;">-</span><span style="font-size:18px;">抢购业务”、“秒杀成功订单的生成”以及“邮件通知服务”等等,如下图所示:</span>n</p>n<p>n <span style="font-size:18px;"><img src="https://img-bss.csdn.net/201907030743388775.png" alt="" /><br /></span>n</p>n<p>n <span style="font-size:18px;"><br /></span>n</p>n<p>n <span style="font-size:18px;">n </span></p><p>n 其中,该“秒杀系统”所对应的整体业务流程图如下图所示:<span></span>n </p>n<img src="https://img-bss.csdn.net/201907030744225540.png" alt="" /><br />nn<p>n <span style="font-size:18px;"><br /></span>n</p>n<p>n <span style="font-size:18px;"><br /></span>n</p>n<p>n <span style="font-size:18px;">n </span></p><p>n 从该整体业务流程图中可以看出,该秒杀系统业务的梳理<span>debug</span>自认为还是比较清楚的。而值得一提的是,本“秒杀系统”涉及的相关技术栈还是比较新颖、主流的,特别是在如今微服务、分布式系统架构横行的时代,本系统涉及的相关技术栈还是很值得各位小伙伴学习的!如下图所示:<span></span>n </p>nnn<p>n <span style="font-size:18px;"><img src="https://img-bss.csdn.net/201907030745139190.png" alt="" /><br /></span>n</p>n<p>n <span style="font-size:18px;"><br /></span>n</p>n<p>n <span style="font-size:18px;">n </span></p><p>n 除此之外,由于本课程属于“项目实战”性质的课程,故而学完本课程后,其整体的收益相对于“单一技术栈”的学习收益将会更多!如下图所示:<span></span>n </p>n<img src="https://img-bss.csdn.net/201907030745435683.png" alt="" /><br />nn<p>n <br /></p>

没有更多推荐了,返回首页