<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%@ include file="../../common/head.jsp"%>
<script>
        $(document).ready(function () {
        /* 	    var seApId = '<select id="apId" name="apId" class="form-control" validate="{required:true}" validateMessage="{required:\'请选择对应广告位\'}"> <option value="">  --请选择 -- </option>';
        		var jsonData = ${jsonAdvPosition};
        		
        		$.each(jsonData, function(i, item) {        	           
        			seApId += '<option value="'+item.id+'">  '+item.apName+' </option>';        	            
        	        }); 
        		seApId += "</select>"
        		$("#divApId").append(seApId); */
        		

        		$("#divGoods").hide();
        		//绑定change事件
        		$(document).on("change", "#advType", function() {
        			if($("#advType").val() == "goods"){
        				$("#divGoods").show();
        				$("#divAdvSrc").hide();
        			}else{
        				$("#divGoods").hide();
        				$("#divAdvSrc").show();
        			}
        		});
        		
        		
        	 	$("#buttonSubmit").bind("click",function(){
        			if ($("#addGoodsClassForm").valid()) {
        				if($("#advType").val() == "goods"){
        	        		if($("#goodsId").val() == ""){
        	        			 layer.alert('请选择商品！');
        	        			 return;
        	        		}
        	        		
        	        		$("#advSrc").val($("#goodsId").val());
        	        							
        	        	}
        				if($("#advPic").val() == ""){
        					 layer.alert('请上传图片！');
        					 return;
        				}
        				
        				$("#addGoodsClassForm").submit();
        			}
        		 }); 
        		
        });
        
      ///选择商品p
 <%--        function selectGooods_radio(){
    		var index = parent.layer.open({
    			type: 2,
    			  area: ['800px', '800px'],
    			  fixed: false, //不固定
    			  resize: true,
    			  maxmin: true,
    			  shade: 0.6,
    			  title:'选择商品',
    			  content: '<%=path%>/case/listGoods.cs'
    		});
    	} --%>
      
      
</script>
<cs:initFile />
</head>

<body>
	<div class="wrapper wrapper-content">
		<div class="row">
			<div class="col-sm-12">
				<cs:form_validate formId="addGoodsClassForm" />
				<form class="form-horizontal" action="add.cs" id="addGoodsClassForm"
					method="POST">
				<!-- 	<div class="form-group">
						<label class="col-sm-3 control-label">对应广告位：</label>
						<div class="col-sm-6" id="divApId"></div>
					</div> -->
					<div class="form-group">
						<label class="col-sm-3 control-label">标题：</label>
						<div class="col-sm-6">
							<input id="advTitle" name="advTitle" class="form-control"
								validate="{required:true}"
								validateMessage="{required:'请输入标题'}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">图片：</label>
						<div class="col-sm-6">
							<cs:file name="advPic" type="130" num="1"></cs:file>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-3 control-label">权重：</label>
						<div class="col-sm-6">
							<input id="advSort" name="advSort" oninput='this.value=this.value.replace(/^[0]+[0-9]*$/gi,"")' onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')" placeholder="请输入数字，正排序" class="form-control"
								validate="{required:true,maxlength:10}"
								validateMessage="{required:'请输入权重',maxlength:'请输入小于10位的数字'}">
						</div>
					</div>

					<!-- 广告链接类型 关键字搜索-keyword 商品-goods 链接-link-->
					<div class="form-group">
						<label class="col-sm-3 control-label">链接类型：</label>
						<div class="col-sm-6">
							<select id="advType" name="advType" class="form-control">
								<!-- validate="{required:true}" validateMessage="{required:'请选择广告链接类型'}" -->
								<option value="">--请选择 --</option>
						<!-- 		<option value="keyword">关键字搜索</option>
								<option value="goods">商品</option> -->
								<option value="link">链接</option>
								<option value="">无链接</option>
							</select>
						</div>
					</div>

					<div class="form-group" id="divAdvSrc">
						<label class="col-sm-3 control-label">链接地址：</label>
						<div class="col-sm-6">
							<input id="advSrc" name="advSrc" class="form-control">
							<!--  validate="{required:true}" validateMessage="{required:'请输入链接地址,不能重复'}"  -->
						</div>
					</div>

				<!-- 	<div class="form-group" id="divGoods">
						<label class="col-sm-3 control-label">商品：</label>
						<div class="col-sm-6">
							<div class="input-group">
								<input type="hidden" class="form-control" value="" id="goodsId"
									placeholder="" name="goodsId"> <input type="text"
									class="form-control" value="" id="goodsName" placeholder=""
									readonly name="goodsName"> <span
									class="input-group-btn">
									<button onclick="selectGooods_radio()" type="button"
										class="btn btn-primary">选择商品</button>
								</span>
							</div>
						</div>
					</div> -->


				<!-- 	<div class="form-group">
						<label class="col-sm-3 control-label">排序：</label>
						<div class="col-sm-6">
							<input id="slideSort" name="slideSort" class="form-control">
						</div>
					</div> -->


					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-3 pull-left">
							<button class="btn btn-default btn-dlg-close">取消</button>
							<button class="btn btn-primary" id="buttonSubmit" type="button">提交</button>
						</div>
					</div>

				</form>
			</div>
		</div>

	</div>


</body>

</html>

