<!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">
   
   <script type="text/javascript" src="/static/js/dist/area/cascade.js"></script>
<script src="https://map.qq.com/api/js?v=2.exp&key=6R4BZ-WAB3W-JITRG-OE7GY-R2753-P3BZ2" type="text/javascript" charset="utf-8"></script>

</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['head_name']}】<?php } ?></small></span></div>
		<div class="layui-card-body" style="padding:15px;">
			<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">
						<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">
							
							<?php if(!empty($item['id'])){ ?>
							<span class="input-group-btn">
								<span class="btn btn-default">会员</span>	
							</span>
							<?php }else{ ?>
							<span class="input-group-btn">
								<span data-input="#member_id" id="chose_member_id"  class="btn btn-default">选择会员</span>	
							</span>
							<?php } ?>
							
						</div>
						<?php if( $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 must">上级团长</label>
					<div class="layui-input-block">
						<div class="input-group " style="margin: 0;">
							<input type="text" disabled value="{$agent_saler['member_id']}" class="form-control valid" name="agent_id" placeholder="" id="agent_id">
							<span class="input-group-btn">
								<span data-input="#agent_id" id="chose_agent_id"  class="btn btn-default">选择团长</span>
							</span>
						</div>
						<?php if( $agent_saler){ ?>
						<div class="input-group " style="margin: 0;">
							<div class="layadmin-text-center choose_user">
								<img style="" src="{$agent_saler['avatar']}">
								<div class="layadmin-maillist-img" style="">{$agent_saler['nickname']}</div>
								<button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this,'agent_id')"><i class="layui-icon">&#xe640;</i></button>
							</div>
						</div>
						<?php } ?>
					</div>
					
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label must">团长名称</label>
					<div class="layui-input-block">
						<input type="text" name="head_name" class="form-control" value="{$item['head_name']}" data-rule-required="true" />
						<span class='layui-form-mid'></span>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label must"> 团长手机号</label>
					<div class="layui-input-block">
						<input type="text" name="head_mobile" class="form-control" value="{$item['head_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="community_name" class="form-control" value="{$item['community_name']}"  data-rule-required="true" />
						<span class='layui-form-mid'></span>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label must">团长等级</label>
					<div class="layui-input-block">
						<select lay-ignore name="level_id">
							<?php foreach($level_id_to_name as $key => $val){ ?>
							<option value="<?php echo $key; ?>" <?php if( !empty($item) && $item['level_id'] == $key ){ ?>selected="true" <?php } ?>><?php echo $val; ?></option>
							<?php } ?>
						</select>
						<span class='layui-form-mid'></span>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label must">团长分组</label>
					<div class="layui-input-block">
						<select lay-ignore name="groupid">
							<?php foreach($keys_group as $key => $val){ ?>
							<option value="<?php echo $key; ?>" <?php if( !empty($item) && $item['groupid'] == $key ){ ?>selected="true" <?php } ?>><?php echo $val; ?></option>
							<?php } ?>
						</select>
						<span class='layui-form-mid'></span>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label must">地址</label>
					<div class="layui-input-block">
						<p>
							<select id="sel-provance" lay-ignore name="province_id" onChange="selectCity();"  style="width:130px;display:inline;">
								<option value="" selected="true">省/直辖市</option>
							</select>
							<select id="sel-city" lay-ignore name="city_id" onChange="selectcounty(0)"  style="width:135px;display:inline;">
								<option value="" selected="true">请选择</option>
							</select>
							<select id="sel-area" lay-ignore name="area_id" onChange="selectstreet(0)" style="width:130px;display:inline;">
								<option value="" selected="true">请选择</option>
							</select>
							 <select id="sel-street" lay-ignore name="country_id" style="width:130px;display:inline;">
								<option value="" selected="true">请选择</option>
							</select>
						</p>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label must"> 提货详细地址</label>
					<div class="layui-input-block">
						<div class="dEdit_1">
							<div class="layui-inline">
								
								<div class="layui-input-inline" style="width: 200px;">
									<input type="text" style="width: 200px;" name="address" id="address"  data-val="true" data-val-required="请填写社区店所在详细地址" class="form-control" value="{$item['address']}" data-rule-required="true"  />
								</div>
								<div class="layui-input-inline" style="width: 100px;">
									<a class="btn btn-default" id="js_search_pos" onclick="getResult()">搜索地图</a>
								</div>
								<br />
								<div class="layui-form-mid layui-word-aux">地图搜索以后，请点击地图定位进行标记坐标，经纬度出来以后在进行保存，以防设置失效。</div>
							</div>
							
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label must"> 经纬度</label>
					<div class="layui-input-block">
						<div class="dEdit_1">
							<div class="layui-inline">
								
								<div class="layui-input-inline" style="width: 100px;">
									<input class="form-control input-sm" data-val="true"   id="lon" name="lon"  type="text" value="{$item['lon']}">
								</div>
								
								<div class="layui-input-inline" style="width: 100px;">
									<input class="form-control input-sm" data-val="true" id="lat" name="lat"  type="text" value="{$item['lat']}">
								</div>
							</div>
  
						</div>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label must"> 地图定位</label>
					<div class="layui-input-block">
						<div class="map-box" id="container" style="width: 603px; height: 300px; float: left;"></div>
						<div class="des" id="map_des" style="display: none; float: left;">请选择一个地址并点击地图中的“导入经纬度”</div>
						<div class="info-box" id="infoDiv" style="display: none"></div>
					</div>
				</div>
				
				<?php if( $item['id'] == 0  ){ ?>
				
				<div class="layui-form-item">
					<label class="layui-form-label">申请状态</label>
					<div class="layui-input-block" >
						
						<label class="radio-inline coupon-radio">
							<input type="radio" name="state" value="1" <?php if( $item['state'] == 1 || empty($item)){ ?>checked="true"<?php } ?> title="通过"  /> 
						</label>
						<label class="radio-inline coupon-radio">
							<input type="radio" name="state" value="0" <?php if( $item['state'] == 0 && !empty($item)){ ?>checked="true"<?php } ?> title="未审核" /> 
						</label>
						<label class="radio-inline coupon-radio">
							<input type="radio" name="state" value="2" <?php if( $item['state'] == 2 && !empty($item)){ ?>checked="true"<?php } ?> title="已拒绝" /> 
						</label>
						
					</div>
				</div>
				
				<?php }else{ ?>
				
				<div class="layui-form-item">
					<label class="layui-form-label">申请状态</label>
					<div class="layui-input-block" style="top:5px ">
						
						<td>
										<?php if( $item['state'] == 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('communityhead/agent_check_first', array('id' => $item['id']))}" >
													
													<i class="icow icow-yibiaoji" style="color: #999;display: inline-block;vertical-align: middle" title="点击审核，选择供应商类型" ></i>
													&nbsp;通&nbsp;过&nbsp;

												</a>
											
											<p style="color: red; display:inline;padding-right: 15px;"></p>
											
												<input type="checkbox" name="" lay-filter="statewsitchunable" data-href="{:U('communityhead/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; 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('communityhead/agent_check_first', array('id' => $item['id']))}" >
												<p style="color: blue;display:inline; ">重新审核</p>
											</a>
										<?php } ?>
        							</td>
						
					</div>
				</div>
				
				<?php } ?>
				
				
				<div class="layui-form-item">
					<label class="layui-form-label must"> {$wechat_div}</label>
					<div class="layui-input-block">
						<input type="text" name="wechat" class="form-control" value="{$item['wechat']}"/>
						<span class='layui-form-mid'></span>
					<!--
					<?php if( !empty($item['wechat']) ){ ?>
						<span class='layui-form-mid'>{$item['wechat']}</span>
					
					<?php }else{ ?>
						<span class='layui-form-mid'>后台添加</span>
					<?php } ?>-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label ">银行卡名称</label>
					<div class="layui-input-block">
						<input type="text" name="bankname"  class="form-control" value="{$item['bankname']}"   />
						<span class='layui-form-mid'>例如农行、微信、支付宝，需有关联会员此处设置才有效</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label ">卡号</label>
					<div class="layui-input-block">
						<input type="text" name="bankaccount"  class="form-control" value="{$item['bankaccount']}"   />
						<span class='layui-form-mid'>需有关联会员此处设置才有效</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label ">持卡人姓名</label>
					<div class="layui-input-block">
						<input type="text" name="bankusername"  class="form-control" value="{$item['bankusername']}"   />
						<span class='layui-form-mid'>需有关联会员此处设置才有效</span>
					</div>
				</div>
				
				
				<div class="layui-form-item">
					<label class="layui-form-label">分享群图片</label>
					<div class="layui-input-block">
						{:tpl_form_field_image2('share_wxcode', $item['share_wxcode'])}
						<span class='layui-form-mid'>提示：带群或微信二维码的引导图</span>
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label"> </label>
					<div class="layui-input-block">
						<input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary"  />
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
					</div>
				</div>
			</form>
		</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 $;

