<%@ page language="C#" autoeventwireup="true" inherits="admin_shop_cpedit, s1.chapk.com" validaterequest="false" %>
<%@ Register Assembly="YangControls" Namespace="YangControls" TagPrefix="yyc" %>

<!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 runat="server">
    <title>添加产品</title>
    <link rel="stylesheet" href="../css/table.css" type="text/css" media="all" /> 
    <script charset="utf-8" src="../editor/jquery.js"></script>
<script charset="utf-8" src="../editor/kindeditor.js"></script>
<script charset="utf-8" src="../editor/lang/zh_CN.js"></script>
<script>
        
			KindEditor.ready(function(K) {
			    var editor = K.create('textarea[name="s_details"]', {
			        uploadJson : '../editor/asp.net/upload_json.ashx',
			        fileManagerJson : '../editor/asp.net/file_manager_json.ashx',
					allowFileManager : true
				});
				
				K('#J_selectImage').click(function() {
					editor.loadPlugin('multiimage', function() {
						editor.plugin.multiImageDialog({
							clickFn : function(urlList) {
								
								K.each(urlList, function(i, data) {
									$("#J_imageView").append('<li><img src="' + data.url + '" class="photo"><input name="photo" type="hidden" value="' + data.url + '" /><span><a href="javascript:;" class="leftli">◄</a><a href="javascript:;" class="rightli">►</a><a href="javascript:;" class="del" imglll="' + data.url + '">X</a></span></li>');	
									
								});
								editor.hideDialog();
							}
						});
					});
				});
			});
			
			$(function(){
				$(".del").live("click",function(){
				    var dobj=$(this);
					$img=$(this).attr("imglll");
					if (confirm("确定删除吗?")){
						$.get("picdel.aspx?Path="+$img,function(data){	
						    if (data)					
							    dobj.parent().parent().remove();
						});
						
					}
				});
				
				$(".leftli").live("click",function(){
				   var obj=$(this).parent().parent();
				   var mimg=obj.find("img").attr("src");
				   var limg=obj.prev().find("img").attr("src");
				   
				   obj.find("img").attr({"src":limg});
				   obj.find("input").val(limg);
				   obj.prev().find("img").attr({"src":mimg});
				   obj.prev().find("input").val(mimg);
			    });
                $(".rightli").live("click",function(){
				   var obj=$(this).parent().parent();
				   var mimg=obj.find("img").attr("src");
				   var limg=obj.next().find("img").attr("src");
				   
				   obj.find("img").attr({"src":limg});
				   obj.find("input").val(limg);
				   obj.next().find("img").attr({"src":mimg});
				   obj.next().find("input").val(mimg);
			    });
			});

        
</script>   
</head>
<body>
    <form id="form1" runat="server">
        <div class="my_alt">添加产品<asp:Label ID="msg" runat="server" ForeColor="Red"></asp:Label></div>
        <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tb">               
            <tr>
                <td class="tl">商品名称：</td>
                <td class="tr"><asp:TextBox ID="s_mc" runat="server" Width="500px"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="请输入商品名称" ControlToValidate="s_mc"></asp:RequiredFieldValidator></td>
            </tr>   
            <tr>
                <td class="tl">关键字：</td>
                <td class="tr"><asp:TextBox ID="taobao" runat="server" Width="500px"></asp:TextBox></td>
            </tr>                   
            <tr>
                <td class="tl">商品类别：</td>
                <td class="tr">
                    <yyc:YangDropDownList ID="dropAddPurview" runat="server"></yyc:YangDropDownList></td>
                </tr>             
            <tr>
                <td class="tl">净含量：</td>
                <td class="tr">
                    <asp:RadioButtonList ID="s_dw" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                        <asp:ListItem Value="500">500克</asp:ListItem>
                        <asp:ListItem Value="250">250克</asp:ListItem>
                        <asp:ListItem Value="50">50克</asp:ListItem>
                        <asp:ListItem Value="75">75克</asp:ListItem>
                        <asp:ListItem Value="100">100克</asp:ListItem>
                        <asp:ListItem Value="125">125克</asp:ListItem>
                        <asp:ListItem Value="150">150克</asp:ListItem>
                        <asp:ListItem Value="200">200克</asp:ListItem>
                        <asp:ListItem Value="300">300克</asp:ListItem>
                        <asp:ListItem Value="1000">1000克</asp:ListItem>
                        <asp:ListItem Value="1500">1500克</asp:ListItem>
                        <asp:ListItem Value="2000">2000克</asp:ListItem>
                    </asp:RadioButtonList>                
                </td>
            </tr>
            <tr>
                <td class="tl">等级：</td>
                <td class="tr">
                    <asp:RadioButtonList ID="s_zl" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                        <asp:ListItem Value="特级">特级</asp:ListItem>
                        <asp:ListItem Value="一级">一级</asp:ListItem>
                        <asp:ListItem Value="二级">二级</asp:ListItem>
                        <asp:ListItem Value="其它">其它</asp:ListItem>
                    </asp:RadioButtonList>                 
                </td>
            </tr>            
            <tr>
                <td class="tl">商品图片：</td>
                <td class="tr">
        <input type="button" id="J_selectImage" value="批量上传" /> 为了方便管理 产品主图只能上传.jpg格式图片
		<ul id="J_imageView"><%=editUploadPicture %></ul>
                
                </td>
            </tr>                                             
            <tr>
                <td class="tl">简介：</td>
                <td class="tr">
