{extend name="$LAYOUT_HOME_BASE" /}
{block name="title"}确认订单 - {:WSTConf('CONF.mallName')}{__block__}{/block}
{block name="meta"}
<meta name="description" content="{:WSTConf('CONF.seointegralDesc')}">
<meta name="Keywords" content="{:WSTConf('CONF.seointegralKeywords')}">
{/block}
{block name="css"}
<link href="__ROOT__/addons/integral/view/home/index/css/carts.css?v={$v}" rel="stylesheet">
{/block}
{block name="nav"}
  {php}$Title = "确认订单";$prompt="";{/php}
  {include file="../../../wstshop/home/view/default/header2" /}
{/block}
{block name="main"}
<div class="wst-cart-container">
<div class="wst-container">
<div class="settlement-box">
    <input type='hidden' class='j-ipt' id='s_addressId' value='{if isset($userAddress["addressId"]) }{$userAddress["addressId"]}{/if}'/>
    <input type='hidden' class='j-ipt' id='s_areaId' value='{if isset($userAddress["addressId"]) }{$userAddress["areaId2"]}{/if}'/>
    <!-- 用户地址 -->
    <div class='address-box'>
       <div class='box-head'>收货地址</div>
       <!-- 选中地址 -->
       <div class='j-show-box'>
        <div class="wst-user-addr j-selected">
        <div id="addressList"></div>
    <script id="address" type="text/html">
        {{# for(var i = 0, len = d.length; i < len; i++){ }}
    <div class="list {{# if(d[i].isDefault==1) { }}default{{# } }} {{# if(i>2) { }}address-hide hide{{# } }}" id="list_{{ d[i].addressId }}" onclick="javascript:changeAddrId({{ d[i].addressId }})">
      <div class="infos">
        <p class="name">{{d[i].userName}}</p>
        <p class="phone">{{d[i].userPhone}}</p>
        <p class="address">{{d[i].areaName}}<br/>{{d[i].userAddress}}</p>
      </div>
      <div class="operate">
        <a href="javascript:void(0);" onclick="javascript:toEditAddress({{ d[i].addressId }},this,1,1,1)">修改</a>
        <a href="javascript:void(0);" onclick="javascript:delAddr({{ d[i].addressId }})">删除</a>
      </div>
    </div>
         {{# } }}
         </script>
      <div class="list add" onclick="javascript:emptyAddress(this,1)"><i class="iconfont"></i>添加新地址</div>
          <div class='wst-clear'></div>
       <div id="address-more" class="more hide" onclick="javascript:moreAddr();"><span id="more1">显示更多收货地址<i class="iconfont"></i></span><span id="more2" class="hide">收起更多收货地址<i class="iconfont"></i></span></div>
        </div>
       </div>
       <!-- 新增编辑地址 -->
       <div class='j-edit-box hide'>
          <form id='addressForm' autocomplete='off' data-validator-option='{theme:"yellow_right"}'>
            <input type='hidden' class='j-eipt' id='addressId' value=''/>
            <div class='rows'>
                <div class='label'>收&nbsp;&nbsp;货&nbsp;&nbsp;人<font color='red'>*</font>：</div>
                <div class='field'><input type='text' class='j-eipt' id='userName' maxLength='25'/></div>
                <div class='wst-clear'></div>
            </div>
            <div class='rows'>
                <div class='label'>所在地区<font color='red'>*</font>：</div>
                <div class='field'>
                <select id="area_0" class='j-areas' level="0" onchange="WST.ITAreas({id:'area_0',val:this.value,isRequire:true,className:'j-areas'});">
              <option value="">-请选择-</option>
              {volist name="areaList" id="vo"}
              <option value="{$vo['areaId']}">{$vo['areaName']}</option>
              {/volist}
          </select>
                </div>
                <div class='wst-clear'></div>
            </div>
            <div class='rows'>
                <div class='label'>详细地址<font color='red'>*</font>：</div>
                <div class='field'>
                  <input type='text' class='j-eipt' id='userAddress' style='width:300px' maxLength='200'/>
                </div>
                <div class='wst-clear'></div>
            </div>
            <div class='rows'>
                <div class='label'>联系电话<font color='red'>*</font>：</div>
                <div class='field'><input type='text' id='userPhone' class='j-eipt' name="addrUserPhone" maxLength='11' onkeypress="return WST.isNumberKey(event);" onkeyup="javascript:WST.isChinese(this,1)"/>  </div>
                <div class='wst-clear'></div>
            </div>
            <div class='rows'>
                <div class='label'>默认地址<font color='red'>*</font>：</div>
                <div class='radio-box'>
                  <label style='margin-right:36px;'>
                     <input type='radio' name='isDefault' value='1' checked class='j-eipt wst-radio' id="isDefault1"/><label class="mt-1" for="isDefault1"></label>是
                  </label>
                  <label>
                     <input type='radio' name='isDefault' value='0' class='j-eipt wst-radio' id="isDefault2"/><label class="mt-1" for="isDefault2"></label>否
                  </label>
                </div>
                <div class='wst-clear'></div>
            </div>
            <div class='rows' style="text-align:center;">
                <a href='javascript:void(0)' class='wst-button' id='saveAddressBtn' onclick='javascript:editAddress()' style='height:38px;line-height: 38px;margin-top:10px;'>保存收货人地址</a>
            </div>
          </form>
       </div>
    </div>
    <!-- 支付方式 -->
    <div class='pay-box'>
       <div class='box-head-title'>支付方式</div>
       <div class="wst-list-box">
          {if !empty($payments['1'])}  
          <div class="wst-frame2 j-selected" onclick="javascript:changeSelected(1,'payType',this)">在线支付<i></i></div>
          {/if}
          <input type='hidden' value='1' id='payType' class='j-ipt' />
          <div class='wst-clear'></div>
       </div>
       <div class='wst-clear'></div>
    </div>
    <!-- 送货方式 -->
    <div class='pay-box'>
       <div class='box-head-title'>送货方式</div>
       <div class="wst-list-box">
         <div class="wst-frame2 j-selected" onclick="javascript:changeDeliverType(0,'deliverType',this)">快递运输<i></i></div>
         <div class="wst-frame2" onclick="javascript:changeDeliverType(1,'deliverType',this)">自提<i></i></div>
          <input type='hidden' value='0' id='deliverType' class='j-ipt' />
          <div class='wst-clear'></div>
       </div>
       <div class='wst-clear'></div>
    </div>
    <!-- 发票信息 -->
    <div class="pay-box" style="border-bottom:0px;">
       <div class='box-head-title'>发票信息</div>
       <div class="j-show-box">
         <div class="wst-frame2 j-selected inv_info" onclick='javascript:changeInvoice(0,"#invoiceClientDiv",this)'>
          <span id="invoice_info">不开发票</span>
          <i></i>
        </div>
         <div class="wst-frame2 inv_bon" onclick='javascript:changeInvoice(1,"#invoiceClientDiv",this)'>修改<i></i></div>
       </div>
       <div class='wst-clear'></div>
        <input type="hidden" id="invoice_obj" value="0" />
        <input type="hidden" id="invoiceId" value="0" class='j-ipt' />
        <input type='hidden' value='0' id='isInvoice' class='j-ipt' />
        <input type='hidden' value='个人' id='invoiceClient' class='j-ipt' />
        <input type="hidden" id="invoiceType" value="0" class='j-ipt' />
     </div>
    <!-- 商品清单 -->
    <div class='cart-box2'>
       <div class='box-head2'>
         <span class="title">商品清单</span>
         <div class="return"><a href="{:Url('home/carts/index')}">返回购物车<i class="iconfont"></i></a></div>
         <div class='wst-clear'></div>
       </div>
       {/* 用来计算总运费的 */}
       {php}$shopFreight = 0;{/php}
       {php}
       if($carts['isFreeShipping']){
          $freight = 0;
       }else{
         if(!empty($userAddress)){
             $freight = WSTOrderFreight($userAddress['areaId2']);
         }else{
             $freight = WSTOrderFreight($vo['areaId']);
         }
       }
        $shopFreight = $shopFreight + $freight;
        $goods = $carts["carts"]['goods'];
       {/php}
       <div class='cart-item'>
          <div class='goods-list'>
            
             
             <div class='item selected'>
            <div class='goods2'>
                <div class='img2'>
                    <a href='{:Url("home/goods/detail","id=".$goods["goodsId"])}' target='_blank'>
                  <img class='goodsImg' data-original="__RESOURCE_PATH__/{:WSTImg($goods['goodsImg'])}" width='30' height='30' title='{$goods["goodsName"]}'/>
                  </a>
                </div>
                <div class='name2'>{$goods["goodsName"]}&nbsp;
				{if($goods['isSpec'])}
				{volist name='goods["specNames"]' id='specs'}{$specs['itemName']}&nbsp;{/volist}
				{/if}
				</div>
            </div>
            <div class='price2'>{$goods['shopPrice']}元&nbsp;x&nbsp;{$goods['cartNum']}</div>
            <div class='material2'>{if($goods['goodsStock']>0)}有货{else}无货{/if}</div>
            <div class='t-price2'>{$goods['shopPrice']*$goods['cartNum']}元 + {$goods['integralNum']*$goods['cartNum']} 积分</div>
            <div class='wst-clear'></div>
             </div>

          </div>
          <div class='pay-box pay-boxs'>
           <span class="box-head-title">订单备注</span>
             <input type='text' id="remark" class='remark j-ipt' maxLength='100' placeholder='给卖家留言'/>
             <div class='wst-clear'></div>
          </div>
          <div class='shop-remark selected2'>
             <div class="cart-count">
             <p><span class="title">商品件数：</span><span class="price">{$carts['goodsTotalNum']}件</span></p>
             <p><span class="title">金额合计：</span><span class="price">{$carts['goodsTotalMoney']}元</span></p>
             <p><span class="title">积分合计：</span><span class="price">{$carts['totalIntegralNum']}个</span></p>
             <p><span class="title">运费：</span><span class="price" id='deliverMoney'>{$shopFreight}元</span></p>
             <p style="margin-top: 10px;"><span class="title" style="margin-top: 5px;">应付总额：</span><span class="price"><em id="totalMoney">{if empty($userAddress)}{$carts["goodsTotalMoney"]}{else}{$carts["goodsTotalMoney"]+$shopFreight}{/if}</em>元 + {$carts['totalIntegralNum']}积分</span></p>
             </div>
          </div>
       </div>

       </div>
     <div class='cart-btn2'>
      <div class="addressin" id="addressin">
        {if isset($userAddress["addressId"]) }
        <p class="info">{$userAddress['userName']}&nbsp;{$userAddress['userPhone']}<br/>{$userAddress['areaName']}&nbsp;{$userAddress['userAddress']}
        &nbsp;<a href="javascript:void(0);" onclick="javascript:toEditAddress({$userAddress["addressId"]},this,1,1,1)" class="modify">修改</a>
        </p>
        {/if}
      </div>
        <a href='javascript:void(0)' onclick='javascript:submitOrder()' class='wst-button wst-order'>提交订单</a>
        <div class='wst-clear'></div>
     </div>
</div>
</div>
</div>
{/block}
{block name="footer"}
  {include file="$LAYOUT_HOME_FOOTER" /}
{/block}
{block name="js"}
<script type='text/javascript' src='__ROOT__/addons/integral/view/home/index/js/carts.js?v={$v}'></script>
<script>
$(function(){
  getAddressList();
});
</script>
{/block}