0

0

JavaScript高仿支付宝倒计时页面及代码实现

高洛峰

高洛峰

发布时间:2016-12-09 14:10:16

|

1976人浏览过

|

来源于php中文网

原创

实现目标

一,页面在图一时开始进行倒计时(可以点击取消订单按钮,支付页面消失)。

二,倒计时完毕,出现删除订单。

三,单击删除订单,弹出弹框,询问是否要真正删除订单。

四,单击确定,即可删除订单。

立即学习Java免费学习笔记(深入)”;

201611011003251.png

201611011003251.png

201611011003251.png

CG Faces
CG Faces

免费的 AI 人物图像素材网站

下载

201611011003251.png

如上图所示效果展示,这里给出所有的源代码(如需运行,只需要修改EJS文件中引入的CSS路径和JS路径即可).
这个页面其实是自己业余时间,写的东西。 

但是里面涉及到,倒计时,弹框,以及字体图(可以参照“如何制作字体图”章节)的相关知识。

这里分享出来,希望大家能从中学到自己想要的知识。 

代码很丑,但是基本效果都已经实现。

JS代码

order_detail.js
/**
* Created by mayouchen on 2016/10/20.
*/
$(function () { //加载完DOM的只执行函数 
var intDiff = parseInt(60); //倒计时总秒数量
function timer(intDiff) {
window.setInterval(function () {
var day = 0,
hour = 0,
minute = 0,
second = 0;//时间默认值
if (intDiff > 0) {
//计算相关的天,小时,还有分钟,以及秒
day = Math.floor(intDiff / (60 * 60 * 24)); 
hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
$('#day_show').html(day + "天");
$('#hour_show').html('' + hour + '时');
$('#minute_show').html('' + minute + '分');
$('#second_show').html('' + second + '秒');
intDiff--;
}, 1000);
//循环函数,是时钟运动起来
setInterval(function(){
if($('#minute_show').text() =='00分' && $('#second_show').text() =='00秒'){
$('.pay-immediately-count').remove();
$('.cancle-order').remove();
$('.del-order').show();
clearInterval();
}
},1000)
//下面三个是跳转链接,本来是在node工程里面的路由配置的,这里大家可以换成自己的链接
$("#dingdan").click(function () {
location.href = "/hotel/order"; //这里跳转的是路由的路径
});
$("#mengdian").click(function () {
location.href = "/hotel"; //这里跳转的是路由的路径
});
$(".set-detail").click(function () {
location.href = "/hotel/detail"; //这里跳转的是路由的路径
});
//这里都是一些单击事件
/* 点击删除按钮*/
$('.del-order').click(function(){
$(".arrow_mask").show();
$(".cancel-order-dialog").show()
})
/* 弹框的设置---取消键*/
$(".cancle-order-btn").click(function(){
$(".cancel-order-dialog").hide();
$(".arrow_mask").hide();
});
/* 弹框的设置---确定键*/
$(".certain-order").click(function(){
$(".section-first").remove();
$(".cancel-order-dialog").remove();
$(".arrow_mask").remove();
$(".footer").css({"position":"fixed"});
});
/* 弹框的设置---取消键*/
$(".cancle-order").click(function(){
$(".section-first").remove();
$(".footer").css({"position":"fixed"});
});
}
//执行上面的函数
$(function () {
timer(intDiff);
});
});
HTML页面
order_detail.html











 
 




 


  • 订房状态
    2015-6-26
    11:14:17
  • 订单号:
    A23456623
  • 订单总额:
    ¥98
  • 订单状态:
    处理中
  • 支付状态:
    线上支付
    未支付
  • 立即支付
    还剩 0分 0秒
    取消订单
    删除订单
入住信息
  • 入住时间:
    6月25日-6月26日
    共1晚
  • 房间类型:
    标准间
    1间
  • 预订人:
    马优晨
    1500070188
  • 特殊要求:
    房间整洁干净
酒店信息
你确定要取消该订单吗?
取消
确定
CSS代码 order_detail.css body{ background: #eeeeee; } .date-head{ width:100%; } .date-head-statue{ width:100%; font-size:14px; border-radius:4px; padding-left:15px; padding-right:15px; } .date-head-state{ background: #fff; height: 240px; border-radius: 10px; margin-top: 16px; padding-top: 14px; position: relative; } /*.set-detail-number a{ color: #333333; }*/ /*.section-body .set-text-button .set-text-button a{ color: #1c94f7; }*/ .reservation-status,.order-number,.total-order,.order-status,.payment-status,.pay-immediately,.pay-immediately-count{ display: -moz-box; -moz-box-orient: horizontal; display: -webkit-box; -webkit-box-orient: horizontal; } .order-number,.total-order,.order-status,.payment-status{ margin-top: 10px; } .pay-immediately{ position: absolute; bottom: 0px; width: 100%; /* margin-top: 16px; */ } .space-underline { border-bottom: 1px solid #999999; -webkit-border-image: url(../../images/hotel/border.gif) 1 stretch; /*margin-top: 12px;*/ -webkit-transform:scaleY(0.2); -moz-transform:scaleY(0.2); -o-transform:scaleY(0.2); } .reservation-status div:nth-of-type(2){ position: absolute; right: 0px; margin-right: 90px; color: #999999; } .reservation-status div:nth-of-type(3){ position: absolute; right: 0px; margin-right: 26px; color: #999999; } .order-number div:nth-of-type(2),.total-order div:nth-of-type(2),.order-status div:nth-of-type(2),.payment-status div:nth-of-type(2) { position: absolute; left: 0px; margin-left: 130px; } .reservation-status,.order-number ,.total-order ,.order-status,.payment-status{ /*position: absolute; left: 0px; margin-left: 130px;*/ padding-left: 12px; } .payment-status div:nth-of-type(3) { position: absolute; left: 0px; margin-left: 200px; color: #1c94f7; } .cancel-order{ width: 100%; } .pay-immediately div:nth-of-type(1){ width: 70%; background: #1c94f7; height: 40px; line-height: 40px; text-align: center; border-radius: 0px 0px 0px 10px; color: #ffffff; paddingleft: 20p; padding-left: 20px; white-space: nowrap; } .pay-immediately div:nth-of-type(2){ width: 30%; height: 40px; background: #097bd9; boder-radus: 5px; /* border-radius: 5px; */ line-height: 40px; text-align: center; border-radius: 0px 0px 10px 0px; color: #ffffff; } .wide-space_line { height: 30px; width: 100%; background: #eeeeee; text-align: center; } .wide-space_line div:nth-of-type(1) { margin-top: 7px; position: absolute; left: 0px; margin-left: 16px; font-size: 15px; color: #999999; } .total-order div:nth-of-type(2){ color:#ff5e38; font-size: 16px; font-weight: bold; } .order-status div:nth-of-type(2){ color: #1c94f7; } .check-in-time,.room-type,.booking-person,.special-requirements{ display: -moz-box; -moz-box-orient: horizontal; display: -webkit-box; -webkit-box-orient: horizontal; margin-left: 16px; } .check-in-time div:nth-of-type(1),.room-type div:nth-of-type(1),.booking-person div:nth-of-type(1),.special-requirements div:nth-of-type(1){ color: #999999; } .check-in-time div:nth-of-type(2),.room-type div:nth-of-type(2),.booking-person div:nth-of-type(2),.special-requirements div:nth-of-type(2){ color: #333; position: absolute; left: 0px; margin-left: 98px; } /*.check-in-time div:nth-of-type(3),.room-type div:nth-of-type(3),.booking-person div:nth-of-type(3){ color: #333; position: absolute; left: 0px; margin-left: 60px; }*/ .check-in-time div:nth-of-type(3){ color: #333; position: absolute; left: 0px; margin-left: 222px; } .room-type div:nth-of-type(3){ color: #333; position: absolute; left: 0px; margin-left: 152px; } .booking-person div:nth-of-type(3){ color: #333; position: absolute; left: 0px; margin-left: 152px; } .check-information{ background: #ffffff; height: 128px; } .check-in-time{ padding-top: 10px; margin-top: 10px; } .room-type,.booking-person,.special-requirements{ padding-top: 10px; } /*中间列表样式**************************************************************************/ .section-body .set-detail,.section-body .set-detail-number,.section-body .set-detail-address{ display: -moz-box; -moz-box-orient: horizontal; display: -webkit-box; -webkit-box-orient: horizontal; margin-left: 10px; } .set-detail,.set-detail-number{ padding-top: 13px; padding-bottom: 13px; text-align: center; /* border-bottom: 1px solid #999999; -webkit-border-image: url(../../images/hotel/border.gif) 1 stretch;*/ } .set-detail-address{ padding-top: 10px; padding-bottom: 10px; text-align: center; } @font-face{ font-family:"font-name-icon"; src:url("../../fonts/icomoon.ttf") format("truetype"), url("../../fonts/icomoon.eot?#iefix") format("embedded-opentype"), url("../../fonts/icomoon.woff") format("woff"), url("../../fonts/icomoon.svg") format("svg"); font-weight:normal; font-style:normal; } .font-name-icon{ font-family: "font-name-icon"; font-weight: normal; font-style: normal; font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .first-icon{ color: #999999; } .second-icon{ margin-left: 5px; } .set-text-button{ position: absolute; right: 0px; margin-right: 24px; font-size: 14px; color: #1c94f7; } .greater-number { position: absolute; right: 0; margin-right: 10px; margin-top: 4px; display: inline-block; width: 8px; height: 8px; border-top: 1px solid #999; border-right: 1px solid #999; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -o-transform: rotate(45deg); } .greater-number-bottom{ position: absolute; right: 0; margin-right: 10px; margin-top: 7px; display: inline-block; width: 4px; height: 8px; border-top: 1px solid #999; border-right: 1px solid #999; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -o-transform: rotate(45deg); } .set-detail,.set-detail-number{ padding-top: 13px; padding-bottom: 13px; text-align: center; /* border-bottom: 1px solid #999999; -webkit-border-image: url(../../images/hotel/border.gif) 1 stretch;*/ } .set-text-detail{ margin-left: 10px; font-size: 13px; } .set-text-detail2 .aa{ margin-left: 15px; font-size: 13px; color: #333333; } .set-detail-address{ padding-top: 10px; padding-bottom: 10px; text-align: center; } .set-text-shut{ white-space: nowrap; text-overflow: ellipsis; overflow: hidden; width: 221px; } .set-text-button{ position: absolute; right: 0px; margin-right: 24px; font-size: 14px; color: #1c94f7; } .set-text-button .bb{ color: #1c94f7; } .space_line{ height: 10px; width: 100%; background: #eeeeee; } .section-body{ background: #ffffff; } /*底部按钮样式**************************************************************************/ .footer{ display: -moz-box; -moz-box-orient: horizontal; display: -webkit-box; -webkit-box-orient: horizontal; } .greater-number-bottom{ position: absolute; right: 0; margin-right: 10px; margin-top: 6px; display: inline-block; width: 8px; height: 8px; border-top: 1px solid #999; border-right: 1px solid #999; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -o-transform: rotate(45deg); } .ellipse{ width: 26px; height: 18px; display: block; border-radius: 8px; background: #1c94f7; color: #ffffff; position: absolute; right: 0px; margin-right: 18px; margin-top: -17px; padding-right: 6px; font-size: 10px; text-align: center; line-height: 18px; } .footer{ display: -moz-box; -moz-box-orient: horizontal; display: -webkit-box; -webkit-box-orient: horizontal; position: relative; bottom: 0px; width: 100%; height: 40px; /* background: #fff; */ margin-top: 50px; /* padding-top: 50px; */ } .footer div:nth-of-type(1){ padding-top: 11px; width: 50%; border-right: 1px solid #eeeeee; background-color: white; text-align: center; } .footer div:nth-of-type(2){ padding-top: 12px; width: 50%; padding-left: 28px; background-color: white; } .footer span{ padding-left: 5px; } .pay-immediately div:nth-of-type(3){ display: none; } /*倒计时样式**************************************************************************/ .time-item { background: #C71C60; color: #fff; line-height: 40px; font-size: 14px; font-family: Arial; padding: 0 10px; border-radius: 5px; } #day_show { float:left; line-height:40px; color:#ffffff; font-size:14px; margin:0 10px; font-family:Arial,Helvetica,sans-serif; } .item-title .unit { background:none; line-height:40px; font-size:14px; padding:0 10px; float:left; } .pay-immediately-count-num{ display: -moz-box; -moz-box-orient: horizontal; display: -webkit-box; -webkit-box-orient: horizontal; } .del-order{ display: none; text-align: center; background: #999999; height: 40px; border-radius: 0px 0px 10px 10px; position: absolute; bottom: 0px; width: 100%; color: #fff; line-height: 40px; } //取消按钮弹出的对话框 .arrow_mask { position: absolute; top: 0; left: 0; bottom: 0; right: 0; z-index: 1; background: #333333; opacity: 0.55; display: none; } .cancel-order-dialog{ display: none; width: 260px; height: 206px; background: #fff; border-radius: 6px; position: absolute; top: 0px; margin-top: 200px; left: 50%; margin-left: -130px; z-index: 1; padding-top: 33px; } .cancel-dialog div:nth-of-type(1){ text-align: center; /* border-right: 1px solid #999; padding: 10px; border-top: 1px solid #999;*/ } .cancel-dialog-btn{ display: -moz-box; -moz-box-orient: horizontal; display: -webkit-box; -webkit-box-orient: horizontal; /* margin-top: -8px;*/ } .cancel-dialog-btn div:nth-of-type(1){ width: 130px; border-right: 1px solid #999; padding: 10px; border-top: 1px solid #999; } .cancel-dialog-btn div:nth-of-type(2){ width: 130px; text-align: center; padding: 10px; border-top: 1px solid #999; } .space-underline2 { margin-top: 116px; } .space-underline3 { width: 100%; height: 10px; -webkit-border-image: url(../../images/hotel/border.gif) 1 stretch; -webkit-transform: scaleX(0.2); -moz-transform: scaleX(0.2); } reset.css @charset "utf-8"; *{margin:0;padding:0;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);-webkit-box-sizing: border-box;-moz-box-sizing: border-box;} html { min-height: 100%; font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } body { width: 100%; min-height: 100%; font-family:"Microsoft YaHei","微软雅黑","MicrosoftJhengHei","华文细黑","Helvetica", "Arial", "sans-serif"; font-size: 14px; position: relative; word-break:break-all; } a { text-decoration: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.35); -webkit-box-sizing:border-box; } img { -ms-interpolation-mode: bicubic; vertical-align: middle; } img:not([src*="/"]) { display: none; } table { border-collapse: collapse; border-spacing: 0; } textarea { resize: none; } input, button, select, textarea { -webkit-appearance:none; outline: none; border-radius: 0; } input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none !important; margin: 0; } ul,ol,li { list-style: none; -webkit-margin-before: 0; -webkit-margin-after: 0; -webkit-margin-start: 0; -webkit-margin-end: 0; -webkit-padding-start: 0; } .section-body .text { margin-top: 24px; margin-left: 40px; margin-right: 35px; width: 84%; font-family: "宋体"; font-size: 18px; } .section-body .textImg{ margin-top: 45px; color: blue; text-align: center; vertical-align: middle; }

相关文章

支付宝
支付宝

支付宝,全球领先的独立第三方支付平台,致力于为广大用户提供安全快速的电子支付/网上支付服务,有需要的小伙伴快来保存下载体验吧!

下载

相关标签:

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
Python Web 框架 Django 深度开发
Python Web 框架 Django 深度开发

本专题系统讲解 Python Django 框架的核心功能与进阶开发技巧,包括 Django 项目结构、数据库模型与迁移、视图与模板渲染、表单与认证管理、RESTful API 开发、Django 中间件与缓存优化、部署与性能调优。通过实战案例,帮助学习者掌握 使用 Django 快速构建功能全面的 Web 应用与全栈开发能力。

0

2026.02.04

Java 流式处理与 Apache Kafka 实战
Java 流式处理与 Apache Kafka 实战

本专题专注讲解 Java 在流式数据处理与消息队列系统中的应用,系统讲解 Apache Kafka 的基础概念、生产者与消费者模型、Kafka Streams 与 KSQL 流式处理框架、实时数据分析与监控,结合实际业务场景,帮助开发者构建 高吞吐量、低延迟的实时数据流管道,实现高效的数据流转与处理。

0

2026.02.04

Golang 容器化与 Docker 实战
Golang 容器化与 Docker 实战

本专题深入讲解 Golang 应用的容器化与 Docker 部署,涵盖 Docker 基础概念、容器构建与镜像管理、Go 应用的 Dockerfile 编写、跨平台容器部署与优化、Docker Compose 和 Kubernetes 部署工具。通过实际案例,帮助学习者掌握 如何将 Golang 应用容器化并实现高效部署与管理,提升系统的可扩展性与运维效率。

1

2026.02.04

全国统一发票查询平台入口合集
全国统一发票查询平台入口合集

本专题整合了全国统一发票查询入口地址合集,阅读专题下面的文章了解更多详细入口。

37

2026.02.03

短剧入口地址汇总
短剧入口地址汇总

本专题整合了短剧app推荐平台,阅读专题下面的文章了解更多详细入口。

104

2026.02.03

植物大战僵尸版本入口地址汇总
植物大战僵尸版本入口地址汇总

本专题整合了植物大战僵尸版本入口地址汇总,前往文章中寻找想要的答案。

49

2026.02.03

c语言中/相关合集
c语言中/相关合集

本专题整合了c语言中/的用法、含义解释。阅读专题下面的文章了解更多详细内容。

9

2026.02.03

漫蛙漫画网页版入口与正版在线阅读 漫蛙MANWA官网访问专题
漫蛙漫画网页版入口与正版在线阅读 漫蛙MANWA官网访问专题

本专题围绕漫蛙漫画(Manwa / Manwa2)官网网页版入口进行整理,涵盖漫蛙漫画官方主页访问方式、网页版在线阅读入口、台版正版漫画浏览说明及基础使用指引,帮助用户快速进入漫蛙漫画官网,稳定在线阅读正版漫画内容,避免误入非官方页面。

76

2026.02.03

Yandex官网入口与俄罗斯搜索引擎访问指南 Yandex中文登录与网页版入口
Yandex官网入口与俄罗斯搜索引擎访问指南 Yandex中文登录与网页版入口

本专题汇总了俄罗斯知名搜索引擎 Yandex 的官网入口、免登录访问地址、中文登录方法与网页版使用指南,帮助用户稳定访问 Yandex 官网,并提供一站式入口汇总。无论是登录入口还是在线搜索,用户都能快速获取最新稳定的访问链接与使用指南。

456

2026.02.03

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
React 教程
React 教程

共58课时 | 4.6万人学习

TypeScript 教程
TypeScript 教程

共19课时 | 2.7万人学习

Bootstrap 5教程
Bootstrap 5教程

共46课时 | 3.2万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号