	$(function(){
	$("#dealorderbuyform").submit(function(){	
		$("#MemberMyorder").attr("disabled", true).text("支付中，请稍候");
		var aa = $("input[name='paytype']:checked").val();
		if($("input[name='paytype']:checked").length==0)
		{
			$.ajax({
			  url: "/public/ajax.aspx?action=updateorder&id="+$("#tuangouid").val(),
			  cache: false,
			  success:function(data)
			  {
				  if(data=="0")
				  {
					 alert("支付成功！");
					 window.location.href=wapurl+"m/morder.aspx";
				  }
				  else
				  {
					  alert(data);
					  $("#MemberMyorder").attr("disabled", false).text("立即支付");
				  }
			  }
			});	
			return false;
		}
		else
		{
			
			if(aa=="1" )
			{
				$("#dealorderbuyform").attr("action",SiteWebUrl+"BankPay/AlipayWap/AliPayWapDefault.aspx?action=shoppay");
				return true;
			}
			else if(aa=="2" )
			{
				$("#dealorderbuyform").attr("action",SiteWebUrl+"BankPay/AlipayWap/AlipayWebDefault.aspx?action=shoppay");
				return true;
			}
			else if(aa=="3"){
				$("#dealorderbuyform").attr("action",SiteWebUrl+"BankPay/YeePayWap/YeePayWap_Default.aspx?action=shoppay&paytype=0");
				return true;	
			}
			else if(aa=="4" ){
				$("#dealorderbuyform").attr("action",SiteWebUrl+"BankPay/YeePayWap/YeePayWap_Default.aspx?action=shoppay&paytype=1");
				return true;	
			}
			else if(aa=="5" ){
				$("#dealorderbuyform").attr("action",SiteWebUrl+"payment/weixinpay/jsapi/JsApiPayPage.aspx?action=shoppay&showwxpaytitle=1");
				return true;	
			}
			var aa = $("input[name='paytype']:checked").val();
		}
	});
	$(".choose").find("input[name='paytype']").each(function(){
		$(this).click(function(){
			if( $(this).val()=="0" )
			{
				$("#paymoneytitle").html("<em>*</em>充值卡号");
			}
			else{
				$("#paymoneytitle").html("<em>*</em>充值金额");
			}
		});
	});
	$("#MemberMoneyPayForm").submit(function(){	
		$("#MemberMoneyPaySubmit").attr("disabled", true).text("充值中，请稍候");
		var aa = $("input[name='paytype']:checked").val();
		if(aa=="0")
		{
			var val=$("#account-charge-money").val();
			if(val.length<2 || val.length> 20 )
			{
				alert("对不起，请正确输入充值卡卡号。");
				$("#MemberJifenPaySubmit").attr("disabled", false).text("立即充值");
				return false;
		    }
			//充值卡号
			$.ajax({
			  url: "/public/ajax.aspx?action=ConsumeSave&shu="+$("#account-charge-money").val(),
			  cache: false,
			  success:function(data)
			  {
				  if(data.length<10)
				  {
					alert("充值成功，充值卡面额为"+data+"元。");
					window.location.href=wapurl+"m/moneylist.aspx";
				  }
				  else{
					alert(data);
					$("#MemberMoneyPaySubmit").attr("disabled", false).text("立即充值");
				  }
			  }
			});
		    return false;
		}
		else
		{
			var val=$("#account-charge-money").val();
			var re=/^[1-9]+[0-9]*]*$/;
			if(!re.test(val))
			{
				alert("对不起，充值金额请填写整数。");
				$("#MemberMoneyPaySubmit").attr("disabled", false).text("立即充值");
				return false;
			}
			if(aa=="1" )
			{
				$("#MemberMoneyPayForm").attr("action",SiteWebUrl+"BankPay/AlipayWap/AliPayWapDefault.aspx?action=moneypay");
				return true;
			}
			else if(aa=="2" )
			{
				$("#MemberMoneyPayForm").attr("action",SiteWebUrl+"BankPay/AlipayWap/AlipayWebDefault.aspx?action=moneypay");
				return true;
			}
			else if(aa=="3"){
				$("#MemberMoneyPayForm").attr("action",SiteWebUrl+"BankPay/YeePayWap/YeePayWap_Default.aspx?action=moneypay&paytype=0");
				return true;	
			}
			else if(aa=="4" ){
				$("#MemberMoneyPayForm").attr("action",SiteWebUrl+"BankPay/YeePayWap/YeePayWap_Default.aspx?action=moneypay&paytype=1");
				return true;	
			}
			else if(aa=="5" ){
				$("#MemberMoneyPayForm").attr("action",SiteWebUrl+"payment/weixinpay/jsapi/JsApiPayPage.aspx?action=moneypay&showwxpaytitle=1");
				return true;	
			}
		}
	});
	$("#MemberJifenPayForm").submit(function(){	
		$("#MemberJifenPaySubmit").attr("disabled", true).text("充值中，请稍候");
		var aa = $("input[name='paytype']:checked").val();
		if(aa=="0")
		{
			var val=$("#account-charge-money").val();
			if(val.length<2 || val.length> 20 )
			{
				alert("对不起，请正确输入充值卡卡号。");
				$("#MemberJifenPaySubmit").attr("disabled", false).text("立即充值");
				return false;
		    }
			//充值卡号
			$.ajax({
			  url: "/public/ajax.aspx?action=JifenConsumeSave&shu="+$("#account-charge-money").val(),
			  cache: false,
			  success:function(data)
			  {
				  if(data.length<10)
				  {
					alert("充值成功，获取积分"+data+"分。");
					window.location.href=wapurl+"m/jifenlist.aspx";
				  }
				  else{
					alert(data);
					$("#MemberJifenPaySubmit").attr("disabled", false).text("立即充值");
				  }
			  }
			});
		    return false;
		}
		else
		{
			var val=$("#account-charge-money").val();
			var re=/^[1-9]+[0-9]*]*$/;
			if(!re.test(val))
			{
				alert("对不起，充值金额请填写整数。");
				$("#MemberJifenPaySubmit").attr("disabled", false).text("立即充值");
				return false;
			}
			if(aa=="1" )
			{
				$("#MemberJifenPayForm").attr("action",SiteWebUrl+"BankPay/AlipayWap/AliPayWapDefault.aspx?action=JifenPay");
				return true;
			}
			else if(aa=="2" )
			{
				$("#MemberJifenPayForm").attr("action",SiteWebUrl+"BankPay/AlipayWap/AlipayWebDefault.aspx?action=JifenPay");
				return true;
			}
			else if(aa=="3"){
				$("#MemberJifenPayForm").attr("action",SiteWebUrl+"BankPay/YeePayWap/YeePayWap_Default.aspx?action=JifenPay&paytype=0");
				return true;	
			}
			else if(aa=="4" ){
				$("#MemberJifenPayForm").attr("action",SiteWebUrl+"BankPay/YeePayWap/YeePayWap_Default.aspx?action=JifenPay&paytype=1");
				return true;	
			}
			else if(aa=="5" ){
				$("#MemberJifenPayForm").attr("action",SiteWebUrl+"payment/weixinpay/jsapi/JsApiPayPage.aspx?action=JifenPay&showwxpaytitle=1");
				return true;	
			}
		}
	});
});
