<?php /* D:\phpstudy\PHPTutorial\WWW\liangshan\resources\views/Admin/user-quan.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-danger back" style="margin-left:17px;margin-bottom:15px"> 返回列表</button>
    </div>
    
    <ul class="list-group col-sm-6">
        <?php $__currentLoopData = $youhui; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <li class="list-group-item" style="font-size:14px">
        <input type="checkbox" value='<?php echo e($val -> id); ?>' class="yh">　　<?php echo e($val -> name); ?></li>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </ul>
    <span style="color:red;font-size:12px;margin-left:10px">*不包含充值专享优惠券</span><br>
    <a href="javascript:void(0)" class="btn btn-success m-3 quan">发券</a>
  </div> 
  <input type="hidden" value="<?php echo e($id); ?>" class="id">
<script src="/admin/plugins/jquery/jquery.min.js"></script>
<script src="/admin/layer-v3.1.1/layer/layer.js"></script>
<script>
    $('.back').click(function(){
        window.location.href="/admin/user/list"
    })
    $('.quan').click(function(){
        //获取选中的优惠券
        var select_id = [];
        $('.yh').each(function(k,v){
            //判断是否选中
            if(v.checked){
                select_id.push($(v).val());
            }
        })
        var id = $('.id').val();
        if(!select_id.length){
            layer.alert('请先选择需要发放的优惠券');
            return;
        }
        $.get('/admin/user/yh',{select_id:select_id,id:id},function(res){
            console.log(res);
            if(res.code == '1000') {
                if(res.err){
                    layer.alert('发放成功! 成功'+res.is+'，失败'+res.err+'，失败原因：优惠券已过期或优惠券领取数量已达上限');
                }else{
                    layer.alert('发放成功! 成功'+res.is+'，失败'+res.err+'');
                }
                
            }else{
                layer.alert('发放失败!请重试');
            }
        })
    })
    
</script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title','发放优惠券'); ?>
<?php $__env->startSection('user','menu-open'); ?>
<?php $__env->startSection('user2','active'); ?>
<?php $__env->startSection('user-list','active'); ?>

                        
        
    
   
<?php echo $__env->make('Public.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>