<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  <title><?php echo $shoname; ?></title>
  <link rel="shortcut icon" href="" />
        
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

  <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  <!--[if lt IE 9]>
  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->

  <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  <script type="text/javascript">
      window.sysinfo = {
        <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
        <?php if( !empty($_W['acid'])  ){ ?>'acid': '{$_W['acid']}',<?php } ?>
        <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
        <?php if( !empty($_W['uid']) ) {  ?>'uid': '{$_W['uid']}',<?php } ?>
        'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php  }else{  ?>0<?php } ?>,
        'siteroot': '{$_W['siteroot']}',
        'siteurl': '{$_W['siteurl']}',
        'attachurl': '{$_W['attachurl']}',
        'attachurl_local': '{$_W['attachurl_local']}',
        'attachurl_remote': '{$_W['attachurl_remote']}',
        'module': {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
        'cookie': {'pre': ''},
        'account': {:json_encode($_W['account'])},
      };
  </script>
		
  <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  <link href="/static/css/snailfish.css" rel="stylesheet">
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-header layui-elem-quote">当前位置：<span class="line-text"><?php if( !empty($item['id'])){ ?>编辑<?php  }else{  ?>添加<?php } ?>供应商 <small><?php if( !empty($item['id'])){ ?>修改【{$item['shopname']}】<?php } ?></small></span></div>
		<div class="layui-card-body" style="padding:15px;">

			<div class="page-content">
				<form action="" method='post' class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data">
					<input type="hidden" name="id" value="{$item['id']}">
					<div class="layui-form-item">
						<label class="layui-form-label must">供应商名称</label>
						<div class="layui-input-block">
							<input type="text" name="shopname" lay-verify="required" class="form-control" value="{$item['shopname']}"  />
							<span class='help-block'></span>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label must">店铺名称</label>
						<div class="layui-input-block">
							<input type="text" name="storename" lay-verify="required" class="form-control" value="{$item['storename']}"  />
							<span class='help-block'></span>
						</div>
					</div>
					
					<div class="layui-form-item">
						<label class="layui-form-label must">关联会员</label>
						
						<div class="layui-input-block">
							<div class="input-group " style="margin: 0;">
								<input type="text" disabled value="{$item['member_id']}" class="form-control valid" name="member_id" placeholder="" id="member_id" >
								
								<span class="input-group-btn">
									<span data-input="#member_id" id="chose_member_id"  class="btn btn-default">选择会员</span>	
								</span>
							</div>
							<?php if( !empty($saler) ){ ?>
							<div class="input-group " style="margin: 0;">
								<div class="layadmin-text-center choose_user">
									<img style="" src="{$saler['avatar']}">
									<div class="layadmin-maillist-img" style="">{$saler['nickname']}</div>
									<?php if(!empty($item['id'])){ ?>
									<?php }else{ ?>
									<button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this,'member_id')"><i class="layui-icon">&#xe640;</i></button>
									<?php } ?>
								</div>
							</div>
							<?php } ?>
						</div>
					</div>
					
					<div class="layui-form-item">
		                <label class="layui-form-label">供应商标志</label>
		                <div class="layui-input-block">
							{:tpl_form_field_image2('logo', $item['logo'])}
		                </div>
		            </div>
					 <div class="layui-form-item">
		                <label class="layui-form-label">店铺顶部图</label>
		                <div class="layui-input-block">
							{:tpl_form_field_image2('banner', $item['banner'])}
		                </div>
		            </div>
					<div class="layui-form-item">
						<label class="layui-form-label must">供应商联系人</label>
						<div class="layui-input-block">
							<input type="text" name="name" lay-verify="required" class="form-control" value="{$item['name']}"  />
							<span class='help-block'></span>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label must"> 供应商手机号</label>
						<div class="layui-input-block">
							<input type="text" name="mobile" class="form-control" value="{$item['mobile']}" data-rule-required="true"  />
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label must"> 产品</label>
						<div class="layui-input-block">
							<input type="text" name="product" class="form-control" value="{$item['product']}" readonly/>
						</div>
					</div>
					<?php if( $item['id'] == 0  ){ ?>
						<div class="layui-form-item">
							<label class="layui-form-label">是否审核</label>
							<div class="layui-input-block" >
								<input type="radio" name="state" value="1" <?php if( $item['state'] == 1 || !empty($item)){ ?>checked="true"<?php } ?> title="是" />
								<input type="radio" name="state" value="0" <?php if( $item['state'] == 0 && empty($item)){ ?>checked="true"<?php } ?> title="否" />
							</div>
						</div>
					<?php }else{ ?>

					<div class="layui-form-item">
						<label class="layui-form-label">是否审核</label>
						<div class="layui-input-block" style="padding-top: 6px;">
							<td>
										<?php if( $item['state'] == 0  ){ ?>
											<?php if( $item['goods_count'] <= 0 ){ ?>
											<p style="color: red; display:inline;padding-right: 15px;">待审核</p>
											<input type="hidden" name="state" value="0" />
												<a style="display:inline;" class='op layui-btn layui-btn-xs'  data-toggle="ajaxModal" href="javascript:;" data-href="{:U('supply/agent_check_first', array('id' => $item['id'],'type' => $item['type']   ))}" >
													
													<i class="icow icow-yibiaoji" style="color: #999;display: inline-block;vertical-align: middle" title="点击审核，选择供应商类型" ></i>
													&nbsp;通&nbsp;过&nbsp;

												</a>
											<?php }else{ ?>
												<input type="checkbox" name="" lay-filter="statewsitch" data-href="{:U('supply/agent_check', array('id'=>$item['id']))}" <?php if($item['state']==1){ ?>checked<?php } ?> lay-skin="switch" lay-text="启用|禁用">
											<?php } ?>
											<p style="color: red; display:inline;padding-right: 15px;"></p>
											
												<input type="checkbox" name="" lay-filter="statewsitchunable" data-href="{:U('supply/agent_check', array('id'=>$item['id']))}" <?php if($item['state']==1){ ?>checked<?php } ?> lay-skin="switch" lay-text="已拒绝|拒绝">

											
											
										<?php }else if( $item['state'] == 1 ){ ?>
											<p style="color: red; display:inline;padding-right: 15px;" >已通过</p>
											<input type="hidden" name="state" value="1" />
										<?php }else if( $item['state'] == 2 ){ ?>
												<p style="color: red; display:inline;padding-right: 15px;">已拒绝</p>
												<input type="hidden" name="state" value="2" />
											<a style="display:inline;" data-toggle="ajaxModal" href="javascript:;" data-href="{:U('supply/agent_check_first', array('id' => $item['id']))}" >
												<p style="color: blue;display:inline; ">重新审核</p>
											</a>
										<?php }else if( $item['state'] == 3 ){ ?>
												<p style="color: red; display:inline;padding-right: 15px;" >已通过</p>
												<input type="hidden" name="state" value="3" />
										<?php } ?>
        							</td>
						</div>
					</div>
					
					<?php } ?>
					
					
					<?php if( !empty($item['id']) ){ ?>
					<div class="layui-form-item">
						<label class="layui-form-label">供应商类型</label>
						<div class="layui-input-block" >
							<input type="radio" name="type"  disabled value="0" <?php if( $item['type'] == 0 || empty($item) ){ ?>checked="true"<?php } ?> title="平台供应商" />
							<input type="radio" name="type"  disabled value="1" <?php if( !empty($item) && $item['type'] == 1 ){ ?>checked="true"<?php } ?> title="独立供应商"  />
							<span class='help-block'>请根据需要的类型进行选择，供应商类型只能在供应商审核的时候选择一次，后续不可修改</span>
						</div>
						
					</div>
					<?php }else{ ?>
					<div class="layui-form-item">
						<label class="layui-form-label">供应商类型</label>
						<div class="layui-input-block" >
							<input type="radio" lay-filter="type" name="type" value="0" <?php if( $item['type'] == 0 || empty($item) ){ ?>checked="true" <?php } ?> title="平台供应商" />
							<input type="radio" lay-filter="type" name="type" value="1" <?php if( !empty($item) && $item['type'] == 1 ){ ?>checked="true" <?php } ?> title="独立供应商"  />
							<span class='help-block'>请根据需要的类型进行选择，供应商类型只能在供应商审核的时候选择一次，后续不可修改</span>
						</div>
					</div>
					<?php } ?>
					
					<?php if( $supply_is_open_mobilemanage == 1 ){ ?>
						<?php if( empty($item) || (!empty($item['id']) && $item['type'] == 1) ){ ?>
						<div class="layui-form-item" id="is_open_mobilemanage">
							<label class="layui-form-label">供应商手机端</label>
							<?php if( !empty($item['id']) ){ ?>
							<div class="layui-input-block" >
								<input type="radio" name="is_open_mobilemanage" value="0" <?php if( $item['is_open_mobilemanage'] == 0 || empty($item) ){ ?>checked="true" <?php } ?> title="关闭" />
								<input type="radio" name="is_open_mobilemanage" value="1" <?php if( !empty($item) && $item['is_open_mobilemanage'] == 1 ){ ?>checked="true" <?php } ?> title="开启"  />
							</div>
							<?php }else{ ?>
							<div class="layui-input-block" >
								<input type="radio" disabled="true" name="is_open_mobilemanage" value="0" <?php if( $item['is_open_mobilemanage'] == 0 || empty($item) ){ ?>checked="true" <?php } ?> title="关闭" />
								<input type="radio" disabled="true" name="is_open_mobilemanage" value="1" <?php if( !empty($item) && $item['is_open_mobilemanage'] == 1 ){ ?>checked="true" <?php } ?> title="开启"  />
							</div>
							<?php } ?>
							
						</div>
						<?php }?>
					<?php } ?>
					
					<div class="layui-form-item">
						<label class="layui-form-label must"> 技术服务费</label>
						<div class="layui-input-block">
							<input type="text" name="commiss_bili" class="form-control" value="{$item['commiss_bili']}" data-rule-required="true"  />
							<span class='help-block'>请填写百分比,例如：6  那么平台抽成是6%。实付金额的百分比，扣除此比例 再扣除团长佣金，剩余货款归供应商</span>
						</div>
					</div>
					
					<div class="layui-form-item" >
						<label class="layui-form-label">工商资质图片</label>
						<div class="layui-input-block">
							{:tpl_form_field_multi_image3('goods_industrial',$piclist)}
						</div>
					</div>
					
					<blockquote class="layui-elem-quote" style="margin-left: 80px;">登录信息</blockquote>
					<div class="layui-form-item">
						<label class="layui-form-label must">登录账户</label>
						<div class="layui-input-block">
							<input type="text" name="login_name" class="form-control" value="{$item['login_name']}"   />
							<span class='help-block'></span>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label must">登录密码</label>
						<div class="layui-input-block">
							<input type="text" name="login_password" class="form-control" value=""   />
							<span class='help-block'>留空则不修改密码</span>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label"></label>
						<div class="layui-input-block">
							<input type="submit" name="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary"  />
							
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<div id="ajaxModal" class="modal fade" style="display: none;">

