<!--{include file="<!--{$tplpath}-->top.tpl"}-->
<!-------------------------------------- 头部结束 -------------------------------------->
<style>
	.site-category{display: none;}
</style>
<!-------------------------------------- 主体开始 -------------------------------------->

		<div class="site-header site-mini-header">

			<div class="container">

				<div class="header-logo" style="width: auto;">

					<a class="" href="<!--{$urlpath}-->" title=""><img src="<!--{$config.logo}-->"  ></a>

				</div>

				<div class="header-title has-more" id="J_miniHeaderTitle">

					<h2>确认订单</h2>

				</div>

			</div>

		</div>
<div class="page-main">
	<div class="container">
		<div class="checkout-box">
            <!--{if empty(<!--{$addressinfo}-->)}-->
            <input type="hidden" id="addressid" value=""/>
			<div class="section section-address" style="text-align: center;">
                	<a href='javascript:;' name='cha' style='background:red;color: white;display: block;width: 120px;text-align: center;line-height: 40px;margin-top: 10px;border-radius: 4px;'>新增地址</a>
			</div>
            <!--{else}-->

			<div class="section section-address">
				<div class="section-header clearfix">
                    <h3 class="title">收货地址</h3>
                	<div class="more"></div>
		        </div>
		        <div class="section-body clearfix" id="J_addressList">
            <p style="padding:0px 40px;">
                       <!--{if $addressinfo.is_mo == '1'}-->
                   <span class="glyphicon glyphicon-ok"  aria-hidden="true"></span>
                       <!--{/if}-->
                <input type="hidden" id="addressid" value="<!--{$addressinfo.id}-->"/>
		        	<!--{$addressinfo.name}-->
		        	<!--{$addressinfo.phone}-->
		        	<!--{$addressinfo.province}--><!--{$addressinfo.city}--><!--{$addressinfo.county}--><!--{$addressinfo.address}-->
                     <a href="javascript:;" name="edit" data-id="<!--{$addressinfo.id}-->" class="btn btn-primary btn-sm" style='color: white;border-radius: 4px;' >修改</a>
                     <a href="javascript:;" data-id="<!--{$addressinfo.id}-->" class="btn btn-danger btn-sm" name="del" style='color:red;border-radius: 4px;'>删除</a>
            </p>
		        </div>
			</div>

        	<!--{/if}-->
			<div class="section section-options section-payment clearfix">
				<div class="section-header">
					<h3 class="title">支付方式</h3>
				</div>
				<div class="section-body clearfix">
					<ul class="J_optionList options ">
						<li data-type="pay" class="J_option selected" data-value="1">
							在线支付
							<span>（支持支付宝）</span>
						</li>
					</ul>
				</div>
			</div>
			<div class="section section-options section-shipment clearfix" style="display:none;">
				<div class="section-header">
					<h3 class="title">配送方式</h3>
				</div>
				<div class="section-body clearfix">
					<ul class="clearfix J_optionList options ">
						<li data-type="shipment" class="J_option selected">
							快递配送（免运费） </li>
					</ul>

					<div style="display: none;" class="service-self-tip" id="J_serviceSelfTip"></div>
				</div>
			</div>
			<div class="section section-options section-time clearfix" style="display:none;">
				<div class="section-header">
					<h3 class="title">配送时间</h3>
				</div>
				<div class="section-body clearfix">
					<ul class="J_optionList options options-list clearfix sendTime" id="sendTime">
						<!-- besttime start -->
						<li class="J_option " sendtime="1" style="border-color: rgb(255, 103, 0); color: rgb(255, 103, 0);">
							不限送货时间：周一至周日
						</li>
						<li class="J_option selected" sendtime="2" style="border-color: rgb(224, 224, 224); color: rgb(51, 51, 51);">
							工作日送货：周一至周五
						</li>
						<li class="J_option " sendtime="3" style="border-color: rgb(224, 224, 224); color: rgb(51, 51, 51);">
							双休日、假日送货：周六至周日
						</li>
						<!-- besttime end -->
					</ul>
					<input type="hidden" name="sendtime" id="" value="3">
				</div>
			</div>
			<div class="section section-goods">
				<div class="section-body">
			<!--{foreach $data as $volist}-->
					<ul class="goods-list" id="J_goodsList">
						<li class="clearfix">
							<div class="col col-img">
								<img height="30" width="30" src="<!--{$volist.uploadfiles}-->">
							</div>
							<div class="col col-name">
								<a>
									<!--{$volist.productname}-->
								</a>
							</div>
							<div class="col col-price">
								<!--{$volist.bprice}--> x <!--{$volist.productnum}-->
							</div>
							<div class="col col-status">
							<!--{if !empty($volist.productnum)}-->有货<!--{else}-->无货<!--{/if}-->
							</div>
							<div class="col col-total">
								<!--{if !empty($volist.subtotal)}--><!--{$volist.subtotal}--><!--{else}--><!--{$volist.bprice}--><!--{/if}-->
							</div>
						</li>
					</ul>
			<!--{/foreach}-->
				</div>
			</div>
			<div class="section section-count clearfix">
				<div class="money-box" id="J_moneyBox">
					<ul>
						<li class="clearfix">
							<label>金额合计：</label>
							<span class="val"><!--{$djtotal}-->元</span>
						</li>
						<li class="clearfix total-price">
							<label>应付总额：</label>
							<span class="val"><em id="J_totalPrice"><!--{$djtotal}--></em>元</span>
						</li>
						<li class="clearfix">
							<label></label>
							<span class="val"></span>
						</li>
						<li class="clearfix">
							<label></label>
							<span class="val"><i id="J_couponVal"></i></span>
						</li>
					</ul>
				</div>
			</div>
			<div class="section-bar clearfix">
				<div class="fl">
					<div class="seleced-address hide" id="J_confirmAddress">
					</div>
					<div class="big-pro-tip hide J_confirmBigProTip"></div>
				</div>
				<div class="fr">
				<!--{if !empty($check)}-->
					<a href="javascript:;" id="J_checkoutToPay" class="btn btn-lg btn-primary white p-x-30 cart-order">立即下单</a>
				<!--{else}-->
        <a class="btn btn-primary" href="./index.php?c=user&a=login">登录</a>
				<!--{/if}-->
				</div>
			</div>
		</div>
	</div>
