<?php /* /www/wwwroot/jian/resources/views/Admin/you-list.blade.php */ ?>
<?php $__env->startSection('admin'); ?>

<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>
    </section>
    <div class="col-xs-3">
        <button class="btn btn-primary add" style="margin-left:17px;margin-bottom:15px">添加优惠券 +</button>
    </div>

    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-12">

            <div class="card">
              <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 style="width: 100px">操作</th>
                  </tr>
                  <?php $__currentLoopData = $you; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <tr style="text-align:center">
                    <td><a onclick="look(<?php echo e($val -> id); ?>)" href="javascript:void(0);"><?php echo e($val -> name); ?></a></td>
                    <td><?php if($val -> type == 1): ?>
                            <?php if($val -> use_height_type == 1): ?>
                            无门槛
                            <?php else: ?>
                            满 <?php echo e($val -> use_height); ?> 元
                            <?php endif; ?>
                        直减 <?php echo e($val -> price); ?> 元
                        <?php else: ?>
                            <?php if($val -> use_height_type == 1): ?>
                            无门槛
                            <?php else: ?>
                            满 <?php echo e($val -> use_height); ?> 元
                            <?php endif; ?>
                        折扣 <?php echo e((100 - $val -> price) / 10); ?> 折
                        <?php endif; ?>
                    </td>
                    <td>
                        <?php if($val -> use_type == 1): ?>
                        全部商品
                        <?php elseif($val -> use_type == 2): ?>
                        <?php 
                            $arr = explode(',',$val -> use_size);
                            $goods = DB::table('goods') -> whereIn('id',$arr) -> get();
                            foreach($goods as $a => $b){
                            echo $b -> goods_name.','.'<br>';
                            }
                        ?>
                        <?php else: ?>
                        <span style="color:red">除却以下商品:</span><br>
                        <?php 
                            $arr = explode(',',$val -> use_size);
                            $goods = DB::table('goods') -> whereIn('id',$arr) -> get();
                            foreach($goods as $a => $b){
                            echo $b -> goods_name.','.'<br>';
                            }
                        ?>
                        <?php endif; ?>
                    </td>
                    <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 href="javascript:void(0)" onclick="edit(<?php echo e($val -> id); ?>)"><i class="fa fa-edit" style="font-size: 16px;" title="编辑"></i></a>
                        <a href="javascript:void(0)" onclick="del(<?php echo e($val -> id); ?>)"><i class="fa fa-trash" style="font-size: 16px;" title="删除"></i></a>
                    </td>
                  </tr>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody></table>
              </div>
            </div>
          </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 del(id)
    {
        if(!id) {
            layer.msg('参数不全');
            return false;
        }
        layer.confirm('确认删除该文章吗？', {
            btn: ['确认','取消'] //按钮
            }, function(){
                $.get('/admin/you/delete',{id:id},function(res){
                    if(res.code == '1000'){
                        layer.msg(res.msg);
                        window.location.reload();
                    }else{
                        layer.msg(res.msg);
                    }
                })
        });
    }
    function status(id)
    {
        if(!id){
            layer.alert('参数错误');
            return false;
        }
        layer.confirm('确认操作吗？不影响用户已领取的优惠券', {
            btn: ['确认','取消'] //按钮
            }, function(){
                $.get('/admin/you/status',{id:id},function(res){
                    if(res.code == '1000'){
                        layer.msg(res.msg);
                        window.location.reload();
                    }else{
                        layer.msg(res.msg);
                    }
                })
        });  
    }
    //添加优惠券
    $('.add').click(function(){
        window.location.href="/admin/you/add";
    })
    //编辑优惠券
    function edit(id)
    {
      if(!id){
        layer.alert('参数错误');
        return false;
      }
      window.location.href="/admin/you/edit/"+ id;
    }
    //查看优惠券详情
    function look(id)
    {
      if(!id) {
        layer.alert('参数错误');
        return false;
      }
      window.location.href="/admin/you/look/"+ id;
    }
</script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title','优惠券列表'); ?>
<?php $__env->startSection('youhui','menu-open'); ?>
<?php $__env->startSection('youhui2','active'); ?>
<?php $__env->startSection('youhui-list','active'); ?>
<?php echo $__env->make('Public.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>