<%@ page language="C#" autoeventwireup="true" inherits="user_wyhProductsEdit, kfenlei" %><%@ Register TagPrefix="qth8" TagName="userManageLeft" Src="~/inc/userWeixinLeft.ascx" %><%@ Register TagPrefix="qth8" TagName="userManageTop" Src="~/inc/userManageTop.ascx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title><%=sWebName %> - 修改产品</title>
<link rel="stylesheet" type="text/css" href="css.css" />
<link rel="stylesheet" type="text/css" href="/template/css.css" />
<%=tools.sUserHtmlEdit("content")%>
</head>
<body>
<div align="center">
<qth8:userManageTop runat="server" ID="userManageTop" selectValue="5" />
<script type="text/javascript" language="javascript" src="/js/layui.js"></script>
<link href="/js/css/layui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
layui.use(['form','laydate'], function(){
var form = layui.form();
    form.render();
});
</script>
<div class="main" align="left">
<div class="clear"></div>
<qth8:userManageLeft runat="server" selectValue="9" ID="userManageLeft" />
<div class="userRight">
<div class="userRightContent">
<div class="userRightContentTop">修改产品</div>
<form action="action.aspx?s=wyhProductsEdit" class="layui-form" method="post" name="fabu">
<input type="hidden" name="id" value="<%=id %>" />
<table width="970" class="formTable" cellspacing="0" cellpadding="5">
<tr>
<td class="head" width="120">产品名称：</td>
<td><input class="textInput"  value="<%=sTitle %>" name="title" type="text" size="55" /></td> 
</tr>
<tr>
<td class="head">产品分类：</td>
<td><div class="post_city"><select name="sort" id="sort">
<option value="">请选择</option>
<%=sSortList %>
</select></div></td> 
</tr>
<tr>
<td class="head">市场价格：</td>
<td><input type="text" class="textInputP" name="price" value="<%=sPrice %>" size="10" /><div class="exDiv">（元）</div></td> 
</tr>
<tr>
<td class="head">会员价格：</td>
<td><input type="text" class="textInputP" name="price1" value="<%=sPrice1 %>" size="10" /><div class="exDiv">（元）</div></td> 
</tr>
<tr>
<td class="head">封面图片：</td>
<td><input type="hidden" name="pic1" id="inputpic1" value="<%=sPic %>" />
<img src="images/nopic2.gif" id="pic1" width="96" height="96" style="border:1px solid #dedede; cursor:pointer;" class="fl5" onclick="$('#upfileDiv').fadeIn(800)" /><a href="#nogo" onclick="$('#upfileDiv').fadeIn(800)" class="btn_1 fl5">上传</a>
<div class="clear"></div>
<div class="upfileDiv" id="upfileDiv">
<div class="upfileClose" onclick="$('#upfileDiv').fadeOut(300)">关闭</div>
<iframe width="300" height="100" style=" padding:0px; margin:0px;" src="actionUpLoad.aspx?tn=pic_path&fn=fabu&size=200,0&js=top.hideDiv('upfileDiv');top.valiUpPic('pic1','{picUrl}');" frameborder="0" scrolling="no"></iframe>
</div>
</td>
</tr>
<tr>
<td class="head">产品图片列表：</td>
<td with="720">
<input type="hidden" name="pic" id="pic" value="<%=sPicList %>" />
<div id="swfupload-control">
<div class="fl5"><input type="button" id="button" /></div>
<div class="exDiv">可以上传<%=sPicCount%>张图片，图片请小于<%=sPicSize1%>。</div>
<div class="clear"></div>
<ul id="preview"></ul>
</div>
<script type="text/javascript" src="<%=sPostPath%>inc/swfupload/swfupload.js"></script>
<script type="text/javascript" src="<%=sPostPath%>inc/jquery.swfupload.js"></script>
<script type="text/javascript">
var s1;
$(function(){
	$('#swfupload-control').swfupload({
		upload_url: "<%=sPostPath%>inc/upload.aspx",
		file_post_name: 'uploadfile',
		file_size_limit : "<%=sPicSize%>",
		file_types : "<%=sUploadType %>",
		file_types_description : "Image files",
		file_upload_limit : <%=sPicCount%>,
		flash_url : "<%=sPostPath%>inc/swfupload.swf",
		button_image_url : '<%=sPostPath%>inc/button.png',
		button_width :110,
		button_height :42,
		button_placeholder : $('#button')[0],
		debug: false
	})
		.bind('fileQueued', function(event, file){
			var listitem='<li id="'+file.id+'" >'+
				'<div class="pic" id="pic'+file.id+'"></div>'+
				'<div class="progressbar" ><div class="progress"></div></div>'+
				'<p class="status" >等待上传 | <span class="cancel">删除</span></p>'+
				'</li>';
			$('#preview').append(listitem);
			$('li#'+file.id+' .cancel').bind('click', function(){
				var swfu = $.swfupload.getInstance('#swfupload-control');
				swfu.cancelUpload(file.id);
				$('li#'+file.id).slideUp('fast');
			});
			// start the upload since it's queued
			$(this).swfupload('startUpload');
		})
		.bind('fileQueueError', function(event, file, errorCode, message){
		if(errorCode=='-100')
			{
				alert('最多可以上传<%=sPicCount%>张图片！');
			}
			else
			{
				alert('图片：【'+file.name+'】过大，单张图片请不要超过<%=sPicSize1%>！');
			}
		})
		.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
			$('#queuestatus').text('');
		})
		.bind('uploadStart', function(event, file){
			$('#preview li#'+file.id).find('p.status').text('0%上传中...');
			$('#preview li#'+file.id).find('span.cancel').hide();
		})
		.bind('uploadProgress', function(event, file, bytesLoaded){
			//Show Progress
			var percentage=Math.round((bytesLoaded/file.size)*100);
			$('#preview li#'+file.id).find('div.progress').css('width', percentage+'%');
			$('#preview li#'+file.id).find('p.status').text(percentage+'%上传中...');
		})
		.bind('uploadSuccess', function(event, file, serverData){
			var item=$('#preview li#'+file.id);
			item.find('div.progress').css('width', '100%');
			item.addClass('success').find('p.status').html('100%上传成功! | <span class="cancel" onclick="delPic(\''+file.id+'\')">删除</span>');
			$("#pic"+file.id).html('<img src="/'+serverData+'" id="img'+file.id+'" />');
			$("#pic").val($("#pic").val()+serverData+",");
		})
		.bind('uploadComplete', function(event, file){
			// upload has completed, try the next one in the queue
			$(this).swfupload('startUpload');
		});
});	
function updatePic()
{
	if($("#pic").val()!="")
	{
		arrPic=$("#pic").val().split(",");
		var picCount=0;
		for(t=0;t<arrPic.length;t++)
		{
			if(arrPic[t]!="")
			{
				picCount++;
				$("#preview").html($("#preview").html()+'<li id="'+t+'" >'+
				'<div class="pic" id="pic'+t+'"><img src="/'+arrPic[t]+'" id="img'+t+'" /></div>'+
				'<div class="progressbar" ><div class="progress"></div></div>'+
				'<p class="status" >100%上传成功! | <span class="cancel" onclick="delPic(\''+t+'\')">删除</span></p>'+
				'</li>');
			}
		}
		var swfu = $.swfupload.getInstance('#swfupload-control');
		var stats = swfu.getStats();  
		stats.successful_uploads+=picCount;
		swfu.setStats(stats);
	}
}
function delPic(pid)
{
	var picPath=$("#img"+pid).attr('src');
	$('li#'+pid).slideUp('fast');
	var swfu = $.swfupload.getInstance('#swfupload-control');
	var stats = swfu.getStats();  
	stats.successful_uploads--;
	swfu.setStats(stats);
	var picArr=$("#pic").val().split(',');
	$("#pic").val('');
	for(i=0;i<picArr.length;i++)
	{
		if(picPath.indexOf(picArr[i])<0)
		{
			$("#pic").val($('#pic').val()+picArr[i]+",");
		}
	}
}
</script>
</td>
</tr>
<tr>
<td class="head">产品介绍：</td>
<td><textarea name="content" id="content" class="textTextarea"><%=sContent %></textarea></td>
</tr>
<tr><td>&nbsp;</td><td><input type="submit" class="inputSubmit" value="修改产品" /></td></tr>
</table>
</form>
<script language="javascript" type="text/javascript">
$("#sort [value='<%=sSort %>']").attr("selected","selected");
valiUpPic("pic1",document.getElementById("inputpic1").value);
setTimeout('updatePic()',500);
function valiUpPic(picId,picValue)
{
	document.getElementById("input"+picId).value=picValue
	if(picValue!="")
	{
		document.getElementById(picId).src="/"+picValue
	}
	else
	{
		document.getElementById(picId).src="/user/images/nopic2.gif"
	}
}
function showStartUp(picId)
{
	document.getElementById(picId).src="/user/images/startUp.gif"
}
function showDiv(divId)
{
  	var obj=divId.split(',');
	if(obj.length>0)
	{
		for(i=0;i<obj.length;i++)
		{
  			document.getElementById(obj[i]).style.display="block";
		}
	}
}
function hideDiv(divId)
{
  	var obj=divId.split(',');
	if(obj.length>0)
	{
		for(i=0;i<obj.length;i++)
		{
  			document.getElementById(obj[i]).style.display="none";
		}
	}
}
</script>
</div></div>
</div></div>
</body>
</html>
