jQuery实现影院选座订座效果


Posted in jQuery onApril 13, 2021

jQuery实现影院选座订座效果,供大家参考,具体内容如下

效果如下:

jQuery实现影院选座订座效果

jQuery实现影院选座订座效果

代码如下:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width; initial-scale=1.0">
    <title>jQuery影院选座订座效果代码</title>
    <meta name="keywords" content="jQuery,选座">

    <style type="text/css">
        .demo {
            width: 700px;
            margin: 40px auto 0 auto;
            min-height: 450px;
        }
        
        @media screen and (max-width: 360px) {
            .demo {
                width: 340px
            }
        }
        
        .front {
            width: 300px;
            margin: 5px 32px 45px 32px;
            background-color: #f0f0f0;
            color: #666;
            text-align: center;
            padding: 3px;
            border-radius: 5px;
        }
        
        .booking-details {
            float: right;
            position: relative;
            width: 200px;
            height: 450px;
        }
        
        .booking-details h3 {
            margin: 5px 5px 0 0;
            font-size: 16px;
        }
        
        .booking-details p {
            line-height: 26px;
            font-size: 16px;
            color: #999
        }
        
        .booking-details p span {
            color: #666
        }
        
        div.seatCharts-cell {
            color: #182C4E;
            height: 25px;
            width: 25px;
            line-height: 25px;
            margin: 3px;
            float: left;
            text-align: center;
            outline: none;
            font-size: 13px;
        }
        
        div.seatCharts-seat {
            color: #fff;
            cursor: pointer;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
        }
        
        div.seatCharts-row {
            height: 35px;
        }
        
        div.seatCharts-seat.available {
            background-color: #B9DEA0;
        }
        
        div.seatCharts-seat.focused {
            background-color: #76B474;
            border: none;
        }
        
        div.seatCharts-seat.selected {
            background-color: #E6CAC4;
        }
        
        div.seatCharts-seat.unavailable {
            background-color: #472B34;
            cursor: not-allowed;
        }
        
        div.seatCharts-container {
            border-right: 1px dotted #adadad;
            width: 400px;
            padding: 20px;
            float: left;
        }
        
        div.seatCharts-legend {
            padding-left: 0px;
            position: absolute;
            bottom: 16px;
        }
        
        ul.seatCharts-legendList {
            padding-left: 0px;
        }
        
        .seatCharts-legendItem {
            float: left;
            width: 90px;
            margin-top: 10px;
            line-height: 2;
        }
        
        span.seatCharts-legendDescription {
            margin-left: 5px;
            line-height: 30px;
        }
        
        .checkout-button {
            display: block;
            width: 80px;
            height: 24px;
            line-height: 20px;
            margin: 10px auto;
            border: 1px solid #999;
            font-size: 14px;
            cursor: pointer
        }
        
        #selected-seats {
            max-height: 150px;
            overflow-y: auto;
            overflow-x: none;
            width: 200px;
        }
        
        #selected-seats li {
            float: left;
            width: 72px;
            height: 26px;
            line-height: 26px;
            border: 1px solid #d3d3d3;
            background: #f7f7f7;
            margin: 6px;
            font-size: 14px;
            font-weight: bold;
            text-align: center
        }
    </style>

</head>

<body>


    <div id="main">

        <div class="demo">
            <div id="seat-map">
                <div class="front">屏幕</div>
            </div>
            <div class="booking-details">
                <p>影片:<span>星际穿越</span></p>
                <p>时间:<span>11月14日 21:00</span></p>
                <p>座位:</p>
                <ul id="selected-seats"></ul>
                <p>票数:<span id="counter">0</span></p>
                <p>总计:<b>¥<span id="total">0</span></b></p>

                <button class="checkout-button">确定购买</button>

                <div id="legend"></div>
            </div>
            <div style="clear:both"></div>
        </div>

        <br />
    </div>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.12.1.min.js"></script>
    <script type="text/javascript" src="jquery.seat-charts.min.js"></script>
    <script type="text/javascript">
        var price = 70; /*票价*/
        $(document).ready(function() {
            var $cart = $('#selected-seats'),
                /*座位区*/
                $counter = $('#counter'),
                /*票数*/
                $total = $('#total'); /*总计金额*/

            var sc = $('#seat-map').seatCharts({
                map: [ /*座位图*/
                    'aaaaaaaaaa',
                    'aaaaaaaaaa',
                    '__________',
                    'aaaaaaaa__',
                    'aaaaaaaaaa',
                    'aaaaaaaaaa',
                    'aaaaaaaaaa',
                    'aaaaaaaaaa',
                    'aaaaaaaaaa',
                    'aa__aa__aa'
                ],
                naming: {
                    top: false,
                    getLabel: function(character, row, column) {
                        return column;
                    }
                },
                legend: { /*定义图例*/
                    node: $('#legend'),
                    items: [
                        ['a', 'available', '可选座'],
                        ['a', 'unavailable', '已售出']
                    ]
                },
                click: function() { /*点击事件*/
                    if (this.status() == 'available') { /*可选座*/
                        $('<li>' + (this.settings.row + 1) + '排' + this.settings.label + '座</li>')
                            .attr('id', 'cart-item-' + this.settings.id)
                            .data('seatId', this.settings.id)
                            .appendTo($cart);

                        $counter.text(sc.find('selected').length + 1);
                        $total.text(recalculateTotal(sc) + price);

                        return 'selected';
                    } else if (this.status() == 'selected') { /*已选中*/
                        /*更新数量*/
                        $counter.text(sc.find('selected').length - 1);
                        /*更新总计*/
                        $total.text(recalculateTotal(sc) - price);

                        /*删除已预订座位*/
                        $('#cart-item-' + this.settings.id).remove();
                        /*可选座*/
                        return 'available';
                    } else if (this.status() == 'unavailable') { /*已售出*/
                        return 'unavailable';
                    } else {
                        return this.style();
                    }
                }
            });
            /*已售出的座位*/
            sc.get(['1_2', '4_4', '4_5', '6_6', '6_7', '8_5', '8_6', '8_7', '8_8', '10_1', '10_2']).status('unavailable');

        });
        /*计算总金额*/
        function recalculateTotal(sc) {
            var total = 0;
            sc.find('selected').each(function() {
                total += price;
            });

            return total;
        }
   