var cur_open_div;

layui.use(['jquery', 'layer','form'], function(){ 
  $ = layui.$;
  var form = layui.form;
  
	form.on('radio(linktype)', function(data){
		if (data.value == 2) {
			$('#typeGroup').show();
		} else {
			$('#typeGroup').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，那么需要字符拼接。
		  });
		});
	})
	$('#chose_agent_id').click(function(){
		cur_open_div = $(this).attr('data-input');
		$.post("{:U('communityhead/query_head_user_agent', array('ok' => 1))}", {}, function(shtml){
		 layer.open({
			type: 1,
			area: '930px',
			content: shtml //注意，如果str是object，那么需要字符拼接。
		  });
		});
	})
	$('#chose_link').click(function(){
		cur_open_div = $(this).attr('data-input');
		$.post("{:U('util.selecturl', array('ok' => 1))}", {}, function(shtml){
		 layer.open({
			type: 1,
			area: '930px',
			content: shtml //注意，如果str是object，那么需要字符拼接。
		  });
		});
	})
	
		
  //监听提交
  form.on('submit(formDemo)', function(data){
	var loadingIndex = layer.load(); // 加载中动画遮罩层（1）
	
	 $.ajax({
		url: data.form.action,
		type: data.form.method,
		data: data.field,
		dataType:'json',
		success: function (info) {
			layer.close(loadingIndex); // 提交成功失败都需要关闭
			if(info.status == 0)
			{
				layer.msg(info.result.message,{icon: 1,time: 2000});
				can_sub = true;
			}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('communityhead/index',array('ok'=>'1'))}";
						location.href = backurl;
						// location.href = info.result.url;
					}
				}); 
				can_sub = true;
			}
		}
	});
	
    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;
	})