</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '/layuiadmin/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use('index');
</script>

<script>
//由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
var layer = layui.layer;
var $;

layui.use(['jquery', 'layer','form','colorpicker'], function(){ 
  $ = layui.$;
  var form = layui.form;
  var colorpicker = layui.colorpicker;
 
  
   //表单赋值
    colorpicker.render({
      elem: '#minicolors'
      ,color: '{$data['nav_bg_color']}'
      ,done: function(color){
        $('#test-colorpicker-form-input').val(color);
      }
    });
	
	form.on('radio(linktype)', function(data){
		if (data.value == 1) {
			$('#is_open_mobilemanage').show();
		} else {
			$('#is_open_mobilemanage').hide();
		}
	}); 
	
	$('#chose_member_id').click(function(){
		cur_open_div = $(this).attr('data-input');
		$.post("{:U('user/zhenquery', array('ok' => 1))}", {}, function(shtml){
		 layer.open({
			type: 1,
			area: '930px',
			content: shtml //注意，如果str是object，那么需要字符拼接。
		  });
		});
	})
	
  //监听提交
  form.on('submit(formDemo)', function(data){
	
	 $.ajax({
		url: data.form.action,
		type: data.form.method,
		data: data.field,
		dataType:'json',
		success: function (info) {
		  
			if(info.status == 0)
			{
				layer.msg(info.result.message,{icon: 1,time: 2000});
			}else if(info.status == 1){
				var go_url = location.href;
				if( info.result.hasOwnProperty("url") )
				{
					go_url = info.result.url;
				}
				
				layer.msg('操作成功',{time: 1000,
					end:function(){
						var backurl = "{:U('supply/index',array('ok'=>'1'))}";
						location.href = backurl;
						// location.href = info.result.url;
					}
				}); 
			}
		}
	});
	
    return false;
  });
  
form.on('switch(statewsitchunable)', function(data){
      
      var s_url = $(this).attr('data-href')
      
      var s_value = 2;
      
      
      $.ajax({
            url:s_url,
            type:'post',
            dataType:'json',
            data:{state:s_value},
            success:function(info){
            
                if(info.status == 0)
                {
                    layer.msg(info.result.message,{icon: 1,time: 2000});
                }else if(info.status == 1){
                    var go_url = location.href;
                    if( info.result.hasOwnProperty("url") )
                    {
                        go_url = info.result.url;
                    }
                    
                    layer.msg('操作成功',{time: 1000,
                        end:function(){
                            location.href = info.result.url;
                        }
                    }); 
                }
            }
        })
    });  
  
 form.on('switch(statewsitch)', function(data){
      
      var s_url = $(this).attr('data-href')
      
      var s_value = 1;
      if(data.elem.checked)
      {
        s_value = 1;
      }else{
        s_value = 3;
      }
      
      $.ajax({
            url:s_url,
            type:'post',
            dataType:'json',
            data:{state:s_value},
            success:function(info){
            
                if(info.status == 3)
                {
                    layer.msg(info.result.message,{icon: 1,time: 2000});
                }else if(info.status == 1){
                    var go_url = location.href;
                    if( info.result.hasOwnProperty("url") )
                    {
                        go_url = info.result.url;
                    }
                    
                    layer.msg('操作成功',{time: 1000,
                        end:function(){
                            location.href = info.result.url;
                        }
                    }); 
                }
            }
        })
    });  
    form.on('checkbox(checkboxall)', function(data){
      if(data.elem.checked)
      {
        $("input[name=item_checkbox]").each(function() {
            $(this).prop("checked", true);
        });
        $("input[name=checkall]").each(function() {
            $(this).prop("checked", true);
        });
        
      }else{
        $("input[name=item_checkbox]").each(function() {
            $(this).prop("checked", false);
        });
        $("input[name=checkall]").each(function() {
            $(this).prop("checked", false);
        });
      }
      
      form.render('checkbox');
    });
  
})


   $("[data-toggle='ajaxModal']").click(function () {
        var s_url = $(this).attr('data-href');
		ajax_url = s_url;
		console.log(23);
       $.ajax({
				url:s_url,
				type:"get",
				success:function(shtml){
					$('#ajaxModal').html(shtml);
					$("#ajaxModal").modal();
				}	
		})
    });
	
	$(document).delegate(".modal-footer .btn-primary","click",function(){
		var s_data = $('#ajaxModal form').serialize();
		$.ajax({
			url:ajax_url,
			type:'post',
			dataType:'json',
			data:s_data,
			success:function(info){
				if(info.status == 0)
				{
					layer.msg(info.result.message,{icon: 1,time: 2000});
				}else if(info.status == 1){
					var go_url = location.href;
					if( info.result.hasOwnProperty("url") )
					{
						go_url = info.result.url;
					}
					
					layer.msg('操作成功',{time: 1000,
						end:function(){
							location.href = info.result.url;
						}
					}); 
				}
			}
		})
		return false;
	})
	

	

</script>  
</body>
</html>
