<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/bootstrap-table.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/table-fix-column.css">

<!--<script src="--><?php //echo base_url();?><!--public/js/vendor/bootstrap/src/bootstrap-table.js"></script>-->
<!--<script src="--><?php //echo base_url();?><!--public/js/vendor/bootstrap/src/table-fix-column.js"></script>-->
<style>
    /* CSS Document */
    .menu {
        margin:0 auto;
        border:1pt solid #999999;
        border-radius:5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
    }
    .menu a {
        text-decoration:none;
        height:100%;
        display:block;
        border-radius:5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px; color:#333;
    }
    .menu a:visited {
        text-decoration:none;
        color:#000000;
    }
    .menu a:active {
        text-decoration:none;
    }
    .link-web{
        width:210px;
        height:40px;
        margin:0 auto;
        border-radius:4px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        /*text-shadow:0 2px 0 #FFF;*/
        font-family: "", "";
        font-size:18px;
    }
    .link-web a{
        text-decoration:none;
        width:210px;
        height:40px;
        display:block;
        border-radius:4px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        background-color: #F5F5F5;
        border:1px dashed #cccccc;
        color:#333;
    }
    .link-web a:visited{
        text-decoration:none;
        color:#333;
    }
    .link-web a:active{
        text-decoration:none;
        color:#333;
    }
    .font-arial{
        font-family: "微软雅黑", "", Arial, "Arial Black";
    }
    .font-italic{
        font-style:italic;
    }
    .font-blod{
        font-weight:bold;
    }
    .font-app{
        text-align:left;
        font-size:25px;
        color: #666666;
    }
    .font-app-display{
        text-align:left;
        font-size:20px;
        color:#999999;
        text-shadow:0 2px 0 #FFF;
    }
    .font02{
        font-size:18px; color:#999999;
        text-align:left;
    }
    .dp_copy{
        margin-top:10px;
        text-align:center;
        color:#919090;
        font-size:22px;
    }
</style>
</head>
<div class="content_wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>宠物查询</header>
                    <section>

                        <div class="row">
                            <div class="col-sm-12">
                                <form class="form-inline">
                                    <span class="gap"></span>
                                    <div class="form-group">
                                        <label>玩家id：</label>
                                        <input type="text" class="form-control" placeholder="用户UID" name="userid" id="userid" value="<?php echo $uid ?? '';?>">
                                    </div>
                                    <button type="button" class="btn btn-primary" id="SubmitBtn">查询</button>
                                </form>
                            </div>
                        </div>
                        <br>
                        <!--                        展示-->
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered table-hover"  width="100%" style="word-break:break-all; word-wrap:break-word; ">
                                            <thead>
                                            <tr>
                                                <th>宠物类型</th>
                                                <th>宠物等级</th>
                                                <th>宠物状态</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            foreach ($list as $k=>$item){
                                                if($item['status']==0){
                                                    $opt = "<button type='button' data-value='".$item['petId']."' class='btn btn-primary openPet'>激活</button>";
                                                }else{
                                                    $opt="";
                                                }
                                                echo "<tr><td>{$item['showName']}</td><td>{$item['lv']}</td><td>{$item['status']}</td><td>{$opt}</td></tr>";
                                            }
                                            ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </section>
                </aside>
            </div>
        </div>
    </div>
</div>

<script>


    $('#SubmitBtn').click(function(){
        var userId = $('#userid').val();
        var url = rootPath+"#customer/showUserPet/"+userId;
        window.location.href = url
    });

    $('.openPet').click(function(){
        var datas =[]
        var uid = "<?php echo $uid;?>";
        var pid = $('.openPet').data('value');
        console.log(datas);
        $.post('/customer/openUserPet', {pid:pid,uid:uid}, function(res){
            if(typeof res == 'string')res = JSON.parse(res)
            console.log(res);
            if(res.ret == 0){
                alert("激活成功");
                // var url = rootPath+"#customer/souchFriend/"+res.data.uid;
                // window.location.href = url
                history.go(0)
            }else{
                alert(res.msg);
                history.go(0)
            }
        })
    })

</script>