function cancle_bind(obj,sdiv)
{
	$('#'+sdiv).val('');
	$(obj).parent().parent().remove();
}

</script> 

<script>
var map, searchService, marker, markers = [], infoWin = null;
var initMap = function () {
	<?php if( !empty($item['lat']) ){ ?>
		var center = new qq.maps.LatLng({$item['lat']},{$item['lon']});
	<?php }else{?>
		var center = new qq.maps.LatLng(39.916527, 116.397128);
	<?php }?>
    map = new qq.maps.Map(document.getElementById('container'), {
        center: center,
        zoom: 13
    });
    var scaleControl = new qq.maps.ScaleControl({
        align: qq.maps.ALIGN.BOTTOM_LEFT,
        margin: qq.maps.Size(85, 15),
        map: map
    });
    //调用Poi检索类
    searchService = new qq.maps.SearchService({
        //检索成功的回调函数
        complete: function (results) {
            //设置回调函数参数
            var pois = results.detail.pois;
            infoWin = new qq.maps.InfoWindow({
                map: map
            });
            var latlngBounds = new qq.maps.LatLngBounds();
            for (var i = 0, l = pois.length; i < l; i++) {
                var poi = pois[i];
                //扩展边界范围，用来包含搜索到的Poi点
                latlngBounds.extend(poi.latLng);
                (function (n) {
                    var marker = new qq.maps.Marker({
                        map: map
                    });
                    marker.setPosition(pois[n].latLng);
                    markers.push(marker);
                    qq.maps.event.addListener(marker, 'click', function () {
                        infoWin.open();
                        infoWin.setContent('<div style = "width:200px;padding:10px 0;">' + pois[n].address + '<div class="map-import-btn"><input type="button" class="btn btn-xs btn-primary" value="导入经纬度" onclick="chooseShopLoc(this);" address=' + pois[n].address + ' lat =' + pois[n].latLng.getLat() + '  lng =' + pois[n].latLng.getLng() + ' /></div></div>');
                        infoWin.setPosition(pois[n].latLng);
                    });
                })(i);
            }
            //调整地图视野
            map.fitBounds(latlngBounds);
        },
        //若服务请求失败，则运行以下函数
        error: function () {
            alert("很抱歉，未搜索到此地址，请重新输入！");
        }
    });
}
function getSelectArea() {
    var storeArr = [];
    var s_province = $('#sel-provance').val();
    var s_city = $('#sel-city').val();
    var s_area = $('#sel-area').val();
    var s_street = $('#sel-street').val();
    
    if('请选择省份' != s_province)
    {
    	storeArr.push(s_province);
    }
    if('请选择城市' != s_city)
    {
    	storeArr.push(s_city);
    }
    if('请选择区域' != s_area)
    {
    	storeArr.push(s_area);
    }
    if('请选择街道/镇' != s_street && '' != s_street)
    {
    	storeArr.push(s_street);
    }
    
    
    $("#area-selector select").each(function (i) {
        if ($(this).find("option:selected").text() != '请选择') {
            storeArr.push($(this).find("option:selected").text());
        }
    });
    return storeArr;
}
//查询社区信息
function chooseShopLoc(t) {
    var address = $(t).attr("address");
    var storeAreaArr = getSelectArea();
    
    for (var i = 3; i >= 0; i--) {
        if (i == 0)
        {
            address = address.replace(storeAreaArr[0] + "市", '');
        }
        address = address.replace(storeAreaArr[i], '');
    }
    var lat = $(t).attr("lat");
    var lng = $(t).attr("lng");
    this.clearMarkers();
    var position = new qq.maps.LatLng(lat, lng);
    marker = new qq.maps.Marker({
        map: map,
        position: position,
        draggable: true
    });
    map.panTo(position);
    map.zoomTo(18);
    $("#lon").val(lng);
    $("#lat").val(lat);
    qq.maps.event.addListener(marker, 'dragend', function () {
        if (marker.getPosition()) {
            $("#lon").val(marker.getPosition().getLng());
            $("#lat").val(marker.getPosition().getLat());
        }
    });   
    if (infoWin) {
        infoWin.close();
    }
    $("#map_des").hide();
}
////删除所有标记
function clearMarkers() {
    if (markers) {
        for (i = 0; i < markers.length; i++) {
            markers[i].setMap(null);
        }
        markers.length = 0;
    }
}

