<?php /* /www/wwwroot/jian/resources/views/Admin/shalong-edit.blade.php */ ?>
<?php $__env->startSection('admin'); ?>
<script src="/admin/plugins/jquery/jquery.min.js"></script>
<script src="/admin/layer-v3.1.1/layer/layer.js"></script>
<!-- 图片裁剪 -->
<!-- <link rel="stylesheet" type="text/css" href="/img_cate/ycbootstrap.css"> -->
<link rel="stylesheet" type="text/css" href="/img_cate/reset.css">
<script src="/img_cate/jquery-1.10.2.js"></script>
<!-- <script src="/img_cate/jquery.min.js"></script> -->
<script src="/img_cate/iscroll-zoom.js" type="text/javascript" charset="utf-8"></script>
<script src="/img_cate/hammer.js" type="text/javascript" charset="utf-8"></script>
<script src="/img_cate/lrz.all.bundle.js" type="text/javascript" charset="utf-8"></script>
<script src="/img_cate/jquery.photoClip.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/layDate-v5.0.9/laydate/laydate.js"></script>
<style>
  img {
    max-width: 100%;
  }
</style>
<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>
              <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>

    <section class="content">
        
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-12">
            <div class="card">
              <div class="card-body p-0">
                <!-- 表单 -->
                <input type="hidden" id="edit_id" value="<?php echo e($edit -> id); ?>">
                <form class="form m-4">
                  <div class="form-group">
                      <label for="name" class="col-sm-12 control-label"><span style="color:red">*</span> 选择门店</label>
                          <div class="col-sm-6">
                              <select class="form-control" id="md">
                                  <?php $__currentLoopData = $md; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                  <option value="<?php echo e($val -> id); ?>" <?php if($edit -> md_id == $val -> id): ?> selected <?php endif; ?>> <?php echo e($val -> md_name); ?></option>
                                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                              </select>
                          </div>
                  </div>
                </div>
                <form class="form">
                    <div class="form-group m-4">
                        <label for="exampleInputName2" class="col-md-4"><span style="color:red">*</span> 沙龙名称</label>
                        <input type="text" class="form-control col-md-6" id="wztitle" value="<?php echo e($edit -> title); ?>" placeholder="请输入沙龙标题">
                    </div>
                </form>
                <form class="form">
                    <div class="form-group m-4">
                        <label for="exampleInputName2" class="col-md-4"> 报名人数限额</label>
                        <input type="number" class="form-control col-md-6" value="<?php echo e($edit -> person_num); ?>" id="person_num">
                    </div>
                </form>
                <form class="form">
                    <div class="form-group m-4">
                        <label for="exampleInputName2" class="col-md-4"><span style="color:red">*</span> 报名截止时间</label>
                        <input type="text" id="end_date" class="form-control col-md-6" value="<?php echo e(date('Y-m-d H:i:s',$edit -> end_date)); ?>">
                    </div>
                </form>
                <form class="form">
                    <div class="form-group m-4">
                        <label for="exampleInputName2" class="col-md-3"><span style="color:red">*</span> 报名方式</label>
                    </div>
                    <div class="form-group m-4">
                        <input class="check" type="radio" name="type" value="1" <?php if($edit -> price_status == 1): ?> checked <?php endif; ?>> <label class="col-md-1"> 现金</label> 
                        <input class="check" type="radio" name="type" value="2" <?php if($edit -> price_status == 2): ?> checked <?php endif; ?>> <label class="col-md-1"> 积分</label>
                    </div>
                </form>
                <form class="form">
                    <div class="form-group m-4">
                        <label for="exampleInputName2" class="col-md-4"><span style="color:red">*</span> 金额</label>
                        <input type="number" class="form-control col-md-6" id="price" value="<?php echo e($edit -> price); ?>" placeholder="需要的积分数量或者现金金额">
                    </div>
                </form>
                <!-- 图片裁剪代码 -->
                <body style="">
                  <div class="yc-upload-wrap col-md-6">
                  <div class="yc-upload-box">
                  <div class="container">
                  <div class="row">
                  <div class="col-md-12 col-sm-12 col-xs-12" style="padding:0;">
                  <div class="ycupload-mainbox">
                  <div class="ycupload-line"></div>
                  <div style="height:30px;"></div>
                  <div style="min-height:1px;">
                  <div class="container">
                  <div class="row">
                  <div class="col-md-12 col-sm-12 col-xs-12" style="padding-right:0;padding-left:36px;">

                  <div style="min-height:1px;line-height:160px;text-align:center;position:relative;" ontouchstart="">
                  <div class="cover-wrap" style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); z-index: 10000000; text-align: center; display: none;">
                  <div class="" style="width:900px;height:600px;margin:100px auto;background-color:#FFFFFF;overflow: hidden;border-radius:4px;">
                  <div id="clipArea" style="margin: 10px; height: 520px; user-select: none; overflow: hidden; position: relative;"><div class="photo-clip-view" style="position: absolute; left: 50%; top: 50%; width: 428px; height: 321px; margin-left: -214px; margin-top: -160.5px;"><div class="photo-clip-moveLayer" style="transform-origin: 0px 0px 0px; transition-timing-function: cubic-bezier(0.1, 0.57, 0.1, 1); transition-duration: 0ms; transform: translate(0px, 0px) scale(1) translateZ(0px);"><div class="photo-clip-rotateLayer"></div></div></div><div class="photo-clip-mask" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; pointer-events: none;"><div class="photo-clip-mask-left" style="position: absolute; left: 0px; right: 50%; top: 50%; bottom: 50%; width: auto; height: 321px; margin-right: 214px; margin-top: -160.5px; margin-bottom: -160.5px; background-color: rgba(0, 0, 0, 0.5);"></div><div class="photo-clip-mask-right" style="position: absolute; left: 50%; right: 0px; top: 50%; bottom: 50%; margin-left: 214px; margin-top: -160.5px; margin-bottom: -160.5px; background-color: rgba(0, 0, 0, 0.5);"></div><div class="photo-clip-mask-top" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 50%; margin-bottom: 160.5px; background-color: rgba(0, 0, 0, 0.5);"></div><div class="photo-clip-mask-bottom" style="position: absolute; left: 0px; right: 0px; top: 50%; bottom: 0px; margin-top: 160.5px; background-color: rgba(0, 0, 0, 0.5);"></div><div class="photo-clip-area" style="border: 1px dashed rgb(221, 221, 221); position: absolute; left: 50%; top: 50%; width: 428px; height: 321px; margin-left: -215px; margin-top: -161.5px;"></div></div></div>
                  <div class="" style="height:56px;line-height:36px;text-align: center;padding-top:8px;">
                  <button id="clipBtn" style="width:120px;height: 36px;border-radius: 4px;background-color:#ff8a00;color: #FFFFFF;font-size: 14px;text-align: center;line-height: 36px;outline: none;">保存封面</button>
                  </div>
                  </div>
                  </div>
                  <div id="view" style="width: 214px; height: 160.5px; <?php if($edit -> imgURL): ?> background:url(/<?php echo e($edit -> imgURL); ?>); <?php endif; ?> background-color: rgb(102, 102, 102); background-repeat: no-repeat; background-position: center center; background-size: contain;"></div>
                  <div style="height:10px;"></div>
                  <div class="" style="width:140px;height:32px;border-radius: 4px;background-color:#ff8a00;color: #FFFFFF;font-size: 14px;text-align:center;line-height:32px;outline:none;margin-left:37px;position:relative;">
                  点击上传封面图
                  <input type="file" id="file" style="cursor:pointer;opacity:0;filter:alpha(opacity=0);width:100%;height:100%;position:absolute;top:0;left:0;" accept="image/*">
                  </div>
                  </div>
                  </div>
                  </div>
                  </div>
                  </div>
                  <!-- <div style="height:25px;"></div> -->
                  </div>
                  </div>
                  </div>
                  </div>
                  </div>
                  </div>

                  </body>
                  
            <input type="hidden" id="imgURL">
                <!-- 文章 -->
                <form class="form">
                    <div class="form-group m-4">
                        <label for="exampleInputFile" class="col-md-4">编辑文章</label>
                        <div class="input-group col-md-6">
                            <!-- 加载编辑器的容器 -->
                              <script id="container" style="height:400px;" name="content" type="text/plain"><?php echo $edit -> content; ?></script>
                              <!-- 配置文件 -->
                              <script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
                              <!-- 编辑器源码文件 -->
                              <script type="text/javascript" src="/ueditor/ueditor.all.js"></script>
                              <!-- 实例化编辑器 -->
                              <script type="text/javascript">
                                  var ue = UE.getEditor('container');
                              </script>
                        </div>
                    </div>
                </form>
                <form class="form">
                    <div class="form-group m-4 col-sm-6">
                        <a class="btn btn-success ok" style="color:white">发布</a>
                    </div>
                </form>
                <!-- 表单结束 --> 

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

