<{import file="index/header_shop.html" title="产品发布"}> 
<style type="text/css">
.cname{ font-size:16px; border-bottom:1px solid #efefef; width:940px; padding:2px 0 10px 0; float:left; }
.cats_list{ width:780px; height:400px; float:left; overflow:hidden; margin:15px 0 0 70px; border:1px solid #efefef; float:left;}
.cats_list .menu{ width:260px; height:400px; padding:0; overflow-y:scroll; float:left;}
.cats_list .menu ul{}
.cats_list .menu ul li{}
.cats_list .menu ul li a{ width:198px; padding:8px 0 8px 20px; font-size:14px; float:left;}
.cats_list .menu ul li.ch{ padding-right:25px; background: #E5F5FD; float:left; }
.cats_list .menu ul li.ch a{ font-weight:bold; color:#1683B6; }

.addBtton{ width:100%; text-align:center; padding:10px 0 30px;  float:left;}
.addBtton input{ float:none; margin:20px 0 0 0; padding:8px 38px; border-radius:1px; background: #efefef; color:#666; font-size:16px;} 
.addBtton input.ch{ background: #3399CC; color:#FFFFFF; }

.guize{ width:890px; height:180px; color:#888; border:1px solid #efefef; margin:0 0 30px 18px; padding:10px; line-height:25px; overflow-y:scroll; float:left;}
</style>
<div class="cname">选择产品分类</div>
<div class="lbox"> 
<form action="?m=company&a=base_save" method="get">	
	<div class="cats_list"></div> 
	<input type="hidden" name="m" value="goods"/>
	<input type="hidden" name="cid" id="cid" value="<{if $smarty.get.cid}><{$smarty.get.cid}><{/if}>"/>
	<input type="hidden" name="a" value="edit"/>
	<{if $smarty.get.gid}>
		<input type="hidden" name="id" id="gid" value="<{$smarty.get.gid}>"/>
	<{/if}>
	
	<div class="addBtton"><input type="submit" id="submit_cats" value="我已经阅读以下规则，现在发布宝贝" disabled="disabled"/></div>
	<!--规则-->
	<div class="guize">
		<{uqcms m="news" v="news_row" c="get_one:alias=goods_rule"}> 
		<{if $news_row.content}><{$news_row.content}><{/if}>  
	</div>
</form> 
</div>
<{include file="index/footer.html"}>  
<script type="text/javascript">
$(function(){
	$(document).on("click",".menu ul li a",function(){
		var $this = $(this);
 		var cid = $this.attr('data-cid'); 
		$this.parent('li').addClass('ch').siblings().removeClass('ch');
		$this.parents('.menu').nextAll().remove();
		category_next(cid);
 	}); 
	function category_next(pcid){ 
		cid = cid?cid:'0';
		$.post('member.php?m=goods&a=ajax_get_next_list',{pcid:pcid}, function(result){
			var data = jQuery.parseJSON(result);
			if(data.error == '0'){
				if(data.last == '0'){
					html = '<div class="menu menu_'+cid+'"><ul>';
					$.each(data.category, function(key, val){
						html += '<li><a href="javascript:;" data-cid="'+val.cid+'" >'+val.name+'</a></li>'; 
					});
					html += '<ul></div>';
					if($('.menu').length == 0){ 
						$('.cats_list').html(html);		
					}else{
						$('.menu:last').after(html);		
					} 
					$("#cid").val('');
					$("#submit_cats").attr('disabled',true).removeClass('ch');
				}else{
					$("#cid").val(pcid);
					$("#submit_cats").attr('disabled',false).addClass('ch'); 
				} 
			}else{
				alert('系统繁忙');
			}
		}); 
	}
	<{if $smarty.get.cid}>
		$.post("member.php?m=goods&a=ajax_get_parents_list",{cid:'<{$smarty.get.cid}>'},function(result){ 
			var data = jQuery.parseJSON(result); 
			html = '';
			$(data).each(function(key, val){
				html += '<div class="menu"><ul>';
				$.each(val.list, function(index, obj){
					if(obj.cid == val.cid){
						html += '<li class="ch"><a href="javascript:;" data-cid="'+obj.cid+'">'+obj.name+'</a></li>'; 
					}else{
						html += '<li><a href="javascript:;" data-cid="'+obj.cid+'" >'+obj.name+'</a></li>'; 
					} 
				}); 
				html += '<ul></div>'; 
			});
			$('.cats_list').html(html); 
		});
		$("#cid").val('<{$smarty.get.cid}>'); 
		$("#submit_cats").attr('disabled',false).addClass('ch'); 
	<{else}>
		category_next('0');	
	<{/if}> 
});
</script>