//搜索地址，这里需要判断是否选择了省市区
function getResult() {
    if ($.trim($("#sel-provance").val()) == '请选择省份') {
		layer.msg('请选择正确的省市区街道',{icon: 1,time: 2000});
        return;
    }
    if ($("#AddressId").val() <= 0) {
       // $.dialog.tips("请先选择店铺地址");
        return;
    }
    if ($.trim($("#address").val()).length == 0) {
        //tip.msgbox.err('请先输入详细地址');
		layer.msg('请先输入详细地址',{icon: 1,time: 2000});
        return;
    }
    if (marker != null) marker.setMap(null);
    clearMarkers();
    if (infoWin) {
        infoWin.close();
    }
    var storeArr = getSelectArea();
    var regions = storeArr[0] + storeArr[1] + storeArr[2];
    var regionText = storeArr.join(',');
    var poiText = regions + $.trim($("#address").val());
    searchService.setLocation(regionText);
    searchService.search(poiText);
    $("#map_des").show();
}

</script>
<script language='javascript'>
	$(function(){
	    cascdeInit("1","1","{$item['province_name']}","{$item['city_name']}","{$item['area_name']}","{$item['country_name']}");
	    initMap();//初始化门店地图
	});
      require(['bootstrap'],function(){
             $('#myTab a').click(function (e) {
                 e.preventDefault();
                $('#tab').val( $(this).attr('href'));
                 $(this).tab('show');
             })
     });

    function showbacktype(type){

        $('.backtype').hide();
        $('.backtype' + type).show();
    }
	$(function(){

		

	})
</script> 
</body>



