<%@ page language="C#" autoeventwireup="true" inherits="wap_user_wyhProductsAdd, kfenlei" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-control" content="no-cache" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<title><%=sWebName %> - 发布产品</title>
<link href="/js/css/layui.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css.css" />
</head>
<body>
<%=qTemplate.Ac("wapUserTop.html") %>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" language="javascript" src="/js/layui.js"></script>
<script type="text/javascript" src="/js/m.js"></script>
<script type="text/javascript">
layui.use(['form','laydate'], function(){
var form = layui.form();
    form.render();
});
</script>
<div align="left">
<div class="wapPageTitle"><a href="/wap/user/index2.aspx" class="infoback">返回</a>发布产品</div>
<div class="clear10"></div>
<div class="infowrap" align="left">
<div class="userRight">
<div class="userRightContent">
<form action="/inc/kfUpload.aspx?s=nowatermark" style="display:none;" id="upFileForm1" name="upFileForm1" method="post" enctype="multipart/form-data">
<input type="file" id="upFile1" name="upFile1" />
<input type="submit" value="上传">
</form>
<form action="/inc/kfUpload.aspx?s=nowatermark" style="display:none;" id="upFileForm" name="upFileForm" method="post" enctype="multipart/form-data">
<input type="file" id="upFile" name="upFile" />
<input type="submit" value="上传">
</form>
<form action="action.aspx?s=wyhProductsAdd" class="layui-form" method="post" name="fabu">
<table width="100%" class="userMessTable" cellspacing="0" cellpadding="5">
<tr>
<td class="head" width="80">产品名称：</td>
<td><input class="inputText"  value="" name="title" type="text" size="55" /></td> 
</tr>
<tr>
<td class="head">产品分类：</td>
<td><div class="selectDivLine"><select name="sort"><option value="">请选择</option><%=sSortList %></select></div></td> 
</tr>
<tr>
<td class="head">市场价格：</td>
<td><input type="text" class="inputText" name="price" size="10" /></td> 
</tr>
<tr>
<td class="head">会员价格：</td>
<td><input type="text" class="inputText" name="price1" size="10" /></td> 
</tr>
<tr>
<td class="head">封面图片：</td>
<td><input type="hidden" name="pic" id="inputpic1" value="" />
<img src="images/nopic2.gif" id="pic1" width="96" height="96" style="border:1px solid #e5e5e5; border-radius:3px; cursor:pointer;" class="fl5" onClick="$('#upFile1').click();" /> <a href="#nogo" onClick="$('#upFile1').click();" class="bt2 fl5">上传</a>
</td>
</tr>
<tr>
<td class="head">图片列表：</td><td><input type="hidden" name="piclist" id="piclist" value="" />
<div class="inputPs1">可上传<strong><%=sPicCount%></strong>张图片，图片请小于<%=sPicSize1%></div>
<div class="swfupload-control">
<ul id="preview" class="preview"><li id="wapUploadBtn" class="wapUploadBtn"><img src="/wap/images/wapUploadBtn.png" /></li></ul><div class="clear"></div></div>
<script language="javascript">
var iPicCount=<%=sPicCount%>;
setCookie("kPicCount",0);
var iPic=0;
function uPic()
{
	var sPic=$("#piclist").val();
	if(sPic!="")
	{
		iPic=0;
		var saPic=sPic.split(',');
		var sPreview="";
		for(i=0;i<saPic.length-1;i++)
		{
			if(saPic[i]!="")
			{
				iPic++;
				sPreview+='<li><div><img src="/'+saPic[i]+'" height="100" width="100" /></div><div class="previewDel" onclick="delUp(\''+saPic[i]+'\')">&times;</div></li>';
			}
		}
		setCookie("kPicCount",iPic);
		$("#preview").html(sPreview+'<li id="wapUploadBtn" class="wapUploadBtn"><img src="/wap/images/wapUploadBtn.png" /></li>');
	}
	else
	{
		$("#preview").html('<li id="wapUploadBtn" class="wapUploadBtn"><img src="/wap/images/wapUploadBtn.png" /></li>');
		setCookie("kPicCount",0);
	}
}
$("#wapUploadBtn").click(function(){
	if(getCookie("kPicCount")>=iPicCount)
	{
		alert("最多可上传<%=sPicCount%>张图片!");
	}
	else
	{
		$("#upFile").click();
	}
});
function delUp(picName)
{
	$("#piclist").val($("#piclist").val().replace(picName+",",""));
	$("#preview li").has("img[src='/"+picName+"']").remove();
	iPic--
	setCookie("kPicCount",iPic);
}
$('#upFile').change(function(){
if($('#upFile').val()!="")
{
$("#wapUploadBtn").before('<li><img src="/images/wait.gif" class="previewWait" /></li>');
}
$("#upFileForm").ajaxSubmit({url:"/inc/kfUpload.aspx",
type:"POST",
success:function(response){
var data=eval("("+response+")");
if(data.status=="1")
{
$("#wapUploadBtn").prev().html('<div><img src="/'+data.pic+'" height="100" width="100" /></div><div class="previewDel" onclick="delUp(\''+data.pic+'\')">&times;</div>');  
$("#piclist").val($("#piclist").val()+data.pic+",");
iPic++;
setCookie("kPicCount",iPic);
}
else
{
	$("#wapUploadBtn").prev().remove();
  	alert(data.ps);
}
  },
  error:function(msg){
  }
});
$('#upFile').val('');
});


$('#upFile1').change(function(){
if($('#upFile1').val()!="")
{
	$("#pic1").attr('src',"/images/wait.gif");
}
$("#upFileForm1").ajaxSubmit({url:"/inc/kfUpload.aspx",
type:"POST",
success:function(response){
var data=eval("("+response+")");
if(data.status=="1")
{
	valiUpPic('inputpic1','pic1',data.pic);
}
else
{
	valiUpPic('inputpic1','pic1',data.pic);
  	alert(data.ps);
}
},
  error:function(msg){
  }
});
$('#upFile').val('');
});


function valiUpPic(picInputId,picId,picValue)
{
	if(picValue!="")
	{
		if($("#"+picInputId)!=null)
		{
  			$("#"+picInputId).val(picValue);
		}
	}
	if($("#"+picId)!=null)
	{
		if($("#"+picInputId).val()!="")
		{
		    if(picValue.toLowerCase().indexOf("http://")==-1)
		    {
			   	$("#"+picId).attr('src',"/"+$("#"+picInputId).val());
		    }
		    else
		    {
				$("#"+picId).attr('src',$("#"+picInputId).val());
			}
		}
		else
		{
			$("#"+picId).attr('src','/user/images/nophoto.png');
		}
	}
  }
</script>
</td>
</tr>
<tr>
<td class="head">产品介绍：</td><td>
<textarea class="inputTextarea" name="content" id="content" rows="8"></textarea></td>
</tr>
</table>
<div class="clear10"></div>
<input type="submit" class="postSubmit" value="发布产品" />
</form>
</div></div>
</div></div>
<div class="clear80"></div>
</body>
</html>
