$(function(){

	$("#submitBtn").click(function(){

		var payId = $("#payId").val();
		var name = $("#name").val();
		var status = $("#status").val();
		var icon = $("#icon").val();
		var sign = $("#sign").val();
		var partner= $("#partner").val();
		var appId = $("#appId").val();
		var ukey= $.trim($("#ukey").val());
		var pubKey= $.trim($("#pubKey").val());
		var notifyUrl = $.trim($("#notifyUrl").val());
		var returnUrl = $.trim($("#returnUrl").val());
		var showUrl = $.trim($("#showUrl").val());
		
		// 参数校验
		if(payId==undefined ||payId==''||payId=='0'){
			if(name==''||sign==''){
				layer.msg('支付名和标识为空！',{icon: 5});
				return;
			}
		}
		
		var params = {
				payId:payId,
				name:name,
				icon:icon,
				sign:sign,
				partner:partner,
				status:status,
				appId:appId,
				ukey:ukey,
				pubKey:pubKey,
				notifyUrl:notifyUrl,
				returnUrl:returnUrl,
				showUrl:showUrl
		};

		var	_httpURL = HttpRest+"/paytype/save.shtml";
		if(payId==undefined ||payId==''||payId=='0'){
			_httpURL = HttpRest+"/paytype/create.shtml";
		}
		$.ajax({
			url: _httpURL, 
			type: "post", 
			dataType: "json",
			data:$.toJSON(params),   
			contentType:"application/json",
			success: function(data) { 
				if(data.code=='01'){
					layer.confirm('保存成功！是否关闭窗口?', function(index) {
						parent.grid.loadData();
						parent.layer.close(parent.pageii);
						return false;
					});
				}else{
					layer.msg('保存失败！',{icon: 5});
				}
			}
		});
	});

	onloadurl();
});