</body>

</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

jQuery 相关文章推荐
jQuery返回定位插件详解
May 15 jQuery
JQueryMiniUI按照时间进行查询的实现方法
Jun 07 jQuery
bootstrap可编辑下拉框jquery.editable-select
Oct 12 jQuery
jQuery实现导航样式布局操作示例【可自定义样式布局】
Jul 24 jQuery
jQuery使用each遍历循环的方法
Sep 19 jQuery
jQuery实现点击旋转,再点击恢复初始状态动画效果示例
Dec 11 jQuery
jQuery实现提交表单时不提交隐藏div中input的方法
Oct 08 jQuery
Jquery让form表单异步提交代码实现
Nov 14 jQuery
jQuery实现验证用户登录
Dec 10 jQuery
jQuery操作事件完整实例分析
Jan 10 jQuery
jQuery实现获取多选框的值示例
Feb 07 jQuery
jQuery插件实现图片轮播效果
Oct 19 jQuery
jQuery class属性操作addClass()与removeClass()、hasClass()、toggleClass()
jQuery treeview树形结构应用
Mar 24 #jQuery
jQuery实现鼠标拖动图片功能
Mar 04 #jQuery
ajax jquery实现页面某一个div的刷新效果
Mar 04 #jQuery
jquery实现广告上下滚动效果
Mar 04 #jQuery
html5以及jQuery实现本地图片上传前的预览代码实例讲解
Mar 01 #jQuery
jQuery是用来干什么的 jquery其实就是一个js框架
Feb 04 #jQuery
You might like
php 删除cookie和浏览器重定向
2009/03/16 PHP
php获取YouTube视频信息的方法
2015/02/11 PHP
PHP入门教程之数学运算技巧总结
2016/09/11 PHP
PHP实现图片压缩
2020/09/09 PHP
laravel利用中间件防止未登录用户直接访问后台的方法
2019/09/30 PHP
javascript让setInteval里的函数参数中的this指向特定的对象
2010/01/31 Javascript
jquery跟js初始化加载的多种方法及区别介绍
2014/04/02 Javascript
avalon js实现仿google plus图片多张拖动排序附源码下载
2015/09/24 Javascript
静态页面实现 include 引入公用代码的示例
2017/09/25 Javascript
基于node下的http小爬虫的示例代码
2018/01/11 Javascript
原生JS+HTML5实现的可调节写字板功能示例
2018/08/30 Javascript
在webstorm开发微信小程序之使用阿里自定义字体图标的方法
2018/11/15 Javascript
微信小程序解除10个请求并发限制
2018/12/18 Javascript
js实现蒙版效果
2020/01/11 Javascript
VUE实时监听元素距离顶部高度的操作
2020/07/29 Javascript
python 采集中文乱码问题的完美解决方法
2016/09/27 Python
Python实现将文本生成二维码的方法示例
2017/07/18 Python
Python排序搜索基本算法之归并排序实例分析
2017/12/08 Python
Python解析命令行读取参数--argparse模块使用方法
2018/01/23 Python
有关Python的22个编程技巧
2018/08/29 Python
删除DataFrame中值全为NaN或者包含有NaN的列或行方法
2018/11/06 Python
Python实现繁?转为简体的方法示例
2018/12/18 Python
python实现将文件夹内的每张图片批量分割成多张
2019/07/22 Python
win7下 python3.6 安装opencv 和 opencv-contrib-python解决 cv2.xfeatures2d.SIFT_create() 的问题
2019/10/24 Python
基于Django统计博客文章阅读量
2019/10/29 Python
Python使用微信接入图灵机器人过程解析
2019/11/04 Python
PyQt5 界面显示无响应的实现
2020/03/26 Python
在pycharm中debug 实时查看数据操作(交互式)
2020/06/09 Python
Html5页面在微信端的分享的实现方法
2018/08/30 HTML / CSS
什么是符号链接,什么是硬链接?符号链接与硬链接的区别是什么?
2013/05/03 面试题
小学生开学第一课活动方案
2014/03/27 职场文书
竞聘演讲稿开场白
2014/08/25 职场文书
2014年四风个人对照检查及整改措施
2014/10/28 职场文书
2014年科普工作总结
2014/12/06 职场文书
创业计划书之农家乐
2019/10/09 职场文书
python实现Nao机器人的单目测距
2021/09/04 Python