</div>
<script>
    // 下单         
       $(".cart-order").bind("click", function(){ //提交
      
           var addressid=$("#addressid").val();
           if(addressid == ''){
               layer.msg('请先填写地址信息');
               return false;
           }
            $.ajax({
                type: "POST",
                url: "index.php?c=user&a=submitorder",
                cache: false,
                data: {addressid:addressid},
                dataType: "json",
                success: function(data) {
                   var json = eval(data);
                   var response = json.response;
                   var result = json.result; 
                   if(response=='1'){
                        layer.msg('订单生成中', {icon: 16,shade:0.01,time: 2000}, function () {
                            layer.msg('下单成功,请付款');
                          window.location.href='index.php?c=user&a=order_detail&order_number='+json.ordallnumbr;
                        //    $("#addorder").css("display", "none");
                         //   $("#pay").css("display", "");
                          //  $("[name=ordernum]").html(json.ordernum);
                           // $("[name=price]").html(json.orderprice);
                           // $("[name=gounum]").html(json.num);
                        });     
                        return false;
                        pay(json.ordallnumbr,json.ordallname,json.ordalltotal);
                       // window.location.reload();
                   }else{
                       layer.msg(result, function(){});  
                   }
                }	
            });

        });

      function pay(omb,gdsnm,ototal){
          var url='./source/plugin/alipay/alipayapi.php';
          var order_number=omb;
          var order_name=gdsnm;
          var oeder_price=ototal;
          var parames = new Array();
          parames.push({ name: "WIDout_trade_no", value: order_number});
          parames.push({ name: "WIDsubject", value: order_name});
          parames.push({ name: "WIDtotal_fee", value: oeder_price});
          parames.push({ name: "WIDbody", value: order_name});


          Post(url, parames);     

          return false;
      }
            /*
         *功能： 模拟form表单的提交
         *参数： URL 跳转地址 PARAMTERS 参数
         */
       function Post(url, parames) {
            //创建form表单
             var temp_form = document.createElement("form");
             temp_form.action = url;
             //如需打开新窗口，form的target属性要设置为'_blank'
         //   temp_form.target = "_blank";
             temp_form.method = "post";
            temp_form.style.display = "none";
             //添加参数
             for (var item in parames) {
                var opt = document.createElement("input");
                 opt.name = parames[item].name;
                 opt.value = parames[item].value;
                 temp_form.appendChild(opt);
             }
            document.body.appendChild(temp_form);

             //提交数据
             temp_form.submit();
         }