<script>
//时间选择器
laydate.render({
  elem: '#end_date'
  ,type: 'datetime'
});
$('.back').click(function(){
    window.location.href="/admin/shalong/list";
})
  var clipArea = new bjj.PhotoClip("#clipArea", {
      size: [500, 380],// 截取框的宽和高组成的数组。默认值为[260,260]
      outputSize: [0, 0], // 输出图像的宽和高组成的数组。默认值为[0,0]，表示输出图像原始大小
      //outputType: "jpg", // 指定输出图片的类型，可选 "jpg" 和 "png" 两种种类型，默认为 "jpg"
      file: "#file", // 上传图片的<input type="file">控件的选择器或者DOM对象
      view: "#view", // 显示截取后图像的容器的选择器或者DOM对象
      ok: "#clipBtn", // 确认截图按钮的选择器或者DOM对象
      loadStart: function() {
        // 开始加载的回调函数。this指向 fileReader 对象，并将正在加载的 file 对象作为参数传入
        $('.cover-wrap').fadeIn();
        console.log("照片读取中");
      },
      loadComplete: function() {
        // 加载完成的回调函数。this指向图片对象，并将图片地址作为参数传入
        console.log("照片读取完成");
      },
      //loadError: function(event) {}, // 加载失败的回调函数。this指向 fileReader 对象，并将错误事件的 event 对象作为参数传入
      clipFinish: function(dataURL) {
        // 裁剪完成的回调函数。this指向图片对象，会将裁剪出的图像数据DataURL作为参数传入
        $('.cover-wrap').fadeOut();
        $('#view').css('background-size','100% 100%');
        if(dataURL){
          $('#imgURL').val(dataURL);
        }
      }
    });
$('.ok').click(function(){
  var imgURL = $('#imgURL').val();    //封面图
  var title = $('#wztitle').val();   //沙龙标题
  var person_num = $('#person_num').val();  //限额人数
  var end_date = $('#end_date').val();  //截止时间
  var price = $('#price').val();  //金额
  var content = ue.getContent();   //内容
  var price_type = $('input:radio:checked').val();   //报名方式
  var id = $('#edit_id').val();   //id
  var md_id = $('#md').val();   //门店id

  if(!title || !end_date ||!id) {
    layer.alert('标题和类型必填');
    return false;
  }
  $.post('/admin/shalong/update',{md_id:md_id,id:id,imgURL:imgURL,title:title,person_num:person_num,end_date:end_date,content:content,price:price,price_type:price_type},function(res){
      console.log(res);
          if(res.code == '1000'){
                layer.msg(res.msg);
                window.location.href="/admin/shalong/list";
            }else{
                layer.alert(res.msg);
            }
  })
})
</script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title','添加沙龙'); ?>
<?php $__env->startSection('sl','menu-open'); ?>
<?php $__env->startSection('sl2','active'); ?>
<?php $__env->startSection('all-sl','active'); ?>
<?php echo $__env->make('Public.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>