<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>私塾家</title>
<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
<script th:include="sys/common/metaJS" th:remove="tag"></script> 
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/js/city/city.json.js}"></script>
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/js/city/citySetMe_V.js}"></script>
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/js/city/Popt.js}"></script>
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
</head>
 <style type="text/css">
   body{min-width:180px;}
       .select1{
   		    width:100%;
		    height: 32px;
		    line-height: 32px;
		    border-top: solid 1px #a7b5bc;
		    border-left: solid 1px #a7b5bc;
		    border-right: solid 1px #ced9df;
		    border-bottom: solid 1px #ced9df;
		    opacity:1;
	        margin-bottom: 10px;
    	}
    	.btn{
    	  width: 100px;
    	}
     label.control-label-error {color: Red;}	
     
._citys {     background-color: whitesmoke;width: 450px; display: inline-block; border: 2px solid #eee; padding: 5px; position: relative; }
._citys span { color: #05920a; height: 15px; width: 15px; line-height: 15px; text-align: center; border-radius: 3px; position: absolute; right: 10px; top: 10px; border: 1px solid #05920a; cursor: pointer; }
._citys0 { width: 95%; height: 34px; line-height: 34px; display: inline-block; border-bottom: 2px solid #05920a; padding: 0px 5px; font-size:14px; font-weight:bold; margin-left:6px; }
._citys0 li { display: inline-block; line-height: 34px; font-size: 15px; color: #888; width: 80px; text-align: center; cursor: pointer; }
._citys1 { width: 100%; display: inline-block; padding: 10px 0; }
._citys1 a { width: 83px; height: 35px; display: inline-block; background-color: #f5f5f5; color: #666; margin-left: 6px; margin-top: 3px; line-height: 35px; text-align: center; cursor: pointer; font-size: 12px; border-radius: 5px; overflow: hidden; }
._citys1 a:hover { color: #fff; background-color: #05920a; }
.AreaS { background-color: #05920a !important; color: #fff !important; }
#school{
	margin-left: 110px;
	padding-bottom: 10px;
}  
#school span{
  	min-width: 25%;
    float: left;
    margin-bottom: 10px;
}
.joinseachform li{
	width: 50%;
	margin-right: 0px;
	padding-right: 0px;
}

.schoolseachform li{
	width: 50%;
	margin-right: 0px;
	padding-right: 0px;
}    

dtext{
	color: red;
	cursor: pointer;
}
.forminfo li label{
	width: 200px;
	text-align: right;
	padding-right: 10px
}
  
</style>
<body>

<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">商户建立</a></li>
		<li><a href="#">端口商户建立</a></li>
	</ul>
</div>

<div class="formbody">
		<ul class="forminfo" style="min-width: 830px;">
			<li style="margin-bottom: 20px">
				<label>商户账号：<b>*</b></label>
				<input autocomplete="off"  th:if="${merchant.id==null}" type="text" id="poscode" class="dfinput fl" name="poscode" style="float: left;" th:value="${merchant.posCode}" placeholder=" 请输入端口商户账号，由字母或数字组成" />
				<input autocomplete="off"  th:if="${merchant.id!=null}" disabled="disabled" type="text" id="poscode" class="dfinput fl" name="poscode" style="float: left;" th:value="${merchant.posCode}"   />
				<br/>
			</li>
			<li th:if="${merchant.id==null}" style="margin-bottom: 20px">
				<label>初始密码：<b>*</b></label>
				<input type="text" id="password" class="dfinput fl" name="password"  style="float: left;" value="00000000" autocomplete="off" placeholder=" 输入端口商户密码，默认：00000000" />
				
				<br/>
			</li>
			<li>
				<label>商户名称：合作名称/合作校区：<b>*</b></label>
				<input type="text" id="unitname" class="dfinput fl" name="unitname" th:value="${merchant.unitName}" autocomplete="off"  placeholder=" 请输入端口商户名称" />
			</li>
			
			<li id="location_wrap" >
				<label th:if="${merchant.location==null || merchant.location==''}">商户区域：<b>*</b></label>
				<label th:if="${merchant.location!=null && merchant.location!=''}">修改区域：<b>*</b></label>
				<div class="wrap">
					<div class="vocation" style="margin-right: 5px; width: 100px">
						<select name="province" id="province" class="select1" onchange="funcprovince()"> 
							<option data-type="1" value="" >选择省</option>
						</select>
					</div>
					
					<div class="vocation" style="margin-right: 5px; width: 100px">
						<select name="city" id="city" class="select1" onchange="funccity()">
							<option data-type="2" value="" >选择市</option>
						</select>
					</div>
					
					<div class="vocation" style="margin-right: 5px; width: 100px">
						<select name="area" id="area" class="select1" onchange="funcarea()">
							<option data-type="3" value="" >选择区</option>
						</select>
					</div>
					
					<div class="vocation" style="margin-right: 5px; width: 130px">
						<input name="libId" id="libId" class="select1"  type="text" autocomplete="off" onfocus="funcblurlibId()" placeholder=" 请选择绑定机构" >
						<input name="radiolibId" id="radiolibId"  type="hidden" >
					</div>
					
					<div class="vocation" style="margin-right: 5px; width: 130px">
						<input name="schooltext" id="schooltext" class="select1" autocomplete="off" type="text" onfocus="funcblurschooltext()"  placeholder=" 请选择绑定学校"  >
					</div>
					
				</div>
			</li>

			
			<li>
				<label>套餐：套餐类型：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 345px">
					<select name="mealType" id="mealType" class="select1"  > 
						<option value="1" th:selected="${merchant.mealType==1 ? true : false}">优选套餐</option>
						<option value="2" th:selected="${merchant.mealType==2 ? true : false}">VIP套餐</option>
						<option value="3" th:selected="${merchant.mealType==3 ? true : false}">尊享套餐</option>
					</select>
				</div>
			</li>
			
			<li>
				<label>合同日期：<b >*</b></label>
				<input type="hidden"  id="minDate" value="2020-01-01" >
				<input type="text" id="signTime" name="signTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'minDate\')}'})" autocomplete="off" th:value="${#dates.format(merchant.signTime, 'yyyy-MM-dd')}" class="scinput date_width " placeholder="合同开始日期">
				&nbsp;&nbsp;&nbsp;~~&nbsp;&nbsp;
				<input type="text" id="endSignTime" name="endSignTime"   onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'signTime\')}'})"  autocomplete="off" th:value="${#dates.format(merchant.endSignTime, 'yyyy-MM-dd')}" class="scinput date_width" placeholder="合同结束日期">
			</li>
			
			<li>
				<label>激活开始日期：<b >*</b></label>
				<input type="text"  class="dfinput fl"  id="startActiveTime" name="startActiveTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" autocomplete="off" th:value="${#dates.format(merchant.startActiveTime, 'yyyy-MM-dd')}" placeholder="合同开始激活日期">
			</li>
			<li>
				<label>激活结束日期：<b >*</b></label>
				<input type="text"  class="dfinput fl"  id="activeTime" name="activeTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" autocomplete="off" th:value="${#dates.format(merchant.activeTime, 'yyyy-MM-dd')}" placeholder="合同结束激活日期">
			</li>
			
			<li th:style="${merchant.computeTime==null ? 'display: none' : ''}">
				<label>计费开始日期：<b >*</b></label>
				<input type="text"  class="dfinput fl"  id="computeTime" name="computeTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" autocomplete="off" th:value="${#dates.format(merchant.computeTime, 'yyyy-MM-dd')}" placeholder="计费开始日期">
			</li>
			
			<li style="display: none">
				<label>上级渠道：<b >*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 345px">
					<select name="parentposcode" id="parentposcode" class="select1" th:disabled="${merchant.id!=null || curMerchant.orgCode ne 'SSJ-FX' ? 'true' : 'false'}" > 
						<option th:each="item:${poslist}" th:selected="${merchant.id==null ?  (item.posCode  eq 'ssj001' ? true : false) : (merchant.parentPosCode  eq item.posCode ? true : false)}" th:if="${item.orgCode ne 'SSJ-FX' && #strings.contains(item.orgCode,curMerchant.orgCode) }" th:data-orgcode="${item.orgCode}" th:data-id="${item.id}" th:value="${item.posCode}" th:text="${item.unitName}+' ['+${item.posCode}+']'"></option>
					</select>
				</div>
			</li>

			<li style="display: none">
				<label>商户级别：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 345px">
					<select name="level" id="level" class="select1"> 
						<option value="4" th:selected="${merchant.level==4 ? true : false}">普通</option>
						<option value="1" th:selected="${merchant.level==1 ? true : false}">市代</option>
						<option value="2" th:selected="${merchant.level==2 ? true : false}">区代</option>
						<option value="3" th:selected="${merchant.level==3 ? true : false}">学校独家</option>
					</select>
				</div>
			</li>

			<li>
				<label>商户类型：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 345px">
					<select name="type" id="type" class="select1"> 
						<option value="5" th:selected="${merchant.type==5 ? true : false}">直接签约（端口模式）</option>
<!-- 						<option value="1" th:selected="${merchant.type==1 ? true : false}">直接签约(旧模式)</option> -->
						<option value="2" th:selected="${merchant.type==2 ? true : false}">内部消耗</option>
						<option value="3" th:selected="${merchant.type==3 ? true : false}">外部签约</option>
						<option value="4" th:selected="${merchant.type==4 ? true : false}">内部不结算（财务）</option>
<!-- 						<option value="6" th:selected="${merchant.type==6 ? true : false}">旧转新(新不结算)</option> -->
<!-- 						<option value="7" th:selected="${merchant.type==7 ? true : false}">旧转新(新旧不结算)</option> -->
					</select>
				</div>
			</li>

			 <li style="display: none;">
				<label>签约状态：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 345px">
					<select name="status" id="status" class="select1"> 
						<option value="3" th:selected="${merchant.status==3 ? true : false}">已签已交付</option>
						<option value="1" th:selected="${merchant.status==1 ? true : false}">待签</option>
						<option value="2" th:selected="${merchant.status==2 ? true : false}">已签待交付</option>
					</select>
				</div>
			</li>
				
			<li style="display: none">
				<label>签约数量（练习册用）：<b></b></label>
				<input type="text" id="signService" class="dfinput fl" name="signService" th:value="${merchant.signService!=null ? merchant.signService : 0}" autocomplete="off"/>
			</li>
			
			<li style="display: none">
				<label>合同硬件采购数量：<b></b></label>
				<input type="text" id="hardwareService" class="dfinput fl" name="hardwareService" th:value="${merchant.hardwareService!=null ? merchant.hardwareService : 0}" autocomplete="off"/>
			</li>
			
			<li style="display: none">
				<label>硬件：签约单价：<b></b></label>
				<input type="number" id="hardwarePrice" class="dfinput fl" name="hardwarePrice" th:value="${merchant.hardwarePrice==null ? 0 : merchant.hardwarePrice }" autocomplete="off" placeholder=" 请输入硬件：签约单价" />
			</li>
			
			
			<li>
				<label>甲方签约人 ：<b></b></label>
				<input type="text" id="signerPerson" class="dfinput fl" name="signerPerson" th:value="${merchant.signerPerson}" autocomplete="off" placeholder=" 请输入甲方签约人"/>
			</li>
			
			<li>
				<label>合同编号 ：<b></b></label>
				<input type="text" id="contractNo" class="dfinput fl" name="contractNo" th:value="${merchant.contractNo}" autocomplete="off" placeholder=" 请输入合同编号" />
			</li>
			
			<li>
				<label>合同签约时间 ：<b></b></label>
				<input type="text" id="contractTime" class="dfinput fl" name="contractTime"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',autoPickDate:true})" th:value="${#dates.format(merchant.contractTime, 'yyyy-MM-dd')}"  autocomplete="off" placeholder=" 请输入合同签约时间"/>
			</li>
			
			<li>
				<label>地址：<b></b></label>
				<input type="text" id="address" class="dfinput fl" name="address"  th:value="${merchant.address}" autocomplete="off" placeholder=" 请输入地址" />
			</li>
			
			<li>
				<label>法人姓名 ：<b></b></label>
				<input type="text" id="legalperson" class="dfinput fl" name="legalperson" th:value="${merchant.legalPerson}" autocomplete="off" placeholder=" 请输入法人姓名" />
			</li>
			<li>
				<label>法人电话：<b></b></label>
				<input type="text" id="phone" class="dfinput fl" name="phone" th:value="${merchant.phone}" autocomplete="off" placeholder=" 请输入法人电话" />
			</li>
			<li>
				<label>代表姓名：<b></b></label>
				<input type="text" id="deputyname" class="dfinput fl" name="deputyname"  th:value="${merchant.deputyName}" autocomplete="off" placeholder=" 请输入代表姓名" />
			</li>
			<li>
				<label>代表电话：<b></b></label>
				<input type="text" id="deputyphone" class="dfinput fl" name=deputyphone th:value="${merchant.deputyPhone}" autocomplete="off" placeholder=" 请输入代表电话"/>
			</li>
		
			<li>
				<label>商户备注：<b></b></label>
				<input type="text" id="remarks" class="dfinput fl" name="remarks"  th:value="${merchant.remarks}" autocomplete="off" placeholder=" 请输入商户备注" />
			</li>

			<li style="padding-top: 10px">
				<label>&nbsp;</label>
				<button type="button" class="btn" onclick="javascript:location.reload();" style="background: #ccc;">清空</button>
				<button type="submit" onclick="push_user();" class="btn" style="width: 137px;margin-left: 20px;">保存</button>
			</li>
		</ul>
		<br/><br/><br/>
</div>


<div class="formbody" id="schoollist" style="display: none">
	<div class="rightinfo">	
			<ul class="seachform">
			    <li>
				 	<label style="color:red">已选择：</label>
				 	<sldiv id="selectschoollist">
					 	<label th:each="item:${positionSchoolV1Dtos}"><sdiv><stext th:data-val="${item.id}">[[${item.schoolName}]]</stext><dtext >[X]</dtext></sdiv></label>
				 	</sldiv>
			    </li>
				
			</ul>
	
	
			<ul class="seachform">
			    <li>
				 	<label>学校名称：</label>
				 	<input name="likeschoolname" id="likeschoolname" type="text" class="scinput" />
			    </li>
				<li>
					<input type="button" class="scbtn" value="全局查询" onclick="funcblurschoollist()" style="height: 32px;"/>
				</li>
			</ul>
			
			<ul class="seachform schoolseachform">
			   
			</ul>
			<br/><br/>
	</div>
	<div class="pagin" style="float: left;width: 90%;">
	    	<div class="message">共<i class="blue schoolcountNum">0</i>条记录，当前显示第&nbsp;<i class="blue schoolpageNo">0</i>页</div>
			    <form id="splitFrom" name="splitFrom" >
						<input type="hidden" id="pageNo" name="pageNo" value="1">
						<input type="hidden" id="pageSize" name="pageSize" value="20">
						<ul class="paginList schoolpaginList">
							
						</ul>
				</form>
				<br/><br/>
		</div>
</div>



<div class="formbody" id="likejoinlist" style="display: none">
	<div class="rightinfo">
			<ul class="seachform">
			    <li>
				 	<label>机构名称：</label>
				 	<input name="likename" id="likename" type="text" class="scinput" />
			    </li>
				<li>
					<input type="button" class="scbtn" value="全局查询" onclick="funcblurlibIdlist()" style="height: 32px;"/>
				</li>
			</ul>
			
			<ul class="seachform joinseachform">
			   
			</ul>
			<br/><br/>
	</div>
	<div class="pagin" style="float: left;width: 90%;">
	    	<div class="message">共<i class="blue countNum">0</i>条记录，当前显示第&nbsp;<i class="blue pageNo">0</i>页</div>
			    <form id="splitFrom" name="splitFrom" >
						<input type="hidden" id="pageNo" name="pageNo" value="1">
						<input type="hidden" id="pageSize" name="pageSize" value="20">
						<ul class="paginList joinpaginList">
							
						</ul>
				</form>
				<br/><br/>
		</div>
</div>



</body>
<script type="text/javascript">

var areaUrl="[[${sysUrl}]]/sys/fx/areaList";
var areaPageUrl="[[${sysUrl}]]/sys/fx/areaListPage";
var likejoinUrl="[[${sysUrl}]]/sys/fx/likejoinList";
var curLocation="[[${merchant.location}]]";
var curLibJoin="[[${merchant.libJoin!=null ?  merchant.libJoin.leagueName : '' }]]";
var curLibJoinId="[[${merchant.libJoin!=null ? merchant.libJoin.id : '' }]]";
var schoolText="[[${schoolText}]]";
var id='[[${param.id}]]';
var merchantLibId='[[${merchant.libId}]]';



$(function (){
	$("#location_txt").click(function (){
		$("#location_wrap").show();
	})
	
	$(".radiolib").on("change",function(){
	    alert("");
	});
	
	if(id==''){
		var val=$("#signType").find("option:selected").data("val");
		$("#libService").val(val);
		var upval=$("#signType").find("option:selected").data("upval");
    	$("#munitPrice").val(upval);
	}
    
	$("#signType").on("change",function(){
	    var val=$(this).find("option:selected").data("val");
	    $("#libService").val(val);
		var upval=$(this).find("option:selected").data("upval");
    	$("#munitPrice").val(upval);
	    if($(this).val()<=4){
	    	$("#libServiceTips").hide();
	    }else{
	    	$("#libServiceTips").show();
	    }
	});
	
	$("#libService").on("focus",function(){
		if($("#signType").val()<=4){
			parent.layer.msg("当前服务包类型不支持修改服务人数",{icon:3});
		}
		return;
	});
	
	
	$("#selectschoollist").on("click","dtext",function(){
		$(this).parent().remove();
		
		var schoollist=[];
		 $.each($('stext'),function(){
	       	schoollist.push($(this).text());
	    });
	 	$("#schooltext").val(schoollist.join(";"));
	});
	
	funcinitprovince();
	
})


function funcinitprovince(){
	var val = 0;
	var type =1;
	
	$("#province").html("<option value='' >选择省</option>");
	
	var params ={ 'type' : type,'upId':val}
	$.post(areaUrl,params,function(data){
		if(data.meta.success){
			var html=[];
			for (var i = 0; i < data.data.length; i++) {
				html.push("<option "+((curLocation.indexOf(data.data[i].name)!=-1) ? 'selected' : '')+" data-type='"+data.data[i].type+"' value='"+data.data[i].id+"' >"+data.data[i].name+"</option>");
			}
			$("#province").append(html.join(""));
			funcprovince();
		}else{
			
		}
	});
}


function funcprovince(){
	var val = $('#province  option:selected').val();
	var type = $('#province  option:selected').data("type");
	
	$("#city").html("<option value='' >选择市</option>");
	
	var params ={ 'type' : (type+1),'upId':val}
	$.post(areaUrl,params,function(data){
		if(data.meta.success){
			var html=[];
			for (var i = 0; i < data.data.length; i++) {
				html.push("<option "+((curLocation.indexOf(data.data[i].name)!=-1) ? 'selected' : '')+" data-type='"+data.data[i].type+"' value='"+data.data[i].id+"' >"+data.data[i].name+"</option>");
			}
			$("#city").append(html.join(""));
			funccity();
		}else{
			
		}
	});
}

function funccity(){
	var val = $('#city  option:selected').val();
	var type = $('#city  option:selected').data("type");
	
	$("#area").html("<option value='' >选择区</option>");
	//$("#libId").hide();
	//$("#school").html("").hide();
	
	var params ={ 'type' : (type+1),'upId':val}
	$.post(areaUrl,params,function(data){
		if(data.meta.success){
			var html=[];
			for (var i = 0; i < data.data.length; i++) {
				html.push("<option "+((curLocation.indexOf(data.data[i].name)!=-1) ? 'selected' : '')+" data-type='"+data.data[i].type+"' value='"+data.data[i].id+"' >"+data.data[i].name+"</option>");
			}
			$("#area").append(html.join(""));
			funcarea();
		}else{
			
		}
	});
}

function funcarea(){
	if(curLibJoin!=''){
		$("#libId").val(curLibJoin);
		$("#radiolibId").val(curLibJoinId);
		$("#schooltext").val(schoolText);
		funclibId();
	}
	$("#libId").show();
	$("#funcblurschooltext").show();
}

function funclibId(){
	
	//$("#school").html("").show();
	
	var val = $('#area  option:selected').val();
	var type = $('#area  option:selected').data("type");
	
	var params ={ 'type' : (type+1),'upId':val}
	$.post(areaUrl,params,function(data){
		if(data.meta.success){
			var html=[];
			for (var i = 0; i < data.data.length; i++) {
				html.push("<span><input name='school' type='checkbox' value='"+data.data[i].id+"'> "+data.data[i].name+"</span>");
			}
			//$("#school").append(html.join(""));
		}else{
			
		}
	});
}

var likejoinlistindex=null;
var schoollistindex=null;
function funcblurlibId(){
	funcblurlibIdlist();
	
	if($("#radiolibId").val()!='' && merchantLibId!=''){
		parent.layer.msg("此处不支持修改绑定机构,请先解绑机构。",{icon:3});
		return;
	}
	
	if($(".layui-layer-shade").length<=0){
		likejoinlistindex =layer.open({
			    type: 1,
			    title: '选择机构',
			    closeBtn: 1, //不显示关闭按钮
			    shift: 0.8,
			    offset: '150px',
			    area: ['80%', '60%'],
			    content: $("#likejoinlist")
		});
	}
}

function funcblurschooltext(){
	
	funcblurschoollist();
	if($(".layui-layer-shade").length<=0){
		schoollistindex =layer.open({
			    type: 1,
			    title: '选择学校',
			    closeBtn: 1, //不显示关闭按钮
			    shift: 0.8,
			    offset: '150px',
			    area: ['80%', '60%'],
			    content: $("#schoollist")
		});
	}
}


function funcblurschoollist(pageNo){
	$(".schoolseachform").html("");
	var val = $('#area  option:selected').val();
	var type = $('#area  option:selected').data("type");

	var params ={ 
			'type' : (type+1),
			'upId':val,
			'area' : $("#area option:selected").text(),
			'name' : $("#likeschoolname").val(),
			'pageNo' : pageNo,
			'pageSize':16
			}
	
	$.post(areaPageUrl,params,function(data){
		if(data.meta.success){
			var html=[];
			for (var i = 0; i < data.data.jsonList.length; i++) {
				html.push("<li><label><text  data-value='"+data.data.jsonList[i].id+"' name='schoolcheckbox' type='checkbox' onclick='funcblurschoolcheckbox(this)' >"+data.data.jsonList[i].name+"</text></label></li>");
			}

			var countPage=data.data.countPage;
			var pageNo=data.data.pageNo;
			$(".schoolcountNum").html(data.data.countNum);
			$(".schoolpageNo").html(data.data.pageNo);
			
			var pagehtml=[];
			if(pageNo>1){
				pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurschoollist('+(pageNo-1)+');"><span class="pagepre"></span></a></li>');
			}
			for (var i = 1; i <= countPage; i++) {
				if(i==pageNo){
					pagehtml.push('<li class="paginItem  current"><a href="javascript:;" onclick="javascript:funcblurschoollist(\''+i+'\');return false;">'+i+'</a></li>' );
				}else{
					pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurschoollist(\''+i+'\');return false;">'+i+'</a></li>' );
				}
			}
			if(countPage>pageNo){
				pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurschoollist('+(pageNo+1)+');"><span class="pagenxt"></span></a></li>');
			}
			
			$(".schoolpaginList").html(pagehtml.join(''));
			$(".schoolseachform").append(html.join(""));
		}else{
			
		}
	});
}



function funcblurlibIdlist(pageNo){
	$(".joinseachform").html("");
	var params ={ 
			'province' : $("#province option:selected").text(),
			'city' : $("#city option:selected").text(),
			'area' : $("#area option:selected").text(),
			'name' : $("#likename").val(),
			'pageNo' : pageNo,
			'pageSize':16
			}
	
	$.post(likejoinUrl,params,function(data){
		if(data.meta.success){
			var html=[];
			for (var i = 0; i < data.data.jsonList.length; i++) {
				html.push("<li><label><input name='radiolib' value='"+data.data.jsonList[i].id+"' type='radio' onchange='funcblurlibIdradio(this)' >"+data.data.jsonList[i].leagueName+"</label></li>");
			}

			var countPage=data.data.countPage;
			var pageNo=data.data.pageNo;
			$(".countNum").html(data.data.countNum);
			$(".pageNo").html(data.data.pageNo);
			
			var pagehtml=[];
			if(pageNo>1){
				pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurlibIdlist('+(pageNo-1)+');"><span class="pagepre"></span></a></li>');
			}
			for (var i = 1; i <= countPage; i++) {
				if(i==pageNo){
					pagehtml.push('<li class="paginItem  current"><a href="javascript:;" onclick="javascript:funcblurlibIdlist(\''+i+'\');return false;">'+i+'</a></li>' );
				}else{
					pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurlibIdlist(\''+i+'\');return false;">'+i+'</a></li>' );
				}
			}
			if(countPage>pageNo){
				pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurlibIdlist('+(pageNo+1)+');"><span class="pagenxt"></span></a></li>');
			}
			
			$(".joinpaginList").html(pagehtml.join(''));
			$(".joinseachform").append(html.join(""));
		}else{
			
		}
	});
}


function funcblurlibIdradio(obj){
	
	var libtext = $("input[name=radiolib]:checked").parent("label").text();
	var libId = $("input[name=radiolib]:checked").val();
	
	$("#radiolibId").val(libId);
	$("#libId").val(libtext);
	
	funclibId();
	
	layer.close(likejoinlistindex);	
}

function funcblurschoolcheckbox(obj){
 	$("#selectschoollist").append('<label><sdiv><stext data-val="'+$(obj).data("value")+'">'+$(obj).parent("label").text()+'</stext>  <dtext >[X]</dtext></sdiv></label>');
 	
 	var schoollist=[];
	 $.each($('stext'),function(){
       	schoollist.push($(this).text());
    });
 	$("#schooltext").val(schoollist.join(";"));
}


function push_user(){
	//新增的
	if(id==''){
		var url="[[${sysUrl}]]/sys/fx/checkMerchant";
		var params ={ 'name' : $("#poscode").val()}
		$.post(url,params,function(data){
			if(data.meta.success){
				save();
			}else{
				parent.layer.msg(data.meta.message,{icon:11});
			}
		});
	}else{
		//修改的
		save();
	}
}

function save(){
	var schoollist=[];
	$.each($('stext'),function(){
        schoollist.push($(this).data("val"));
    });
	if($("#poscode").val()==''){
		parent.layer.msg("商户账号不能为空",{icon:11});
		return
	}
	var reg = /^[0-9a-zA-Z]+$/
	if(!reg.test($("#poscode").val())){
		parent.layer.msg("商户账号只可包含字母、数字",{icon:11});
		return
	}	
	if($("#unitname").val()==''){
		parent.layer.msg("商户名称不能为空",{icon:11});
		return
	}
// 	if($("#signTime").val()==''){
// 		parent.layer.msg("合同开始日期不能为空",{icon:11});
// 		return
// 	}
// 	if($("#endSignTime").val()==''){
// 		parent.layer.msg("合同结束日期不能为空",{icon:11});
// 		return
// 	}
// 	if($("#signType").val()!='' && $("#signType").val()>=1 && $("#libServiceMonth").val()<=0){
// 		parent.layer.msg("新模式充值月份数不可小于0",{icon:11});
// 		return
// 	}
	if($("#signType").val()!='' && $("#signType").val()>=1 && $("#curSummaryTime").val()==''){
		parent.layer.msg("新模式激活时间不可为空",{icon:11});
		return
	}

	var title="您确定要保存商户信息?<br/>此动作会把商户塾币覆盖到机构塾币";
	if(id!=''){
		title="您确定要保存商户信息?";
	}
	parent.layer.confirm(title, {
		icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
	}, function(){
		var url="[[${sysUrl}]]/sys/fx/saveMerchant";
		if( $("#poscode").val()==''){
			alert("商户账号不能为空");
			return ;
		}
		var params ={
		 	'id' : id,
            'posCode' : $("#poscode").val(),
            'type' : $("#type").val(),
            'level' : $("#level").val(),
            'unitName' : $("#unitname").val(),
            'legalPerson' : $("#legalperson").val(),
            'phone' : $("#phone").val(),
            'deputyName' : $("#deputyname").val(),
            'deputyPhone' : $("#deputyphone").val(),
            'status':$("#status").val(),
            'parentPosCode':$("#parentposcode").val(),
            'price':$("#price").val(),
            'outPrice':$("#outPrice").val(),
            'remarks':$("#remarks").val(),
            'password':$("#password").val(),
            'signService':$("#signService").val(),
            'hardwareService':$("#hardwareService").val(),
            
            'signType':$("#signType").val(),
            'mealType':$("#mealType").val(),
            'libService':$("#libService").val(),
            
            'libServiceMonth':$("#libServiceMonth").val(),
            
            'startTime':$("#signTime").val(),
            'endTime':$("#endSignTime").val(),
            'startActiveTimeStr':$("#startActiveTime").val(),
            'activeTimeStr':$("#activeTime").val(),
            'computeTimeStr':$("#computeTime").val(),
            
            
            'munitPrice':$("#munitPrice").val(),
            'signerPerson':$("#signerPerson").val(),
            'contractNo':$("#contractNo").val(),
            'contractTimeStr':$("#contractTime").val(),
            'posType':2,
            'buyMonth':$("#buyMonth").val(),
            'giveMonth':$("#giveMonth").val(),
            'plusAmountPrice':$("#plusAmountPrice").val(),
            'plusMonthPrice':$("#plusMonthPrice").val(),
            
            'province':$("#province").val(),
            'city':$("#city").val(),
			'address':$("#address").val(),
            'area':$("#area").val(),
            'libId':$("#radiolibId").val(),
            'location':
            	($("#province option:selected").text()!='选择省' ? $("#province option:selected").text() : '') +
            			($("#city option:selected").text()!='选择市' ? $("#city option:selected").text() : '') +
            			($("#area option:selected").text()!='选择区' ? $("#area option:selected").text() : ''),
            'schoollist':schoollist.join(";")
        };
		$.post(url,params,function(data){
			if(data.meta.success){
				parent.layer.msg("保存成功",{icon:1});
				parent.location.reload();
			}else{
				parent.layer.msg(data.meta.message,{icon:11});
			}
		});
	});
}



</script>
</html>