<?php /* D:\phpStudy\PHPTutorial\WWW\liangshan\resources\views/Admin/vip-list.blade.php */ ?>
<?php $__env->startSection('admin'); ?>
<!-- 修改等级 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal2Label">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
      <div class="modal-body">
                <form class="form-horizontal">
                      <div class="form-group m-4">
                            <label for="inputEmail3" class="col-sm-3 control-label">当前等级:</label>
                            <div class="col-sm-12">
                              <span id="now_level">加载中...</span>
                            </div>
                        </div>
                    <div class="form-group m-4">
                        <label for="exampleInputName2" class="col-md-3"><span style="color:red">*</span> 等级调整</label>
                        <div class="col-sm-12">
                        <input type="hidden" id="vip_id">
                          <select class="form-control col-md-6" id="level">
                            <?php $__currentLoopData = $level; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                              <option value="<?php echo e($val -> id); ?>"><?php echo e($val -> level_name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          </select>
                        </div>
                    </div>
                </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" onclick="update()">修改</button>
      </div>
    </div>
  </div>
</div>
<!-- 莫泰结束 -->
<div class="content-wrapper" style="min-height: 810px;">
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h4>会员列表</h4>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/admin/index">首页</a></li>
              <li class="breadcrumb-item active">会员管理</li>
              <li class="breadcrumb-item active">会员列表</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
    <div class="col-xs-3">
        <a href="javascript:window.location.href='/admin/vip/level'" class="btn btn-danger" style="margin-left:17px;margin-bottom:15px"> 设置会员等级</a>
    </div>
    
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-12">

            <div class="card">
              <!-- /.card-header -->
              <div class="card-body p-0">
                <table class="table table-condensed">
                  <tbody>

                  <tr style="text-align:center">
                    <th>头像</th>
                    <th>昵称</th>
                    <th>等级</th>
                    <th>积分</th>
                    <th>余额</th>
                    <th>状态</th>
                    <th>操作</th>
                  </tr>
                <?php $__currentLoopData = $vip; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <tr style="text-align:center">
                    <input type="hidden" value="<?php echo e($val -> id); ?>">
                    <td><img src="<?php echo e($val -> header); ?>" style="height:40px;width:40px"></td>
                    <td><?php echo e($val -> nickname); ?></td>
                    <td>
                      <?php if($val -> level == 1): ?>
                      <span style="color:#FF4A51"><?php echo e(DB::table('vip_level') -> where('id',$val -> level) -> value('level_name')); ?></span>
                      <?php else: ?>
                      <span style="color:#FDC436"><?php echo e(DB::table('vip_level') -> where('id',$val -> level) -> value('level_name')); ?></span>
                      <?php endif; ?>
                    </td>
                    <td><?php echo e($val -> jifen); ?></td>
                    <?php $price = DB::table('access') -> where('user_id',$val -> id) -> value('price');?>
                    <?php if(!$price): ?>
                    <td>未开通</td>
                    <?php else: ?>
                    <td><?php echo e($price); ?></td>
                    <?php endif; ?>
                    <td>
                        <?php if($val -> status == 1): ?>
                        <a href="javascript:void(0)" onclick="status(<?php echo e($val -> id); ?>)"><span class="badge bg-success">正常</span></a>
                        <?php else: ?>
                        <a href="javascript:void(0)" onclick="status(<?php echo e($val -> id); ?>)"><span class="badge bg-danger">冻结中</span></a>
                        <?php endif; ?>
                    </td>
                    <td><a class="btn btn-primary btn-sm" onclick="mode(<?php echo e($val -> id); ?>,'<?php echo e(DB::table('vip_level') -> where('id',$val -> level) -> value('level_name')); ?>')" style="color:white">调整等级</a></td>
                  </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody></table>
                
              </div>
              
            </div>
            <span class="pull-right"><?php echo e($vip -> appends($a->page) -> links()); ?></span>
          </div>
        </div>
    </section>
  </div>
<script src="/admin/plugins/jquery/jquery.min.js"></script>
<script src="/admin/layer-v3.1.1/layer/layer.js"></script>
<script>
    function mode(id,level)
    {
      //设置id到隐藏域
      if(!id || !level) {
        layer.alert('参数错误');
        return false;
      }
      $('#now_level').html(level);
      $('#vip_id').val(id);
      $('#myModal').modal();
    }
    //更新会员等级
    function update()
    {
      var id = $('#vip_id').val();
      var level = $('#level').val();
      if(!id || !level){
            layer.msg('信息错误');
            return false;
        }
        $.get('/admin/vip/update',{id:id,level:level},function(res){
            if(res.code == '1000'){
                layer.msg(res.msg);
                window.location.reload();
            }else{
                layer.alert(res.msg);
            }
        })
    }

    function status(id)
    {
        if(!id){
            layer.msg('参数错误');
            return false;
        }
        layer.confirm('确认操作吗？', {
            btn: ['确认','取消'] //按钮
            }, function(){
                $.get('/admin/vip/status',{id:id},function(res){
                    if(res.code == '1000'){
                        layer.msg(res.msg);
                        window.location.reload();
                    }else{
                        layer.msg(res.msg);
                    }
                })
        });  
    }
</script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title','会员列表'); ?>
<?php $__env->startSection('vip','menu-open'); ?>
<?php $__env->startSection('vip2','active'); ?>
<?php $__env->startSection('vip-list','active'); ?>
<?php echo $__env->make('Public.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>