{wc:templates "index","header"}
<div class="main-content clearfix">
<script type="text/javascript" charset="utf-8" src="{G_PLUGIN_PATH}/uploadify/jquery.uploadify-3.1.min.js"></script>
<link rel="stylesheet" href="{G_PLUGIN_PATH}/uploadify/uploadify.css" type="text/css"> 
{wc:templates "member","left"}
<script>
//上传文件
$(function(){
    $('#sd_file').uploadify({
    	'auto'     : false,
    	'removeTimeout' : 1,
        'swf'      : '{G_PLUGIN_PATH}/uploadify/uploadify.swf',
        'uploader' : '{WEB_PATH}/member/home/singphotoup',
        'method'   : 'post',
		'buttonText' : '选择图片',
		'buttonImage': '{G_PLUGIN_PATH}/uploadify/select.png',
		'width': 120,
		'height': 30,
        'multi'    : true,
		'uploadLimit' : 10,
		'queueID'         : 'fileQueue',
        'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.gif; *.jpg; *.png',
        'fileSizeLimit' : '500KB',

		'formData'        : {
			'uid': '{wc:$uid}',			
			'ushell':'{wc:$ushell}'
		},	
		'onUploadSuccess' : function(file, data, response){		
			$(".fileWarp ul").append(SetImgContent(data));
			SetUploadFile();
		}
    });
});
function sdUpload(){
		$('#sd_file').uploadify('settings','formData',{'typeCode':document.getElementById('id_file').value});
		$('#sd_file').uploadify('upload','*')
	}
//显示上传的图片
function SetImgContent(data){
	var sLi = "";
		sLi += '<li>';
		sLi += '<img src="{G_UPLOAD_PATH}/' + data + '" width="100" height="100" />';
		sLi += '<input type="hidden" name="fileurl_tmp[]" value="' + data + '">';
		sLi += '<a href="javascript:void(0);">删除</a>';
		sLi += '</li>';
	return sLi;
}

//删除上传元素DOM并清除目录文件
function SetUploadFile(){
	$(".fileWarp ul li").each(function(l_i){
		$(this).attr("id", "li_" + l_i);
	})
	$(".fileWarp ul li a").each(function(a_i){
		$(this).attr("rel", "li_" + a_i);
	}).click(function(){
		$.get(
			'{WEB_PATH}/member/home/singdel',
			{action:"del", filename:$(this).prev().val()},
			function(){}
		);
		$("#" + this.rel).remove();
	})
}
$(function(){
	$(".fileoldimg a").click(function(){
		$.post(
			"{WEB_PATH}/member/home/singoldimg",
			{action:"del",sd_id:"{wc:$sd_id}", oldimg:$(this).prev().val()},
			function(){}			
		);
		$("#" + this.rel).remove();
	})
})
</script>
<style>
.R-content .sd_lilie{display:block; width:780px; margin:10px 0 10px 0; float:left;}
.R-content .sd_lilie .sd_span{font-size:14px; float:left; display:block;width:70px;}
#sd_text{border:1px solid #ccc; width:450px; height:30px; padding:0 0 0 5px;}
#sd_textarea{width:500px; height:150px; border:1px solid #ccc; resize:none; padding:5px;}
#sd_file{ float:left; margin:20px 0 0 0;}
#fileQueue{display: block; margin: 30px 0 0 0;}
#fileQueue div{ margin:5px 0 0 0;}
#sd_submit{padding:5px 10px; float:right; border-right:1px solid #666; border-bottom:1px solid #666;}
.button{ margin:5px 0 0 0; float:left;padding:3px 7px; float:left; border-right:1px solid #666; border-bottom:1px solid #666;}
.fileWarp{ width:710px;  float:left;}
.fileWarp ul li{ float:left;  margin-right:10px;}
.fileWarp ul li a{ display:block; height:25px; width:100px; text-align:center; background-color:#eee; color:#f60;line-height:25px;}

.fileoldimg{ width:710px;  float:left;}
.fileoldimg ul li{ float:left;  margin-right:10px;}
.fileoldimg ul li a{ display:block; height:25px; width:100px; text-align:center; background-color:#eee; color:#f60;line-height:25px;}

</style>
<div class="R-content">
	<div class="subMenux" style="height:50px;line-height:50px;">
		<span>添加晒单</span>
		<a style="float:right;" href="{WEB_PATH}/member/home/singlelist" class="blue">返回晒单</a>
	</div>
	<form  action="{WEB_PATH}/member/home/singleupdate" method="post">
		<input type="hidden" name="sd_id" value="{wc:$sd_id}"/>
		<div class="sd_lilie">
			<span class="sd_span">标题：</span>
			<input id="sd_text" type="text" name="title" value="{wc:$shaidan['sd_title']}" />
		</div>
		<div class="sd_lilie">
			<span class="sd_span">内容：</span>
			<textarea id="sd_textarea" name="content">{wc:$shaidan['sd_content']}</textarea>
		</div>
		<div class="sd_lilie">
			<span class="sd_span">晒图：</span>			
			<div style="float:left; width:400px;">
				{wc:if $shaidan['sd_photolist']!=null}
				<div class="fileoldimg"><ul>{wc:fun:sdimg($shaidan['sd_id'])}</ul></div>
				{wc:if:end}
				<input id="sd_file" type="file" name="upimg"/>				
				<div style="width:710px; float:left;"></div>
				<input type="hidden" name="imglist" id="id_file" />
				<input type="button"  class="button" onClick="sdUpload()" value="上传图片" />
				<div class="fileWarp"><div id="fileQueue"></div><ul></ul></div>			
			</div>
		</div>
		<div class="sd_lilie" style="width:580px;">
		<input id="sd_submit" name="submit" type="submit" value="确认添加" />
		</div>
	</form>
</div>

</div>
		</div>
	</div>
<!--center_center_end-->
<div class="right">				
</div>
<!--center_rjght_end-->

</div>
{wc:templates "index","footer"}