</script>


<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">添加地址</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="companyinfoedit">
          <input type="hidden" name='id' value=''/>
          <div class="form-group">
            <label for="name" class="col-sm-2 control-label">姓名：</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="name" placeholder="姓名" name="name">
            </div>
          </div>
          <div class="form-group">
            <label for="phone" class="col-sm-2 control-label">电话：</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="phone" placeholder="电话" name="phone">
            </div>
          </div>
          <div class="form-group">
            <label   class="col-sm-2 control-label">地址：</label>
            <div class="col-sm-10">
              
                <select onchange="get_city(this);" id="province" name="provinceid"  class="form-control" style="width:33.3%; float: left;">
                 <option value="">选择省份</option>
                <!--{foreach $province as $volist}-->                
                     <option value="<!--{$volist.id}-->"  <!--{if $volist.name == <!--{$data.province}-->}-->selected<!--{/if}--> ><!--{$volist.name}--></option>                                                                     
                 <!--{/foreach}-->                                                                      
               </select>
                <select onchange="get_area(this)" id="city" name="cityid" class="form-control" style="width:33.3%; float: left;">
                 <option value="">请选择市</option>
                <!--{foreach $city as $volist}-->                
                     <option value="<!--{$volist.id}-->" <!--{if $volist.name == <!--{$data.city}-->}-->selected<!--{/if}--> ><!--{$volist.name}--></option>                                                                     
                 <!--{/foreach}-->   
               </select>
                 <select id="district" name="countyid" title="请选择所在区县" class="form-control"  style="width:33.3%; float: left;">
                 <option value="">请选择县/区</option>
                  <!--{foreach $area as $volist}-->                
                     <option value="<!--{$volist.id}-->" <!--{if $volist.name == <!--{$data.county}-->}-->selected<!--{/if}--> ><!--{$volist.name}--></option>                                                                     
                 <!--{/foreach}-->   
               </select>

            </div>
          </div>
          <div class="form-group">
            <label for="address" class="col-sm-2 control-label">地址详情：</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="address" placeholder="地址详情" name="address" value="<!--{$data.address}-->">
            </div>
          </div>
          <div class="form-group">
            <label for="zcode" class="col-sm-2 control-label">邮编：</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="zcode" placeholder="邮编" name="zcode">
            </div>
          </div>
          <div class="form-group">
            <label for="is_mo" class="col-sm-2 control-label">是否默认：</label>
            <div class="col-sm-10">
              <input type="checkbox" class="form-control" id="is_mo" name="is_mo" <!--{if $data.is_mo =='1'}-->checked<!--{/if}--> >
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <a type="button" class="btn btn-primary" onclick="update();">保存</a>
      </div>
    </div>
  </div>
</div>


<!--{include file="<!--{$tplpath}-->botton.tpl"}-->