<textarea id="s_details" runat="server" name="s_details" style="width:800px;height:300px;"></textarea>
                </td>
            </tr>   
            <tr>
                <td class="tl">库存数量：</td>
                <td class="tr"><asp:TextBox id="s_sl" runat="server" Width="100px"></asp:TextBox>
                </td>
            </tr>            
            <tr>
                <td class="tl">市场价：</td>
                <td class="tr"><asp:TextBox id="s_jg1" runat="server" Width="100px"></asp:TextBox></td>
            </tr>             
            <tr>
                <td class="tl">会员价格：</td>
                <td class="tr"><asp:TextBox id="s_jg" runat="server" Width="100px"></asp:TextBox>格式为金额类型如：53.05</td>
            </tr> 
            <tr>
                <td class="tl"></td>
                <td class="tr"><asp:Button ID="btn_ok" runat="server" Text=" 保存 " OnClick="btn_ok_Click" />
        <asp:Label id="lab_id" runat="server" Visible="False"></asp:Label>
	            </td>
            </tr>      
            <tr>
                <td class="tl"><asp:TextBox ID="kzname" runat="server" Width="80px"></asp:TextBox>：<br /><input onclick="addItem()" type="button" value="增加属性">  </td>
                <td class="tr">
<p id="ItemList"></p>              
<p id="newItem"></p>
<input type="hidden" id="kzvalue" name="kzvalue" value="" />
<script>
var itemstr="<%=kzvalue %>";
showItem();
function showItem(){
    document.getElementById('kzvalue').value=itemstr;
    document.getElementById('ItemList').innerText="";
    if(itemstr+"a"!="a"){
        var tl1=itemstr.split('|');
        for(var i=0;i<tl1.length;i++){
            var tl2=tl1[i].split(',');
            var str = '<BR> 价格:<input type="text" name="text0'+i+'" value="'+tl2[0]+'" /> 显示名称:<input type="text" name="text1'+i+'" value="'+tl2[1]+'" /> <input type="button" value="删除" onclick="itemDel('+i+')" /><input type="button" value="上移" onclick="itemLeft('+i+')" /><input type="button" value="下移" onclick="itemRight('+i+')" />';
            document.getElementById('ItemList').insertAdjacentHTML("beforeEnd",str);
        }
    }
}

