﻿
//编辑用户提交的简介内容
function EiditSynopsis(synid,currentpage)
{
    var url = "EiditSynopsis.aspx?synid="+synid;
    new Ajax.Request(url,
    {
    onSuccess:function(result){
    Dialog.confirm({url:url},
    {
    id:"pointDialog",
    width:650,
    height:650,
    title:"",
    className:"alphacube",okLabel: "确定", cancelLabel:"取消", ok:
    function(){ 
    submitSynopsis(synid,currentpage);
            Dialog.cancelCallback();
    }
    }
    );
    }
    }
    );
}

//确认用户提交的简介内容
function submitSynopsis(id,currentpage)
{
    var synopsis=document.getElementById("synopsis").value;
    var shopname=document.getElementById("shopname").value;
    if(synopsis=="")
    {
        document.getElementById("errinfo").innerHTML="<font color='red'>请填写内容！</font>";
        document.getElementById("synopsis").focus();
        return false;
    }
    if(shopname=="")
    {
        document.getElementById("errinfo").innerHTML="<font color='red'>请填写标题！</font>";
        document.getElementById("shopname").focus();
        return false;
    }

        var data="synopsis="+encodeURIComponent(synopsis)+"&synopsisID="+id+"&shopname="+shopname;
         new Ajax.Request("Synopsis.ashx",
         {method:"post",
         parameters:data,
         onSuccess:function(transport){
         var result = transport.responseText;
		 if(result =="Success"){
		    Showpage(0,currentpage);
		    Dialog.okCallback();
		 }
		 else{
		 document.getElementById("errinfo").innerHTML="<font color='red'>信息添加失败</font>";
		 return false;}
         },
         onFailure:function(){dialog("信息提交失败！");}
         }
         );
}

//删除简介内容
function DelSynopsis(syid,shopid,type,currentpage)
{
    if (confirm("确实要删除吗？"))
    {
        CheckPass(syid,shopid,type,currentpage)
    }
}

//简介审核通过
function CheckPass(syid,shopid,type,currentpage)
{
       var data="synopsisID="+syid+"&type="+type+"&shopid="+shopid;
        new Ajax.Request("CheckSynopsisPass.ashx?"+data,
         {method:"post",
         parameters:data,
         onSuccess:function(transport){
         var result = transport.responseText;
		 if(result =="Success")
		 {
		    Showpage(0,currentpage);
		 }
		 else
		 {
		    dialog("操作执行失败！");
		 }
         },
         onFailure:function(){dialog("对不起，信息提交失败！");}
         }
         );
}

//图片审核通过
function CheckImgPass(imgid,command,username,currentpage)
{
    
     var data="imgID="+imgid+"&command="+command+"&username="+username;
     new Ajax.Request("CheckImgPass.ashx?"+data,
     {method:"post",
     parameters:data,
     onSuccess:function(transport){
      var result = transport.responseText;
	 if(result =="Success")
	 {
//         dialog("操作执行成功！");
         Showpage(1,currentpage);
	 }
	 else
	 {
	    dialog("<span style=\"color:red;\">操作执行失败！</span>");
	 }
      },
      onFailure:function(){dialog("对不起，信息提交失败！");}
      }
      );
}

//删除用户提交的内容或者图片
function DelImg(syid,type,username,currentpage)
{
    if (confirm("确实要删除吗？"))
    {
        CheckImgPass(syid,type,username,currentpage)
    }
}

