<!--{assign var="menu_id" value="coupon"}-->
<!--{include file="<!--{$oetplpath}-->block_header.tpl"}-->
<style type="text/css">
  body{background:#f7f7f7;}
</style>
<div class="oe_ntop"> <i class="iconfont" onclick="goBack();">&#xe616;</i>
  <p>确认订单</p>
</div>
<div class="oe_cart_confirm">

  <dl class="dl_1" f="edit-address">
    <dt> <i class="iconfont">&#xe629;</i> </dt>
    <dd>
      <p class="p_1">
          收货人：<font f="contname"><!--{$default_add.contname}--></font>
        <label f="contphone"><!--{$default_add.contphone}--></label>
      </p>
      <p class="p_2">收货地址：
          <font f="street">
              <!--{area type='text' value=$default_add.area1}-->
              <!--{area type='text' value=$default_add.area2}-->
              <!--{area type='text' value=$default_add.area3}-->
              <!--{area type='text' value=$default_add.area4}-->
              <!--{$default_add.street}-->
          </font>
      </p>
      <i class="iconfont">&#xe615;</i>
      </dd>
    <div class="clear"></div>
  </dl>
  <form action="<!--{$oefile}-->&c=order&a=add" method="post" name="myform" id="myform" f="myform" >
    <input type="hidden" name="paytype" id="paytype" value="1" checked >
    <input type="hidden" value="<!--{$data.goods}-->" name="goodslist" id="goodslist" f="goodslist">
    <input type="hidden" value="<!--{$default_add.isdefault}-->"  name="address" id="address" f="address">
  </form>
  <!--{foreach $data.cart as $volist}-->
  <dl class="dl_2">
    <dt><i class="iconfont">&#xe60e;</i> <!--{$volist.shopname}--> <i class="iconfont">&#xe615;</i></dt>
    <dd class="dd_1">
      <ul>
        <!--{assign var='i' value=0}-->
        <!--{foreach $volist.goodslist as $val}-->
        <li> <img src="<!--{$val.thumbimg}-->" alt="" />
          <h3><!--{$val.goodsname}--></h3>
          <p class="p_1">套餐分类：<!--{$val.pricelist.name}--></p>
          <p class="p_2"> <span>￥ <!--{$val.price}--></span><s>￥ <!--{$val.oldprice}--></s>
            <label>x <font f="goods_nums"><!--{$val.nums}--> <!--{assign var='i' value=$i+$val.nums}--></font></label>
          </p>
        </li>
        <!--{/foreach}-->
      </ul>
    </dd>
    <dd class="dd_2">
      <ul>
        <li><span>配送方式</span>
          <p>快递平邮</p>
           </li>
        <li><span>快递运费</span>
          <p><!--{if $volist.shipfee==0}-->快递免邮<!--{else}--><!--{$volist.shipfee}-->元<!--{/if}--></p>
          </li>
        <li><span>买家留言：</span>
          <p>
            <input type="text" name="postscript_<!--{$volist.shopid}-->" id="postscript_<!--{$volist.shopid}-->" placeholder="选填，与商家达成的要求" />
          </p>
          </li>
        <li class="total">共<!--{$i}-->件商品  合计：<b>￥<!--{$volist.shoptotal}--></b></li>
      </ul>
    </dd>
  </dl>
  <!--{/foreach}-->
</div>
<div class="kong"></div>
<div class="oe_cartconfirm"> 合计：<span>￥<!--{$data.amount}--></span>
  <label f="form-submit">提交订单</label>
</div>

<div class="oe_shade" f="select_address" style="left:1024px; display: none;">
    <div class="oe_topser"> <i class="iconfont" f="data-back"></i>
        <p>选择收货地址</p>
        <label f="data-mange">管理</label>
    </div>
    <div class="oe_cart_address" style="margin-top:2px;" id="addresslist">

    </div>
</div>


<div class="oe_shade" f="modify_address" style="display:none; left: 1024px;">
    <div class="oe_topser"> <i class="iconfont" f="modify-back"></i>
        <p>管理收货地址</p>
    </div>
    <div class="oe_cart_address" id="manage-address">

    </div>
    <div  class="kong"></div>
    <div class="oe_cartrs_btn" f="data-add">
        <span>添加新地址</span>
    </div>

</div>

<div class="oe_shade" style="display: none; left: 1024px;" f="add-address">
    <div class="oe_topser"> <i class="iconfont" f="add-back"></i>
        <p>添加新地址</p>
    </div>
    <div class="oe_cart_addaddress" id="saveadd-address">

    </div>
    <div class="ge"></div>
    <div class="oe_cartrs_btn" f="save-submit">
        <span>保存地址</span>
    </div>
</div>

<div class="oe_shade" style="display: none; left: 1024px;" f="saveedit-address">
    <div class="oe_topser"> <i class="iconfont" f="saveedit-back"></i>
        <p>编辑地址</p>
    </div>
    <div class="oe_cart_addaddress" id="saveedit-address">

    </div>
    <div class="ge"></div>
    <div class="oe_cartrs_btn" f="saveedit-submit">
        <span>保存地址</span>
    </div>
</div>

<script type="text/javascript">
$(function(){
    $max_width = WIN_WIDTH-110;
    $(".oe_cart_confirm .dl_2 ul li .p_2").css({"width":$max_width});

    //异步调取用户收货地址列表
    $url = "<!--{$oefile}-->&c=address&a=ajaxlist";
    $tpname = "addresslist";
    _oemarryAjaxGetContent($url, $tpname);

    //选择地址
    $(document).on("click", '[f="edit-address"]', function(){
        $('[f="select_address"]').show();
        $('[f="select_address"]').animate({ left: '0px' }, "100");

        //异步调取用户收货地址列表 管理收货地址
        $url = "<!--{$oefile}-->&c=address&a=ajaxlist&modify=1";
        _oemarryAjaxGetContent($url, "manage-address");
    });
    //选择收货地址-返回键
    $(document).on("click", '[f="data-back"]', function(){
        $('[f="select_address"]').animate({ left: '1024px' }, "1000",
                function(){$('[f="select_address"]').hide();});
    });
    //选中地址
    $(document).on("click", '[f="data-address"]', function(){
        $address_id = $(this).attr("data-id");
        $("#address").val($address_id);
        $('[f="contname"]').html($(this).find('[f="sel_contname"]').html());
        $('[f="contphone"]').html($(this).find('[f="sel_contphone"]').html());
        $('[f="street"]').html($(this).find('[f="sel_street"]').html());
        $('[f="select_address"]').animate({ left: '1024px' }, "1000");
    });

    $(document).on("click", '[f="add-address"]', function(){

    });

    //管理
    $(document).on("click", '[f="data-mange"]', function(){
        $('[f="modify_address"]').show();
        $('[f="modify_address"]').animate({ left: '0px' }, "100");
    });
    //管理收货地址-返回键
    $(document).on("click", '[f="modify-back"]', function(){
        $url = "<!--{$oefile}-->&c=address&a=ajaxlist";
        $tpname = "addresslist";
        _oemarryAjaxGetContent($url, $tpname);
        $('[f="modify_address"]').animate({ left: '1024px' }, "1000",
                function(){$('[f="modify_address"]').hide();});
    });

    $(document).on("click", '[f="data-add"]', function(){
        //异步调取用户收货地址列表 管理收货地址
        $url = "<!--{$oefile}-->&c=address&a=ajaxadd";
        _oemarryAjaxGetContent($url, "saveadd-address");
        $('[f="add-address"]').show();
        $('[f="add-address"]').animate({ left: '0px' }, "100");
    });

    $(document).on("click",'[f="add-back"]', function(){
        //异步调取用户收货地址列表 管理收货地址
        $url = "<!--{$oefile}-->&c=address&a=ajaxlist&modify=1";
        _oemarryAjaxGetContent($url, "manage-address");
        $('[f="add-address"]').animate({ left: '1024px' }, "1000",
                function(){$('[f="add-address"]').hide();});
        $("#saveadd-address").html('');
    });

    $(document).on("click", '[f="save-submit"]', function(){
        $data = _oemarryGetField();
        if($data !== false){
            $area1 = $("#area1").val();
            $area2 = $("#area2").val();
            $area3 = $("#area3").val();
            if ($area1 <= 0) {
                ToastShow("请选择所在地区");
                return false;
            }
            if ($area2 <= 0) {
                ToastShow("请选择所在地区");
                return false;
            }
            $data = $data+"&area1="+encodeURIComponent($area1)+"&area2="+encodeURIComponent($area2)+"&area3="+encodeURIComponent($area3);
            $_url = "<!--{$oefile}-->&c=address&a=saveadd"+$data;
            $post_json = {"url":$_url, "success_text":"添加成功", "fail_text":"添加失败"};
            _oemarryAjaxPost($post_json);

            //异步调取用户收货地址列表 管理收货地址
            $url = "<!--{$oefile}-->&c=address&a=ajaxlist&modify=1";
            _oemarryAjaxGetContent($url, "manage-address");
            $('[f="add-address"]').animate(
                    { left: '1024px' },
                    "1000",
                    function(){
                        $('[f="add-address"]').hide();
                    }
            );
            $("#saveadd-address").html('');
        }
    });

    $(document).on("click", '[f="saveedit-submit"]', function(){
        $data = _oemarryGetField();
        if($data !== false){
            $area1 = $("#area1").val();
            $area2 = $("#area2").val();
            $area3 = $("#area3").val();
            if ($area1 <= 0) {
                ToastShow("请选择所在地区");
                return false;
            }
            if ($area2 <= 0) {
                ToastShow("请选择所在地区");
                return false;
            }
            $data = $data+"&area1="+encodeURIComponent($area1)+"&area2="+encodeURIComponent($area2)+"&area3="+encodeURIComponent($area3);
            $_url = "<!--{$oefile}-->&c=address&a=saveedit"+$data;
            $post_json = {"url":$_url, "success_text":"保存成功", "fail_text":"保存失败"};
            _oemarryAjaxPost($post_json);

            //异步调取用户收货地址列表 管理收货地址
            $url = "<!--{$oefile}-->&c=address&a=ajaxlist&modify=1";
            _oemarryAjaxGetContent($url, "manage-address");
            $('[f="saveedit-address"]').animate(
                    { left: '1024px' },
                    "1000",
                    function(){
                        $('[f="saveedit-address"]').hide();
                    }
            );
            $("#saveedit-address").html('');
        }
    });

    $(document).on("click", '[f="saveedit-back"]', function(){
        //异步调取用户收货地址列表 管理收货地址
        $url = "<!--{$oefile}-->&c=address&a=ajaxlist&modify=1";
        _oemarryAjaxGetContent($url, "manage-address");
        $('[f="saveedit-address"]').animate(
                { left: '1024px' },
                "1000",
                function(){
                    $('[f="saveedit-address"]').hide();
                }
        );
        $("#saveedit-address").html('');
    });

    $(document).on("click", '[f="form-submit"]', function(){
        //  paytype
        if($("#goodslist").val()==''){
            ToastShow("商品不存在");
            return false;
        }
        if($("#address").val()==''){
            ToastShow("请添加收货地址");
            return false;
        }
        $("#myform").submit();
    });


});
</script>
</body></html>