<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>订单提交</title>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="__TMPL__/static/assets/css/weui.min.css" />
    <link rel="stylesheet" type="text/css" href="__TMPL__/static/assets/css/swiper-3.4.2.min.css" />
    <link rel="stylesheet" type="text/css" href="http://at.alicdn.com/t/font_773803_lmxwdl64j4h.css" />
    <script type="text/javascript" src="__TMPL__/static/assets/font/iconfont.js"></script>
    <script type="text/javascript" src="__TMPL__/static/js/base.js"></script>
    <link rel="stylesheet" href="__TMPL__/static/css/orders_submitted.css" />
    <script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <style>
        .weui-picker__group {
            font-size: 0.3rem;
        }
        .people li {
            display: block;
            align-items: center;
            height: 2.04rem;
            padding: 0.36rem 0.31rem 0.1rem 0.32rem;
            border-bottom: 1px solid #F6F6F6;
        }
        .mold {
            display: none;
        }
        .weui-picker__action:first-child {
            text-align: left;
            color: #888;
        }
        .weui-toast {
            line-height: 1rem;
            height: 1rem;
            font-size: 0.3rem;
            position: fixed;
            z-index: 5000;
            width: 3rem;
            min-height: 1em;
            top: 180px;
            left: 50%;
            margin-left: -3.8em;
            background: hsla(0,0%,7%,.7);
            text-align: center;
            border-radius: 5px;
            color: #fff;
        }
        .weui-picker__group {
            font-size: 0.3rem;
        }
        .mold {
            display: none;
        }
        .weui-picker__action:first-child {
            text-align: left;
            color: #888;
        }

        .sss {
            display: none;
        }
        /*.move3 {
            display: none;
        }*/

        .move {
            display: none;
        }

        .move_main {
            animation: move 0.18s;
        }

        @keyframes move {
            0% {
                height: 1rem;
            }
            50% {
                height: 4rem;
            }
            100% {
                height: 4.55rem;
            }
        }

        .move_main3 {
            animation: move 0.18s;
        }

        .mold_out {
            display: none;
        }
        .outtravel .chooseall button{
            right: 0;
            top:0;
        }
        .dai {
            position: absolute;
            top: 0.15rem;
            left: 0.52rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
    </style>
</head>

<body>
<div class="taocan">
    套餐信息
</div>
<div class="information">
    <ul class="jai">
        <li class="mingcheng">
					<span>
						套餐名称
					</span >
            <span class="liang">
						{$data.activity.name}
					</span>
        </li>
        <li class="mingcheng ming pelpe">
            <div class='li_span'>
						<span>
							出行时间
					    </span>
                <span class="liang lian ">
                    <span class="showcang">{$data.choose.time_text}</span>
						</span>
            </div>
            <span>
							<i class="iconfont icon-common-jinru-copy"></i>
					</span>
        </li>
        <li class="mingcheng shuliang" id="shuliang">
					<span>
						购买数量
					</span>
            <div class="suan">
                <span class="reduce" id="del">-</span>
                <span class="val" id="quantity">1</span>
                <span class="add" id="add">+</span>
            </div>
        </li>
        <li class="mingcheng chu">
					<span class="chuxing">
						出行信息
					</span>

        </li>
    </ul>
</div>
<div class="chengke">
    <span>乘客信息</span>
    <div class="xuan">
					<span class="xuanze">
				 	请选则出行人
					 </span>
        <i class="iconfont icon-common-jinru-copy"></i>
    </div>
</div>

<div class="qita">
    其他信息
</div>
<!--优惠-->
<div class="you">
    <div class="chengke1">
        <span class="hui">优惠券</span>
        <div class="xuan3">
					<span class="xuanze1">
				 	请选择
					 </span>
            <i class="iconfont icon-common-jinru-copy"></i>
        </div>
    </div>
    <div class="chengke1">
        <span class="hui">商家备注(10字以内)</span>
        <div class="xuan2">
            <input type="text" placeholder="点击可给商家留言" class="dian_text">
        </div>
    </div>
    <div class="chengke1">
        <span class="hui">单房差(一人一房)</span>
        <div class="xuan1">
					<span class="xuanze2 xuandan">
				 	请选择
					 </span>
            <i class="iconfont icon-common-jinru-copy"></i>
        </div>
    </div>
    <div class="t chengke1">
        <i class="iconfont icon-xuanzhong3"></i>
        <span class="comx">我已同意购买<a href="agreement.html" class="aaa">协议和合同协议</a></span>
    </div>
</div>
<div class="zhezhao">
</div>
<footer>
    <span class="jin">定金:¥<span id="down_price">{$data.down_price}</span></span>
    <span>总价:¥<span id="total">{$data.total}</span></span>
    <!--<a href="orderPay.html">-->
    <input type="button" value="提交订单" class="sub" id="sub" />
    <!--</a>-->
</footer>

<div class='mold'>
    <div class='mold_main'>
				<span class="fon30">
					是否允许绑定手机号码?
				</span>
        <span>
					<span class="fon30" id="no">否</span>
				<span class="fon30 green" id="yes">允许</span>
				</span>
        <span class="fon26">
					注:绑定后可获得¥10代金券一张
				</span>
    </div>
</div>

<div class='move'>
    <div class='move_main'>
        <div class="change">
            <div class="fang">
						<span class="call">
								取消
							</span>
                <span class="single1">
								单人间&nbsp;&nbsp;(一人一房)
							</span>

                <span class="confirm">
									确定
						</span>
            </div>
        </div>
        <div class="required">
            <span class="yes">需要</span>
            <span>不需要</span>
        </div>

    </div>

</div>
<div class='move1'>
    <div class='move_main1'>
        <div class="shang2">
            <div class="shang1">
						<span class="choose">
							选择支付方式
						</span>
            </div>
            <div class="shang1 shan1 shang_list">
                <div class="shang1_inner">
                    <div class="img_out">
                        <img src="__TMPL__/static/images/yue.png" alt="" class="yue" />

                    </div>
                    <div>
                        余额支付
                    </div>
                </div>
                <div>
                    <i class='iconfont icon-xuanzhong2' data-var="0"></i>
                </div>
            </div>
            <div class="shang1 shan1">
                <div class="shang1_inner">
                    <div class="img_out">
                        <img src="__TMPL__/static/images/wei.png" alt="" class="yue" />

                    </div>
                    <div>
                        微信支付
                    </div>
                </div>
                <div>
                    <i class='iconfont' data-var="1"></i>
                </div>
            </div>
            <div class="shang1 shan1">
                <div class="shang1_inner">
                    <div class="img_out">
                        <img src="__TMPL__/static/images/zhi.png" alt="" class="yue" />

                    </div>
                    <div>
                        支付宝支付
                    </div>
                </div>
                <div>
                    <i class='iconfont' data-var="2"></i>
                </div>
            </div>
            <div class="agreepay">
                确认支付
            </div>
        </div>
    </div>
</div>
<div class='mold_out'>
    <div class='mold_center'>
        <div class="scroll_out">
            <div class="scroll">
                <volist name="data.schedule" id="vo">
                    <div class="money" data-id="{$vo.schedule_id}">
                        <div class="year_change">
                            <if condition="$vo['schedule_id'] eq $data['choose']['schedule_id']">
                                <img class="imgNow" src="__TMPL__/static/images/circle1.png"/>
                                <else/>
                                <img src="__TMPL__/static/images/circle.png"/>
                            </if>
                            <span>{$vo.start_time}&nbsp;至&nbsp;{$vo.end_time}</span>
                        </div>
                        <div class="price">¥{$vo.price}</div>
                    </div>
                </volist>
            </div>
            <button class="bottom_button" value="">确定</button>
        </div>

    </div>

</div>

<!--点击输入要绑定的手机号-->
<div class='move3'>
    <div class='move_main3'>
        <span class="tie_phone">输入绑定的手机号:</span>
        <input type="text" class="phone_input" placeholder="请输入手机号" />
        <span class="phone_btn"><span class="agreed">确认</span></span>
    </div>
</div>


<!--选择出行人弹窗-->
<div class="outtravel">
    <div class="chuxing">
        <ul class="people">
            <li class="userInfo">
                <div class="guo">
                    <div class="gli">
                        <!--<div>-->
                        <div class="circle circle_chu">
                            <i class="iconfont icon-duigou "></i>
                        </div>
                        <!--</div>-->
                        <!--<i class="iconfont icon-yuancircle46"></i>-->
                        <div class="xin">
							<span class="guoxin">
							<span class="name">郭新宇</span>&nbsp;&nbsp;&nbsp; &nbsp;136120645435</span>
                            <span>身份证:123543546576868</span>
                        </div>
                    </div>
                    <div class="bian">

                        <div class="bianji">
                            <i class="iconfont icon-bianji"></i>编辑
                        </div>

                        <div class="delete">
                            <i class="iconfont icon-shanchu"></i> 删除
                        </div>
                    </div>
                </div>
            </li>
            <li class="userInfo">
                <div class="guo">
                    <div class="gli">
                        <div class="circle circle_chu">
                            <i class="iconfont icon-duigou"></i>
                        </div>

                        <!--</div>-->
                        <!--<i class="iconfont icon-yuancircle46"></i>-->
                        <div class="xin">
							<span class="guoxin">
							<span class="name">郭新宇</span>&nbsp;&nbsp;&nbsp; &nbsp;136120645435</span>
                            <span>身份证:123543546576868</span>
                        </div>
                    </div>
                    <div class="bian">

                        <div class="bianji">
                            <i class="iconfont icon-bianji"></i>编辑
                        </div>

                        <div class="delete">
                            <i class="iconfont icon-shanchu"></i>删除
                        </div>
                    </div>
                </div>
            </li>
            <li class="userInfo">
                <div class="guo">
                    <div class="gli">
                        <div class="circle circle_chu">
                            <i class="iconfont icon-duigou"></i>
                        </div>

                        <!--</div>-->
                        <!--<i class="iconfont icon-yuancircle46"></i>-->
                        <div class="xin">
							<span class="guoxin">
							<span class="name">郭新宇</span>&nbsp;&nbsp;&nbsp; &nbsp;136120645435</span>
                            <span>身份证:123543546576868</span>
                        </div>
                    </div>
                    <div class="bian">

                        <div class="bianji">
                            <i class="iconfont icon-bianji"></i>编辑
                        </div>

                        <div class="delete">
                            <i class="iconfont icon-shanchu"></i>删除
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div class="quanxuan chooseall">
        <div class="check">
            <div class="circle circle_chu " id="selectAll">

                <i class="iconfont icon-duigou icon1"></i>
            </div>
            <span>全选</span>
        </div>
        <button class="agree">
            确定
        </button>
    </div>
    <div class="tianjia ok ok_xing">
        添加出行人
    </div>
</div>
<!--选择优惠券=============================================-->
<div class="choose_waitquan">
    <!--<div class="out">-->
    <!--<div class="use">-->
    <!--<span id="nouse" class="active" style="color: rgb(254, 10, 1);">待使用</span>-->
    <!--<span id="outdata" style="color: rgb(37, 39, 41);">已过期</span>-->
    <!--<span id="used" style="color: rgb(37, 39, 41);">已使用</span>-->
    <!--</div>-->
    <!--</div>-->
    <!--待使用优惠券-->
    <div class="wai1" id="wai1">
        <!--<div class="wai" data-id="1">-->
        <!--<div class="youhui">-->
        <!--<div class="circle1">-->
        <!--<i class="iconfont icon-duigou"></i>-->
        <!--</div>-->

        <!--<div class="quan">-->
        <!--<img src="__TMPL__/static/images/f2.png" alt="" />-->
        <!--<div class="dai">-->
        <!--<div class="money">¥<span class="money_five">20</span></div>-->
        <!--<div class="date">-->
        <!--<span>代金券</span>-->
        <!--<span class="you">有效期:2018.08.06-2018.08.08</span>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--<div class="wai">-->
        <!--<div>-->
        <!--<div class="youhui">-->
        <!--<div class="circle1">-->
        <!--<i class="iconfont icon-duigou "></i>-->
        <!--</div>-->
        <!--<div class="quan">-->
        <!--<img src="__TMPL__/static/images/f2.png" alt="" />-->
        <!--<div class="dai">-->
        <!--<div class="money">¥<span class="money_five">6</span></div>-->
        <!--<div class="date">-->
        <!--<span>代金券</span>-->
        <!--<span class="you">有效期:2018.08.06-2018.08.08</span>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->

        <!--<div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
    </div>
    <!--已过期代金券-->
    <div id="wai2">
        <div class="wai">
            <div class="youhui">
                <div class="quan">
                    <img src="__TMPL__/static/images/f2.png" alt="" />
                    <div class="dai">
                        <span class="outdate"><img src="__TMPL__/static/images/outdate.png" alt="" /></span>
                        <div class="money">¥5</div>
                        <div class="date">
                            <span>代金券</span>
                            <span class="you">有效期:2018.08.06-2018.08.08</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div>
            <div class="youhui">

                <div class="quan">
                    <img src="__TMPL__/static/images/f2.png" alt="" />
                    <div class="dai">
                        <span class="outdate"><img src="__TMPL__/static/images/outdate.png" alt="" /></span>
                        <div class="money">¥5</div>
                        <div class="date">
                            <span>代金券</span>
                            <span class="you">有效期:2018.08.06-2018.08.08</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--已使用代金券-->
    <div id="wai3">
        <div class="wai">
            <div class="youhui">

                <div class="quan">
                    <img src="__TMPL__/static/images/f2.png" alt="" />
                    <div class="dai">
                        <span class="outdate"><img src="__TMPL__/static/images/use.png" alt="" /></span>
                        <div class="money">¥5</div>
                        <div class="date">
                            <span>代金券</span>
                            <span class="you">有效期:2018.08.06-2018.08.08</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div>
            <div class="youhui">

                <div class="quan">
                    <img src="__TMPL__/static/images/f2.png" alt="" />
                    <div class="dai">
                        <span class="outdate"><img src="__TMPL__/static/images/use.png" alt="" /></span>
                        <div class="money">¥5</div>
                        <div class="date">
                            <span>代金券</span>
                            <span class="you">有效期:2018.08.06-2018.08.08</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="agree3 ok" id="agreeFun3">确定使用</div>
</div>
<!--添加出行人-->
<div class="jia_travel" style='display: none;'>
    <ul class="list">
        <li>
            <span class="real ">真实姓名</span>
            <input class="add name_1 chu" id="name" placeholder="请填写真实姓名"/>
        </li>
        <li>
            <span class="real">性别</span>
            <div class="xuanze_sex">
                <div class="sex se">
                    <img src="__TMPL__/static/images/circle.png" class="yuan yu sexId"><span>男</span>
                </div>

                <div class="sex">
                    <img src="__TMPL__/static/images/circle1.png" class="yuan yu1 sexId"><span>女</span>
                </div>
            </div>

        </li>
        <li>
            <span class="real">手机号</span>
            <input class="add phone chu" id="phone" placeholder="请填写手机号码" />
        </li>
        <li>
            <span class="real">微信号码</span>
            <input class="add chu wei " id="wxNum" placeholder="请填写微信号码"/>
        </li>
        <li>
            <span class="real ">身份证号</span>
            <input class="add confirm chu zfzid" id="sfzNum" placeholder="请填写身份证号"/>
        </li>
    </ul>
    <!--====底部=====-->
    <footer class="foot ok ok_chu" id="foot">
        保存
    </footer>
</div>
<div id="toast" style='display: none;'>
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <!--<i class="weui-icon-success-no-circle weui-icon_toast"></i>-->
        <p class="weui-toast__content">已完成</p>
    </div>
</div>

<script type="text/javascript" src="__TMPL__/static/assets/js/jquery-2.1.0.js"></script>
<script type="text/javascript" src="__TMPL__/static/assets/js/swiper-3.4.2.min.js"></script>
<script type="text/javascript" src="__TMPL__/static/assets/js/weui.js"></script>
<script type="text/javascript" src="__TMPL__/static/assets/js/myweui.js"></script>
<script type="text/javascript" src="__TMPL__/static/index.js"></script>
<script type="text/javascript" src="__TMPL__/static/assets/js/common.js"></script>
<script type='text/javascript' src='__TMPL__/static/assets/js/Augly_Verification.js'></script>
<script type="text/javascript" src="__TMPL__/static/assets/js/sami_until.js"></script>
<script>
    var total;   // 活动总价;
    var down_price;   //  活动定金;

    $('.xuandan').click(function(){
        $('.move').css('display','block');
    })
    var schedule_id = '{$data.choose.schedule_id}';//	上一页选中的批次id
    var activity_id = '{$data.activity.activity_id}';//上一页选中的活动id
    var max = '{$data.choose.allowMaximum}';//购买数量
    var is_first='{$data.is_first}';

    $(function() {
        //获取选择出行人页面的数据
        var name = decodeURI(getQueryString('name')).replace(/,/g, ' ');
        if(!name) {
            $('.xuanze').html('请选择出行人');
        } else {
            $('.xuanze').html(name);
        }

        function getQueryString(name) {
            var reg = new RegExp("(^|&)" +
                name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r) return unescape(r[2]);
            //return null;
            return '请选择出行人';
        }

        $('.money').click(function(event) {
            $(this).find('img').attr("src", "/themes/simpleboot3/static/images/circle1.png");
            $(this).find('img').addClass("imgNow");
            $(this).siblings().find('img').attr("src", "/themes/simpleboot3/static/images/circle.png");
            $(this).siblings().find('img').removeClass("imgNow");
            schedule_id = $(this).attr('data-id');
        });
        //获取选择选择代金券的数据

        var price = decodeURI(getQueryString_money('price')).replace(/,/g);
        if(!price) {
            $('.waitmoney').html('请选择代金券');
        } else {
            $('.waitmoney').html('代金券¥' + price);
        }

        function getQueryString_money(price) {
            var reg = new RegExp("(^|&)" +
                price + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r) return unescape(r[2]);
            return '';
        }

        var mold = $('.mold');
        $('.mold').click(function() {
            $(this).hide();
        })

        $('.mold_main').click(function(e) {
            e.stopPropagation();
        })
        $('.move_main3').click(function(e) {
            e.stopPropagation();
        })
        $('.move3').click(function() {
            $(this).hide();
        })
        //点击增加
        $("#add").click(function() {
            var num =  parseInt($("#quantity").html());
            var aloowMax = parseInt(max);
            if(num >= aloowMax) {
                alert('名额超出');
            }else {
                numAdd();
                $.ajax({
                    url:"{:url('order/Order/confirm')}",
                    data:{
                        activity_id:'{$data.activity.activity_id}',
                        schedule_id:schedule_id,
                        num:$("#quantity").html()
                    },
                    type:"POST",
                    dataType:"JSON",

                    success: function (data) {
                        console.log(data);
                        $("#down_price").html(data.data.down_price);
                        $("#total").html(data.data.total);
                        total = data.data.total;
                        down_price = data.data.down_price;
                    }
                })
            }
        });
        $("#del").click(function() {
            numDec();
            $.ajax({
                url:"{:url('order/Order/confirm')}",
                data:{
                    activity_id:'{$data.activity.activity_id}',
                    schedule_id:schedule_id,
                    num:$("#quantity").html()
                },
                type:"POST",
                dataType:"JSON",

                success: function (data) {
                    $("#down_price").html(data.data.down_price);
                    $("#total").html(data.data.total);
                }
            })
        });





        //我已同意购买协议和合同协议
        $(".danxuan").click(function() {
            if($('.icon-duigou').css('display') == 'none') {
                $('.icon-duigou').css('display', 'block');
            } else {
                $('.icon-duigou').css('display', 'none');
            }
        });
        $('.sub').click(function() {
            if(is_first == 1) {
                $('.mold').css('display', 'block');
            }else {
                $('.move1').css('display', 'block');
            }
        })

        var money_id='';
        $(".agreepay").click(function () {
            $.ajax({
                url:"{:url('order/Order/done')}",
                data:{
                    activity_id:activity_id,
                    schedule_id:schedule_id,
                    num:$("#quantity").html(),
                    escort:escort_id,
                    payment:$(".icon-xuanzhong2").attr('data-var'),
                    discount_coupon_id:money_id,
                    desc:$('.dian_text').val(),
                    room:$('.xuandan').html()
                },
                type:"POST",
                dataType:"JSON",


                success: function (data) {
                    if($(".icon-xuanzhong2").attr('data-var') == 1) {
                        console.log(data);
                        wx.chooseWXPay({
                            timestamp: data.data.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
                            nonceStr: data.data.nonceStr, // 支付签名随机串,不长于 32 位
                            package: data.data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
                            signType: data.data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
                            paySign: data.data.paySign, // 支付签名
                            success: function (res) {
                                window.location.href=data.url;
                            }
                        });
                    }else if($(".icon-xuanzhong2").attr('data-var') == 0) {
                        if(data.code == 20000) {
                            window.location.href=data.url;
                        }
                    }else {

                    }
                }
            })
        })


        $('.dan').click(function() {
            $('.move').css('display', 'block');

        })
        $('#yes').click(function() {
            $('.mold').css('display', 'none');
            if($('.mold').css('display') == 'none') {
                $('.move3').css('display', 'block');
            }
        })
        $('#no').click(function() {
            $('.mold').css('display', 'none');
            if($('.mold').css('display') == 'none') {
                $('.move1').css('display', 'block');
            }
        })

        $('.move_main').click(function(e) {
            e.stopPropagation();
        })
        $('.move_main1').click(function(e) {
            e.stopPropagation();
        })

        $('#sub').click(function() {

        })

        var liangVal = $('.lian2').html();
        var tem = '';
        $('.required span').click(function(e) {

            tem = $(this).html();

            $(this).css('color', 'red');
            $(this).siblings().css('color', '#000');
        });
        $('.call').click(function() {
            $('.lian2').html(liangVal);
        })

        $('.confirm').click(function(e) {
            $('.lian2').html(tem);
            liangVal = tem;
            $('.move').css('display', 'none');

        })
        $('.call').click(function(e) {
            $('.move').css('display', 'none');

        })
        $('.move').click(function(e) {
            $('.move').css('display', 'none');

        })

        //    获取优惠券

        getCards(1,schedule_id);
        /*商品数量+1*/
        function numAdd() {
            money_id = "";
            var num_add = parseInt($("#quantity").html()) + 1;
            $("#quantity").html(num_add);
            getCards(num_add,schedule_id);
        }
        /*商品数量-1*/
        function numDec() {
            money_id = "";
            if($("#quantity").html() <= 1) {
                return false;
            }
            var num_dec = parseInt($("#quantity").html()) - 1;
            $("#quantity").html(num_dec);

            getCards(num_dec,schedule_id);
            $(".xuanze1").html('请选择代金券');
        }
        getpeople(num);
    })

    $('.bottom_button').click(function(){
        var imgId = $(".imgNow");
        schedule_id = imgId.parents(".money").data("id");
        console.log(schedule_id);
        console.log(num);
        getCards(1,schedule_id);
    })
    function getCards(num,id){
        $.ajax({
            url: "/order/Order/confirm",
            type: "post",
            dataType: "json",
            data: {
                activity_id: activity_id,
                schedule_id: id,
                num:num
            },
            success: function (data) {

                console.log(data);
                total = data.data.total;
                down_price = data.data.down_price;
                var html='';
                if(data.data.coupons !=null){
                    for(var i=0;i< data.data.coupons.length;i++){
                        html +='<div class="wai" data-id="'+data.data.coupons[i].discount_coupon_id+'" data-type="'+data.data.activity.type+'">' +
                            '            <div class="youhui">' +
                            '                <div class="circle1" onclick="circles(this)"  >' + '<i class="iconfont icon-duigou "></i>' +
                            '                </div>'+
                            '                <div class="quan">'+
                            '                    <img src="/themes/simpleboot3/static/images/f2.png" alt="">' +
                            '                    <div class="dai">' +
                            '                        <div class="money">¥<span class="money_five">'+data.data.coupons[i].reduce+'</span></div>' +
                            '                        <div class="date">' +
                            '                            <span>代金券</span>' +
                            '                            <span class="you">'+data.data.coupons[i].discount_coupon_name+'</span>' +
                            '                        </div>' +
                            '                    </div>' +
                            '                </div>' +
                            '            </div>' +
                            '        </div>'
                    }
                }else{
                    html +='<div>暂无数据</div>'
                }


                $('.wai1').html('');
                $('.wai1').append(html);


            },
            complete: function (data) {
                // console.log(data)
            }
        })
    }
    //=========================================================================


    //选择出行人
    function getpeople(num){
        $.ajax({
            url: "/escort/Escort/_list",

            type: "post",
            dataType: "json",
            // data: {
            //     activity_id:activity_id,
            //     schedule_id:schedule_id,
            //     num:num
            // },
            success: function (data) {
                var html='';
                if(data.code==20000){
                    for(var i=0;i<data.data.length;i++) {
                        html +='<li class="userInfo" data-id="'+data.data[i].id+'">' +
                            '                <div class="guo">' +
                            '                    <div class="gli">' +
                            '                        <!--<div>-->' +
                            '                        <div class="circle circle_chu"  onclick="circlepeople(this)">' +
                            '                            <i class="iconfont icon-duigou icon1"></i>' +
                            '                        </div>' +
                            '                        <!--</div>-->' +
                            '                        <!--<i class="iconfont icon-yuancircle46"></i>-->' +
                            '                        <div class="xin">' +
                            '<span class="guoxin">' +
                            '<span class="name">'+data.data[i].name+'</span>&nbsp;&nbsp;&nbsp; &nbsp;'+ data.data[i].tel+'</span>' +
                            '                            <span>身份证:'+data.data[i].identity+'</span>' +
                            '                        </div>' +
                            '                    </div>' +
                            '                    <div class="bian">' +
                            '' +
                            '                        <div class="bianji" onclick="bianji(this)">' +
                            '                            <i class="iconfont icon-bianji"></i>编辑' +
                            '                        </div>'+
                            '                        <div class="delete" onclick="deletes(this)">' +
                            '                            <i class="iconfont icon-shanchu"></i> 删除' +
                            '                        </div>' +
                            '                    </div>' +
                            '                </div>' +
                            '            </li>'
                    }
                }else if(data.code==40000){
                    html +='<div class="nodata">暂无数据</div>'
                    $('.nodata').className='nodata';


                }

                $('.people').html('');
                $('.people').append(html);

            },
            complete: function (data) {
                // console.log(data)
            }
        })

    }
    $('.pelpe').click(function() {
        $('.mold_out').css('display', 'block');
    })
    var index = 0;
    var num = 0;
    $('.bottom_button').click(function() {
        money_id = "";
        var inputLength = $('.mold_center').find('img').length;
        for(var i = 0; i < inputLength; i++) {
            if($('.mold_center').find('img').eq(i).attr("src") =="__TMPL__/static/images/circle1.png") {
                num = num + 1;
                index = i;
            }
        }
        if(1 == 1) {
            $('.mold_out').css('display', 'none');
            $("#quantity").html(1);
            $.ajax({
                url:"{:url('order/Order/confirm')}",
                data:{
                    activity_id:'{$data.activity.activity_id}',
                    schedule_id:schedule_id,
                    num:$("#quantity").html()
                },
                type:"POST",
                dataType:"JSON",

                success: function (data) {
                    $(".showcang").html(data.data.choose.time_text);
                    // $(".price").html()-$('xuanze1').

                    $("#down_price").html(data.data.down_price);
                    $("#total").html(data.data.total);
                    max = data.data.choose.allowMaximum;

                }})
        } else {
            $('.showcang').html($('.mold_center').find('span').eq(index).html());
            $('.mold_out').css('display', 'none');
        }

    })
    $('.shan1').click(function() {
        $(this).find('i').attr('class', 'iconfont icon-xuanzhong2');
        $(this).siblings().find('i').attr('class', 'iconfont');
    })
    $('.move1').click(function() {
        $(this).css('display', 'none');
    })
    $('.phone_btn').click(function() {
        $('.move3').css('display', 'none');
    })
    $('.dainji').click(function(){
        $('.dainji').css('display', 'none');
        $('.texteare1').focus();
    })
    //我已同意购买协议和合同协议
    $(" .t .iconfont").click(function() {
        if($(this).attr('class')=='iconfont icon-weixuanzhong1') {
            $(this).attr('class','iconfont icon-xuanzhong3')
        } else {
            $(this).attr('class','iconfont icon-weixuanzhong1')
        }
    });


    //	选择出行人

    // function  deletes(obj){
    //      $(obj).parents('.userInfo').remove();
    //  }
    var num= $('.people li').length;

    var count = 0;
    var circle=$('.people');
    var nameArr = [];

    var numcircle=0;

    var numd=0;

    function  circlepeople(obj){
        var num_xuan=$('.val').html();
        if($(obj).find('.icon-duigou').hasClass("now")){
            --numcircle;
            $(obj).find('.icon-duigou').removeClass("now");
            $(obj).find('.icon-duigou').css('color','rgba(255, 255, 255)');
            $(obj).css('border','0.02rem solid #999');
        }else{
            if(numcircle<num_xuan){
                // toast(1)
                ++numcircle;
                $(obj).find('.icon-duigou').addClass("now");
                $(obj).find('.icon-duigou').css('color','rgb(254, 10, 1)');
                $(obj).css('border','0.02rem solid rgb(254, 10, 1)');
                // console.log(numcircle);
            }else if(numcircle>=num_xuan){
                toast('选择:'+num_xuan +' 人');
            }
        }

        var len=$(".people").find('.icon-duigou.now').length;
        // console.log(len);
        // console.log(num);
        if(num == len) {

            $("#selectAll").css('border','0.02rem solid rgb(254, 10, 1)');
            $("#selectAll").find('.icon-duigou').css('color','rgba(254, 10, 1)');
        }else{
            $("#selectAll").css('border','0.02rem solid rgb(153, 153, 153)');
            $("#selectAll").find('.icon-duigou').css('color','rgb(255, 255, 255)');
        }

    }
    //全选反选
    $("#selectAll").click(function(){
        if( $(this).find('.icon-duigou').css('color')=='rgb(255, 255, 255)'){
            var num_jia=$('.val').html();
            console.log(num_jia);
            if(num_jia<$('.people li').length){
                console.log($('.people li').length);
                toast('选择:'+num_jia +' 人');
            }else{
                $(this).css('border','0.02rem solid rgb(254, 10, 1)');
                $(this).find('.icon-duigou').css('color','rgb(254, 10, 1)');
                circle.find(".circle").css('border','0.02rem solid rgb(254, 10, 1)');
                circle.find(".icon-duigou").css('color','rgb(254, 10, 1)');
            }
        }else{
            $(this).find('.icon-duigou').css('color','rgb(255, 255, 255)');
            $(this).css("border","0.02rem solid #999");
            circle.find(".icon-duigou").css('color','rgb(255, 255, 255)');
            circle.find(".circle").css("border","0.02rem solid #999");
        }
    })

    var arr=[];
    $('.agree').click(function(){
        $('.outtravel').css('display','none');
    })
    $('.xuan').click(function(){
        $('.outtravel').css('display','block');
    })
    var escort = new Array();
    var names='';
    var escort_id = '';
    // 点击确定时,出行人名字添加到数组,回显到订单提交页面;
    $(".agree").click(function () {
        names='';
        escort_id='';
        escort=new Array();
        for (var i = 0; i < $(".userInfo").length; i++ ) {
            if($(".userInfo").eq(i).find(".icon-duigou").hasClass("now")) {
                names+= $(".userInfo").eq(i).find(".name").html()+' ';
                escort.push($(".userInfo").eq(i).data('id'));
                escort_id+=$(".userInfo").eq(i).data('id')+',';
            }
        }
        console.log(escort_id);
        console.log(escort);
        console.log(names);
        if(names!=''){
            $('.xuanze').html(names);
        }else {
            $('.xuanze').html('请选择出行人');
        }
    })

    // 添加出行人
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" +
            name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r != null) return unescape(r[2]);
        //return null;
        return '请选择出行人';
    }
    function add(){
        var arrlist=decodeURI(getQueryString('arrlist')).replace(/,/g ,' ');
        //$("#parentIndustryUL").append(" <li value="+industry.xyIndustryId+">"+industry.industryName+"</li>");
    }
    add();
    // 选择优惠券
    var wai1 = $('#wai1');
    var wai2 = $('#wai2');
    var wai3 = $('#wai3');
    var nouse = $('#nouse');
    var outdata = $('#outdata');
    var used = $('#used');
    $('#nouse').click(function() {
        wai1.css('display', 'block');
        wai2.css('display', 'none');
        wai3.css('display', 'none');
        nouse.css('color', '#FE0A01');
        outdata.css('color', '#252729');
        used.css('color', '#252729');
    })
    $('#outdata').click(function() {
        wai1.css('display', 'none');
        wai2.css('display', 'block');
        wai3.css('display', 'none');
        nouse.css('color', '#252729');
        outdata.css('color', '#FE0A01');
        used.css('color', '#252729');
    })
    $('#used').click(function() {
        wai1.css('display', 'none');
        wai2.css('display', 'none');
        wai3.css('display', 'block');
        nouse.css('color', '#252729');
        outdata.css('color', '#252729');
        used.css('color', '#FE0A01');
    })
    var circle1 = $('.wai1 .youhui .circle1');

    // circle1.click(function(){
    //     if($(this).find('.icon-duigou').css('color') == 'rgb(255, 255, 255)') {
    //         //			alert(1)
    //         $(this).find('.icon-duigou').css('color', 'rgb(254, 10, 1)');
    //         $(this).css('border', '0.02rem solid rgb(254, 10, 1)');
    //         $(this).parents('.wai').siblings().find('.icon-duigou').css('color', 'rgb(255, 255, 255)');
    //         $(this).parents('.wai').siblings().find('.circle1').css('border', '0.02rem solid #999');
    //     } else {
    //         //				alert(2)
    //         $(this).find('.icon-duigou').css('color', 'rgb(255, 255, 255)');
    //         $(this).css('border', '0.02rem solid #999');
    //     }
    // })
    //优惠券选择
    function circles(obj){
        if($(obj).find('.icon-duigou').css('color') == 'rgb(255, 255, 255)'){
            //			选中
            $(obj).find('.icon-duigou').css('color', 'rgb(254, 10, 1)');
            $(obj).css('border', '0.02rem solid rgb(254, 10, 1)');
            $(obj).parents('.wai').siblings().find('.icon-duigou').css('color', 'rgb(255, 255, 255)');
            $(obj).parents('.wai').siblings().find('.circle1').css('border', '0.02rem solid #999');

        } else {
            //				alert(2)
            $(obj).find('.icon-duigou').css('color', 'rgb(255, 255, 255)');
            $(obj).css('border', '0.02rem solid #999');
        }
    }

    $('.xuan3').click(function(){
        $.ajax({
            url:"{:url('order/Order/confirm')}",
            data:{
                activity_id:'{$data.activity.activity_id}',
                schedule_id:schedule_id,
                num:$("#quantity").html()
            },
            type:"POST",
            dataType:"JSON",

            success: function (data) {
                $('.choose_waitquan').css('display','block');
            }
        })
    })
    // // 点击确定时,出行人名字添加到数组,回显到订单提交页面;
    var money_id;
    var activity_type;
    $("#agreeFun3").click(function () {
        var arr = [];
        var money;
        for(var i = 0; i < $(".wai1 .wai").length; i++) {
            if($(".wai1 .wai").eq(i).find('.icon-duigou').css('color') == 'rgb(254, 10, 1)') {
                var price = $(".wai1 .wai").eq(i).find('.money_five').html();
                money_id = $(".wai1 .wai").eq(i).data("id");
                arr.push(price);
                activity_type = $(".wai1 .wai").eq(i).data("type");
                money = $(".wai1 .wai").eq(i).find('.money_five').html();
            }
        }
        $('.choose_waitquan').css('display','none');
        if(arr[0]==undefined){
            $('.xuanze1').html('请选择代金券');
        }else{
            $('.xuanze1').html('¥'+arr[0]+'代金券');
        }
        if(activity_type == 0) {
            console.log(money)
            var totalYh = total - money;
            $("#total").html(totalYh);
            // console.log(totalYh)
        }else if(activity_type == 1) {
            var downYh = down_price - money;
            $("#down_price").html(downYh);
        }
    })


    $('.ok_xing').click(function(){
        $('.jia_travel').css('display','block')
    })

    $('.yu').click(function() {

        if ($(this).attr('src') == '__TMPL__/static/images/circle.png') {

            $(this).attr('src','__TMPL__/static/images/circle1.png')  ;
            $('.yu1').attr('src','__TMPL__/static/images/circle.png')  ;
        } else {
            $(this).attr('src').attr('src','__TMPL__/static/images/circle.png')  ;
            $('.yu1').attr('src').attr('src','__TMPL__/static/images/circle1.png')  ;
        }
    })
    $('.yu1').click(function() {

        if ($(this).attr('src') == '__TMPL__/static/images/circle.png') {

            $(this).attr('src','__TMPL__/static/images/circle1.png')  ;
            $('.yu').attr('src','__TMPL__/static/images/circle.png')  ;
        } else {
            $(this).attr('src').attr('src','__TMPL__/static/images/circle.png')  ;
            $('.yu').attr('src').attr('src','__TMPL__/static/images/circle1.png')  ;
        }
    })

    var liangVal = $('.xuandan').html();
    var tem = '';
    $('.required span').click(function(e) {
        tem = $(this).html();
        $(this).css('color', 'red');
        $(this).siblings().css('color', '#000');

    });
    $('.call').click(function() {
        $('.xuandan').html(liangVal);
    })

    $('.confirm').click(function() {

        $('.xuandan').html(tem);
        console.log($('.xuandan').html(tem))
        liangVal = tem;
        if(tem==''){
            $('.xuandan').html('请选择');
        }
        $('.move').css('display', 'none');


    })
    var id_bianji='';

    function bianji(obj){
        id_bianji = $(obj).parents(".userInfo").data("id");
        // console.log(id_bianji);
        $.ajax({
            url:"/escort/Escort/edit",
            type: "get",
            dataType: "json",
            data: {
                id: id_bianji,
            },
            success: function (data) {
                console.log(data);
                if(data.data.sex == 0) {
                    $(".sex .yu1").attr("src","/themes/simpleboot3/static/images/circle.png");
                    $(".sex .yu").attr("src","/themes/simpleboot3/static/images/circle1.png");
                }else if (data.data.sex == 1) {
                    $(".sex .yu1").attr("src","/themes/simpleboot3/static/images/circle1.png");
                    $(".sex .yu").attr("src","/themes/simpleboot3/static/images/circle.png");
                };
                $("#name").val(data.data.name);
                $("#phone").val(data.data.tel);
                $("#wxNum").val(data.data.wechat);
                $("#sfzNum").val(data.data.identity);

            }
        })
        $('.jia_travel').css('display','block');
    }

    $('.ok_chu').click(function() {


        var sexId;
        if ($(".sex .yu1").attr('src') == '__TMPL__/static/images/circle1.png') {
            sexId = 1;
        } else if ($(".sex .yu").attr('src') == '__TMPL__/static/images/circle1.png'){
            sexId = 0;
        }
        console.log(id_bianji)
        var data = {};
        data.id = id_bianji;
        data.name = $("#name").val();
        data.sex = sexId;
        data.tel = $("#phone").val();
        data.identity = $("#sfzNum").val();
        data.wechat=$("#wxNum").val();
        var adddata={};
        adddata.name = $("#name").val();
        adddata.sex = sexId;
        adddata.tel = $("#phone").val();
        adddata.identity = $("#sfzNum").val();
        adddata.wechat=$("#wxNum").val();

        if(data.name == '') {
            toast('请填入您的姓名');
        }else if(data.tel == '') {
            toast('请输入电话号码');
        }else if(!AuglyTest_phone.test(data.tel)) {
            toast('电话号码格式不正确');
        }else if( data.wechat == '') {
            toast('请输入微信号码');
        }else if(data.identity == '') {
            toast('请输入身份证号');
        }else if(!AuglyTest_ID.test( data.identity)) {
            toast('身份证号输入不正确');
        }else{
            if(id_bianji !=''){
                console.log('bianji');
                $.ajax({
                    url:"/escort/Escort/edit",
                    type:"post",
                    data:data,
                    dataType:"JSON",
                    success:function(data){
                        console.log(data);
                        toast("保存成功");
                        getpeople(num);
                        id_bianji='';
                        $('.jia_travel').css('display','none');
                        $("#name").val('');
                        $("#phone").val('');
                        $("#wxNum").val('');
                        $("#sfzNum").val('');
                    }
                })
            }else{
                console.log('add');
                $.ajax({
                    url:"/escort/Escort/add",
                    type:"post",
                    data:adddata,
                    dataType:"JSON",
                    success:function(data){
                        console.log(data);
                        toast("保存成功");
                        getpeople(num);
                        id_bianji='';
                        $('.jia_travel').css('display','none');
                    }
                })
            }
        }


    })

    function deletes(obj){
        console.log(1);
        id_bianji = $(obj).parents(".userInfo").data("id");
        $.ajax({
            url:"/escort/Escort/del",
            type:"post",
            data:{
                id: id_bianji,
            },
            dataType:"JSON",
            success:function(data){
                // console.log(data);
                if(data.code == 20000){
                    $(obj).parents('.userInfo').remove();
                }
                getpeople(num);
                toast('删除成功');
                $('.jia_travel').css('display','none');
            }
        })
    }
    //================================================================

    $('.agreed').click(function () {

        $.ajax({
            url:"{:url('portal/Index/bindMobile')}",
            data:{
                tel:$('.phone_input').val()
            },
            type:"POST",
            dataType:"JSON",
            success: function () {
                is_first=0;

            }
        })
    })
</script>

<script>
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
        appId: '{$js_sdk.appId}', // 必填,公众号的唯一标识
        timestamp: '{$js_sdk.timestamp}', // 必填,生成签名的时间戳
        nonceStr: '{$js_sdk.nonceStr}', // 必填,生成签名的随机串
        signature: '{$js_sdk.signature}',// 必填,签名
        jsApiList: [
            'chooseWXPay'
        ] // 必填,需要使用的JS接口列表
    });

</script>


</body>

</html>