#@ucenter_layout()

#define script()

<script src="#(CPATH)/static/components/distpicker/distpicker.min.js"></script>

<script>

    $("#add-address-event").on("click", function () {
        $("#addressForm").ajaxSubmit({
            type: "post",
            success: function (data) {
                if (data.state == "ok") {
                    alert("操作成功");
                    location.href = "#(CPATH)/ucenter/address/list";
                } else {
                    alert(data.message);
                }
            },
            error: function () {
                alert("系统错误，请联系管理员。");
            }
        });
    })
</script>
#end

#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            新增/编辑地址
            <small>Add/Edit Address </small>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-header ">
                        <h3 class="box-title"></h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form class="form-horizontal" id="addressForm" method="post" action="#(CPATH)/ucenter/address/doAdd">

                        <input type="hidden" class="form-control" name="address.id" value="#(data.id ??)"/>

                        <div class="box-body ">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">联系人</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" placeholder="联系人" name="address.username" value="#(data.username ??)">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">联系电话</label>
                                <div class="col-sm-6">
                                    <input type="input" class="form-control" placeholder="联系电话" name="address.mobile" value="#(data.mobile ??)">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">地址管理</label>
                                <div class="col-sm-6">
                                    <div data-toggle="distpicker"  class="form-inline" data-autoselect="3">
                                        <select class="form-control" data-province="#(data.province ?? '---- 选择省 ----')" name="address.province" ></select>
                                        <select class="form-control" data-city="#(data.city ?? '---- 选择市 ----')" name="address.city" ></select>
                                        <select class="form-control" data-district="#(data.district ?? '---- 选择区 ----')" name="address.district" ></select>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">详细地址</label>
                                <div class="col-sm-6">
                                    <textarea rows="3" class="form-control"
                                              placeholder="详细地址..."
                                              name="address.detail">#(data.detail ??)</textarea>
                                    <p class="help-block"> 请具体到街道、楼层以及门牌号 </p>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">邮政编码</label>
                                <div class="col-sm-6">
                                    <input type="input" class="form-control" placeholder="" name="address.zipcode" value="#(data.zipcode ??)">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否默认</label>
                                <div class="col-sm-6">
                                    <select class="form-control" name="address.isDefault" >
                                        <option value="true" #selectedIf(data.isDefault ??)>是</option>
                                        <option value="false" #selectedIf(!data.isDefault ??)>否</option>
                                    </select>
                                </div>

                            </div>

                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="col-sm-offset-2 col-sm-10 submit-block">
                                <div class="box-submit">
                                    <button type="button" class="btn btn-primary" id="add-address-event">提交</button>
                                    <a href="#(CPATH)/ucenter/address/list"><button type="button" class="btn ">返回</button></a>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
        </div>

    </section>

</div>
#end