//添加新的积分操作
function GetPoint(pid)
{
    var url = "Point_Dialog.aspx?pid="+pid;
    new Ajax.Request(url,
    {
    onSuccess:function(result){
    Dialog.confirm({url:url},
    {
    id:"pointDialog",
    width:360,
    height:300,
    title:"",
    className:"alphacube",okLabel: "确定", cancelLabel:"取消", ok:
    function(){ 
    UpdataPoint(pid,"update");
            Dialog.cancelCallback();
    }
    }
    );
    }
    }
    );
}
//更新积分操作的项目
function UpdataPoint(pid,command)
{
    var data="pid="+pid+"&command="+command;
    if (command != "delete")
    {
        var pointid = document.getElementById("txtpointid").value;
        var title = document.getElementById("txttitle").value;
        var point = document.getElementById("txtpoint").value;
        var state = document.getElementById("ddlState").value;
        var count = document.getElementById("txtcount").value;
        var limit = document.getElementById("txtlimit").value;
        var description = document.getElementById("txtdescription").value;
        data += "&pointid="+encodeURIComponent(pointid)+"&title="+encodeURIComponent(title)+"&point="+point+"&state="+state+"&count="+count+"&limit="+limit+"&description="+encodeURIComponent(description);
    }
        new Ajax.Request("CheckPoint.ashx?"+data,
        {method:"post",
        parameters:data,
        onSuccess:function(transport){
         var result = transport.responseText;
		 if(result =="Success")
		 {
//            dialog("操作执行成功！");
            Showpage(2);
		 }
		 else
		 {
		    dialog("<span style=\"color:red;\">操作执行失败！</span>");
		 }
         },
         onFailure:function(){dialog("对不起，信息提交失败！");}
         }
         );
}
//开启或者关闭积分
function openPoint(pid,command)
{
       var data="pid="+pid+"&command="+command;
        new Ajax.Request("CheckPoint.ashx?"+data,
        {method:"post",
        parameters:data,
        onSuccess:function(transport){
         var result = transport.responseText;
		 if(result =="Success")
		 {
//            dialog("操作执行成功！");
            Showpage(2);
		 }
		 else
		 {
		    dialog("<span style=\"color:red;\">操作执行失败！</span>");
		 }
         },
         onFailure:function(){dialog("对不起，信息提交失败！");}
         }
         );
}

//删除积分操作项目
function DeletePoint(pid,command)
{
    if (confirm("确实要删除吗？"))
    {
        UpdataPoint(pid,command)
    }
}

//用户提交的宝贝审核通过
function CheckShopPass(shopid,command,username,currentpage)
{
     var data="ShopID="+shopid+"&command="+command+"&username="+encodeURIComponent(username);
     new Ajax.Request("CheckShopPass.ashx?"+data,
     {method:"post",
     parameters:data,
     onSuccess:function(transport){
      var result = transport.responseText;
	 if(result =="Success")
	 {
//         dialog("操作执行成功！");
         Showpage(3,currentpage);
	 }
	 else
	 {
	    dialog("<span style=\"color:red;\">操作执行失败！</span>");
	 }
      },
      onFailure:function(){dialog("对不起，信息提交失败！");}
      }
      );
}

//删除用户提交的宝贝
function Delshop(shopid,type,username,currentpage)
{
    if (confirm("确实要删除吗？"))
    {
        CheckShopPass(shopid,type,username,currentpage)
    }
}


//审核会员提交的举报内容
function CheckReport(pass,rid,type,ruserid,currentpage)
{
    var point = 0;
    var data = "type="+type+"&rid="+rid+"&pass="+pass+"&ruserid="+ruserid;
    //审核通过
    if(pass == "pass")
    {
    var url = "CheckReport_Dialog.aspx?type="+type;
    new Ajax.Request(url,
    {
    onSuccess:function(result){
    Dialog.confirm({url:url},
    {
    id:"CheckReportDialog",
    width:300,
    height:100,
    title:"",
    className:"alphacube",okLabel: "确定", cancelLabel:"取消", ok:
    function(){
            point = document.getElementById("point").value;
            CheckReportResult(data+"&point="+point);
            Dialog.cancelCallback();
    }
    }
    );
    }
    }
    );
    }
    else if(pass == "refuse")
    {
        CheckReportResult(data,currentpage);
    }
}
//最后处理程序
function CheckReportResult(data,currentpage)
{
    new Ajax.Request("CheckReport.ashx?"+data,
    {
        method:"post",
        parameters:data,
        onSuccess:function(transport){
         var result = transport.responseText;
	    if(result =="Success")
	    {
//            dialog("操作执行成功！");
            Showpage(4,currentpage);
	    }
	    else
	    {
	       dialog("<span style=\"color:red;\">操作执行失败！</span>");
	    }
        },
        onFailure:function(){dialog("对不起，信息提交失败！");}
    }
    );
}