
 <!doctype html>
  <html class="no-js">
  <head>

    <include file="Common/head" />
    <style type="text/css">
      .am-form{width:500px;margin-left:20px;float: left;}
      #editor {font-size: 12px;}
      .am-form label span{font-size: 13px;font-weight:normal;}
      .am-form label p{display: inline;color: #f00;}
      .am-form .am-form-inline-2 input[type=file]{width: 246px}
      .am-form .am-form-inline-3 input[type=text]{width: 160px}
      .am-form .am-form-inline-3 select{width: 160px}
      .am-form .am-form-inline-4 input[type=text]{width: 120px}
      .am-form .am-form-inline-4 select{width: 120px}
      .two-input {display: flex;}
      .am-form .am-form-inline-4 .two-input input[type=text]{width: 50px;}
      .am-form .am-form-inline-4 .two-input input[type=text]:nth-of-type(2){width: 20px;padding: 8px 2px;cursor: default;background: #fff; border-left: 0; border-right: 0;}

      .am-form input[type=file]{display:none;}
      .am-form .am-form-group img{height: 60px;min-width: 60px;max-width: 100px;margin-top: 2px;display: block;cursor: pointer;}
      input[readonly]{background-color: #fff!important;cursor: default!important;}
      .am-form-group input{
        height: 30px;font-size: 14px;margin-bottom: 10px !important;
      }
      .am-form-group select{
        height: 30px;font-size: 14px;margin-bottom: 10px !important;
      }
    </style>
  </head>
  <body>
  <include file="Common/header" />

  <div class="am-cf admin">

    <include file="Common/sidebar" nav="goods" navv="goods"/>
    <div class="content-page" style="background: white;">

      <div class="admin-content" style="background: white;">
        <div class="admin-content-body">
          <div class="am-cf am-padding">
            <div class="am-fl am-cf">
              <strong class="am-text-primary am-text-lg">商品管理</strong> /
              <small>商品列表 / <?php echo $_GET['id']?"编辑":"新增"; ?></small>
            </div>
          </div>
          <hr style="margin-top:0px;">
          <form action="" method="POST" id="saveForm" enctype="multipart/form-data">
            <div class="am-form">
              <input type="hidden" name="op" value="save" />
              <input type="hidden" name="id" value="{$goods.id}" />
              <div class="am-form-group am-form-inline">
                <div class="am-form-group">
                  <label>排序<span>（数字越大排序越靠前）</span></label>
                  <input type="text" name="seat_no" data-type="zs" value="{$goods.seat_no}">
                </div>
                <div class="am-form-group" style="margin-left:10px;">
                  <label >上下架</label>
                  <div class="tttt-switch" style="margin:4px 14px;">
                    <input type="checkbox" name="status" <?php if($goods[status]) echo "checked";?>>
                    <span class="tttt-switch-btn"></span>
                  </div>
                  <input type="hidden" name="old_status" value="<?php echo $goods[status]?:0;?>">
                </div>


                <!-- <div class="am-form-group" style="margin-left:10px;float: right;">
                  <label style="margin-left: 38px">推荐</label>
                  <div class="ttt-switch" style="margin:4px 14px;">
                    <input type="checkbox" name="home_show" <?php if($goods['home_show']) echo "checked";?>>
                    <span class="ttt-switch-btn"></span>
                  </div>
                </div> -->
              </div>
              <div class="am-form-group am-form-inline">

                <div class="am-form-group" style="width:220px;">
                  <label>商品名称 <p>*</p></label>
                  <input type="text" name="title" value="{$goods.title}">
                </div>
                <div class="am-form-group" style="width:150px;">
                  <label>商品编号 </label>
                  <input type="text" name="model" value="{$goods.model}">
                </div>
                <script type="text/javascript">
                    $("#img_preview").on('click',function(){
                        $("input[name=img]").click();
                    });
                    $("input[name=img]").on('change', function() {
                        var reader = new FileReader();
                        reader.onload = function(e){
                            $('#img_preview').attr('src', e.target.result);
                        }
                        if(this.files[0]){
                            reader.readAsDataURL(this.files[0]);
                        }else{
                            $('#img_preview').attr('src','');
                        }
                    });
                </script>
              </div>
              <div class="am-form-group am-form-inline">
                <!--<div class="am-form-group" style="width: 310px;">-->
                  <!--<label>商品副名称<span>（用于商品搜索）</span></label>-->
                  <!--<input type="text" name="title2" value="{$goods.title2}">-->
                <!--</div>-->
                <!-- <div class="am-form-group">
                  <label>品牌</label>
                  <input type="text" name="brand" value="{$goods.brand}">
                </div> -->
              </div>

              <div class="am-form-group am-form-inline am-form-inline-4">
                <!-- <div class="am-form-group">
                  <label>首周价格 <p>*</p></label>
                  <input type="text" name="price" data-type="xs" value="{$goods.price}">
                </div> -->
                <!-- <div class="am-form-group">
                  <label>续租价格 <p>*</p></label>
                  <input type="text" name="price2" data-type="xs" value="{$goods.price2}">
                </div> -->
                <!--<div class="am-form-group">-->
                  <!--<label>进货价</label>-->
                  <!--<input type="text" name="buy_price" data-type="xs" value="{$goods.buy_price}" style="width: 130px;">-->
                <!--</div>-->
                <!--<div class="am-form-group">-->
                  <!--<label>原价<p>*</p></label>-->
                  <!--<input type="text" name="orig_price" data-type="xs" value="{$goods.orig_price}" style="width: 130px;">-->
                <!--</div>-->
                <div class="am-form-group" >
                  <label>售价<p>*</p></label>
                  <input type="text" name="price" data-type="xs" value="{$goods.price}" style="width: 220px" >
                </div>
                <div class="am-form-group">
                  <label>虚拟销量 </label>
                  <input type="text" name="false_sell" value="{$goods.false_sell}" style="width:150px;">
                </div>
                <!--<div class="am-form-group">-->
                  <!--<label>商品单位名称<p>*</p></label>-->
                  <!--<input type="text" name="unit"  value="{$goods.unit}" style="width: 130px;">-->
                <!--</div>-->
                <!--<div class="am-form-group">-->
                  <!--<label>商品属性<p>*</p></label>-->
                  <!--<select name="is_hot" style="width: 130px;">-->
                    <!--<option value="0">正常</option>-->
                    <!--<option value="1">特价</option>-->
                    <!--<option value="2">新品</option>-->
                  <!--</select>-->
                <!--</div>-->
                <!--<div class="am-form-group">-->
                  <!--<label>最大下单数量</label>-->
                  <!--<input type="text" name="max_buy" data-type="xs" placeholder="特价商品时填写" style="height: 30px;font-size: 14px;" value="{$goods.max_buy}" style="width: 130px;">-->
                <!--</div>-->
              </div>
              <div class="am-form-group am-form-inline am-form-inline-4">

                <!--<div class="am-form-group">-->
                  <!--<label>库存</label>-->
                  <!--<input type="text" name="total" value="{$goods.total}">-->
                  <!--&lt;!&ndash; <input type="text" data-type="zzs" value="{$goods.total}" readonly onclick="layer.msg('请在右下角添加供应记录')"> &ndash;&gt;-->
                <!--</div>-->



              </div>
              <div class="am-form-group am-form-inline am-form-inline-4"    >
                <div class="am-form-group">
                  <label>所属分类 <p>*</p></label>
                  <select id="one" name="cat_id1" style="width: 150px;">
                    <option value="">请选择一级分类</option>}
                    <?php foreach($one as $i=>$val){?>
                    <option value="<?php echo $val['id'] ?>" <?php if($val['id']==$goods['cat_id1']){?> selected="selected" <?php } ?> ><?php echo $val['title'] ?></option>}
                    <?php } ?>
                  </select>
                </div>
            </div>

            <div class="am-form-group am-form-inline am-form-inline-4"    >
                <div class="am-form-group">
                  <label>商品数量购买限制（PS:0表示没有购买限制） </label>
                  <input type="text" name="max_buy" value="{$goods.max_buy}" style="width:150px;">
                </div>
            </div>


              <div class="am-form-group am-form-inline am-form-inline-2">
                <label>商品图片 </label>
                <div class="am-form-group">
                  <img src="" id="img_preview" onerror="this.src='<?php echo $goods[img]?:'__PUBLIC__/img/add.png'?>'">
                  <input type="file" name="img" value="" accept="image/jpg,image/jpeg,image/png">
                </div>

              </div>
            <div class="am-form-group am-form-inline am-form-inline-2">

                <label>商品描述</label>
                <textarea class="" NAME="content"  rows="5" id="doc-ta-1"><?php echo $goods[content];?></textarea>

            </div>
              <button type="submit" class="am-btn am-btn-success" id="form_submit" style="margin-bottom: 50px;">保存</button>
            </div>
          </form>
        </div>
        <footer class="admin-content-footer"><hr></footer>
        <script type="text/javascript">
            $("#img_preview").on('click',function(){
                $("input[name=img]").click();
            });
            $("input[name=img]").on('change', function() {
                var reader = new FileReader();
                reader.onload = function(e){
                    $('#img_preview').attr('src', e.target.result);
                }
                if(this.files[0]){
                    reader.readAsDataURL(this.files[0]);
                }else{
                    $('#img_preview').attr('src','');
                }
            });
        </script>


      </div>

    </div>



  </div>
  <include file="Common/footer" />
  <script type="text/javascript">
      $(function(){
          // 重置密码
          $(".reset_link").on("click",function(){
              var id=$(this).attr('data-id');
              var name=$(this).attr("data-name");
              var bool = confirm("确认重置管理员“"+name+"”的密码吗？");
              if (bool) {
                  $("#float_id").val(id);
                  $("#float_name").html(name);
                  $("#shade_div").show();
                  $("#float_div").show();
              };
          });
          $("#btclose").on("click",function(){
              $("#shade_div").hide();
              $("#float_div").hide();
          });
          // 删除
          $(".del_link").on("click",function(){
              var name=$(this).attr("data-name");
              var the_link=$(this).attr("data-url");
              var bool = confirm("确认删除管理员“"+name+"”吗？");
              if (bool) {
                  location.href = the_link;
              };
          });
      });
  </script>
  </body>


  </html>