#@ucenter_layout()


#define script()
<script>

    function doDel(id) {
        if (confirm('确定要删除该记录吗？删除后不可恢复')) {
            ajaxGet("#(CPATH)/ucenter/address/doDel/" + id)
        }
    }

    $("#batchDel").click(function () {
        var ids = getSelectedIds();
        if (ids == "") {
            alert('您未选择任何内容');
            return
        }

        if (confirm('确定要删除选中的记录吗？删除后不可恢复')) {
            ajaxGet("#(CPATH)/ucenter/address/doDelByIds?ids=" + ids);
        }

    });


    function checkAll(checkbox) {
        $(".dataItem").each(function () {
            $(this).prop('checked', checkbox.checked);
        });

        dataItemChange();
    }

    function dataItemChange() {
        $(".checkAction").each(function () {
            getSelectedIds() != "" ? $(this).show().css("display", "inline-block") : $(this).hide();
        })
    }

    function getSelectedIds() {
        var selectedIds = "";
        $(".dataItem").each(function () {
            if ($(this).prop('checked')) {
                selectedIds += $(this).val() + ",";
            }
        });
        return selectedIds.substring(0,selectedIds.length - 1);
    }

</script>
#end


#define css()
<style>

    .box-dashboard {
        position: relative;
        border-radius: 3px;
        background: #ffffff;
        border: 1px solid #d2d6de;
        margin-bottom: 20px;
        width: 100%;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0);
    }

    .box-dashboard .box-header .box-title {
        display: inline-block;
        font-size: 14px;
        margin: 0;
        line-height: 1;
    }

</style>

#end

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

    <section class="content-header">
        <h1>
            我的地址
            <small>My Address</small>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-header with-border">

                        <div class="row actionPanel">
                            <div class="col-xs-12">
                                <a href="#(CPATH)/ucenter/address/edit" class="btn btn-primary "> <i class="fa fa-fw fa-plus"></i> 新建</a>
                                <button type="button" id="batchDel" class="btn btn-default checkAction"> 批量删除</button>
                            </div>
                        </div>

                    </div>
                    <!-- /.box-header -->
                    <div class="box-body ">

                        <table class="table table-striped" id="table-address">
                            <tbody>
                            <tr>
                                <th style="width: 10px">
                                    <input name="dataItem" onchange="checkAll(this)" type="checkbox" value="0"/>
                                </th>
                                <th style="width: 150px">收货人</th>
                                <th style="width: 150px">手机号码</th>
                                <th style="width: 40%">地址</th>
                                <th style="width: 100px">邮政编码</th>
                                <th style="width: 80px">是否默认</th>
                            </tr>

                            #for(data : page.list)
                            <tr class="jp-actiontr">
                                <td><input class="dataItem" type="checkbox" name="address.id" value="#(data.id)" onchange="dataItemChange(this)"/></td>
                                <td style="width: 50px">
                                    <strong><a href="#">#(data.username ??)</a></strong>
                                    <div class="jp-actionblock">
                                        <div class="jp-actionitem">
                                            <a href="#(CPATH)/ucenter/address/edit?id=#(data.id)" style="color: #006505">编辑</a>|<a href="javascript:;" onclick="doDel('#(data.id)')" style="color: #a00">删除</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    #(data.mobile ??)
                                </td>
                                <td>
                                    #(data.province ??) &nbsp;#(data.city ??) &nbsp; #(data.district ??) &nbsp;#(data.detail ??)
                                </td>
                                <td>
                                    #(data.zipcode ??) &nbsp;
                                </td>
                                <td>
                                    #if(data.isDefault)
                                        是
                                    #else
                                        否
                                    #end
                                </td>
                            </tr>
                            #end

                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-12">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

    </section>


</div>
#end