function addItem()
{
    var str = '<BR> 价格:<input type="text" id="text00" value="0" /> 显示名称:<input type="text" id="text10" /> <input type="button" value="提交" onclick="itemAdd()" />';
    document.getElementById('newItem').insertAdjacentHTML("beforeEnd",str);
}
function itemAdd()
{
    var jg=document.getElementById('text00').value;
    var mc=document.getElementById('text10').value;
    if(jg+"a"!="a" && mc+"a"!="a"){
        if(itemstr+"a"!="a"){
            itemstr+="|"+jg+","+mc;
        }
        else{
            itemstr=jg+","+mc;
        }
        document.getElementById('newItem').innerText="";
        showItem();    
    }    
}
function itemDel(itemi){
    var nstr="";
    var tl1=itemstr.split('|');
    for(var i=0;i<tl1.length;i++){
        if(i!=itemi)
            nstr+="|"+tl1[i];
    }
    if(nstr+"a"!="a"){
        nstr=nstr.substring(1);
    }
    itemstr=nstr;
    showItem(); 
}
function itemLeft(itemi){
    if(itemi>0){
        var tl1=itemstr.split('|');
        var ls=tl1[itemi-1];
        tl1[itemi-1]=tl1[itemi];
        tl1[itemi]=ls;
        itemstr="";
        for(var i=0;i<tl1.length;i++){
            itemstr+="|"+tl1[i];
        }
        itemstr=itemstr.substring(1);
    }
    showItem(); 
}
function itemRight(itemi){
    var tl1=itemstr.split('|');
    if(itemi<tl1.length-1){
        var ls=tl1[itemi+1];
        tl1[itemi+1]=tl1[itemi];
        tl1[itemi]=ls;
        itemstr="";
        for(var i=0;i<tl1.length;i++){
            itemstr+="|"+tl1[i];
        }
        itemstr=itemstr.substring(1);
    }
    showItem(); 
}
</script>                    
                </td></tr>                                                      
            <tr>
                <td class="tl">参加活动：</td>
                <td class="tr">
                    <asp:RadioButtonList ID="ms" runat="server" RepeatDirection="Horizontal"
                        RepeatLayout="Flow">
                        <asp:ListItem Value="0">无</asp:ListItem>
                        <asp:ListItem Value="1">限时抢购</asp:ListItem>
                        <asp:ListItem Value="2">特价商品</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                </tr>  
            <tr>
                <td class="tl">活动价格：</td>
                <td class="tr">
                    <asp:TextBox ID="msj" runat="server" Width="100px">0</asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" 
                        ControlToValidate="msj" ErrorMessage="格式必需是整数数" 
                        ValidationExpression="^\d+(\.\d+)?$"></asp:RegularExpressionValidator> 如果不是特价商品可不填写
                </td>
                </tr>                 
            <tr>
                <td class="tl">截止时间：</td>
                <td class="tr">
                    <input id="mssj" runat="server" name="mssj" style="width:200px;font-size:18px" type="text" /> 格式:2013-5-10 10:45:60</td>
                </tr>   
            <tr>
                <td class="tl">积分换购：</td>
                <td class="tr">
                    <asp:RadioButtonList ID="score" runat="server" RepeatDirection="Horizontal"
                        RepeatLayout="Flow">
                        <asp:ListItem Value="0">否</asp:ListItem>
                        <asp:ListItem Value="1">是</asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:TextBox id="scores" runat="server" Width="100px"></asp:TextBox> 积分  <span style="color:Red">注意：选择"是"就只出现在积分专区</span>
                </td>
                </tr> 
            <tr>
                <td class="tl">人气：</td>
                <td class="tr"><asp:TextBox id="hits" runat="server" Width="100px"></asp:TextBox>
                </td>
            </tr>                  
            <tr>
                <td class="tl">其它参数：</td>
                <td class="tr">
                    <asp:RadioButtonList ID="p1" runat="server" RepeatDirection="Horizontal"
                        RepeatLayout="Flow">
                        <asp:ListItem Value="0">平凡是真</asp:ListItem>
                        <asp:ListItem Value="1">新品抢鲜</asp:ListItem>
                        <asp:ListItem Value="2">掌柜推荐</asp:ListItem>
                        <asp:ListItem Value="3">茗茶热卖</asp:ListItem>
                    </asp:RadioButtonList>                    
                    </td></tr> 
            <tr>
                <td class="tl">运费：</td>
                <td class="tr">
                    <asp:CheckBox ID="s_fre" runat="server" Text="免运费" />
                </td>
            </tr>                                      
        </table>
    </form>
</body>
</html>
