function IsNull(data) {
    data = $.trim(data);
    if (data == '' || data.length == 0)
        return false;
    return true;
}

$(".SaveMPSET").live('click', function () {
    var mpNickName = $("#mpNickName").val();
    if (!IsNull(mpNickName)) {
        $("#mpNickName").focus();
        _alert("请填写微信公众号名称");
        return;
    }
    var mpOrgid = $("#mpOrgid").val();
    if (!IsNull(mpOrgid)) {
        $("#mpOrgid").focus();
        _alert("请填写微信公众号原始ID");
        return;
    }
    var mpwxuser = $("#mpwxuser").val();
    if (!IsNull(mpwxuser)) {
        $("#mpwxuser").focus();
        _alert("请填写微信号");
        return;
    }
    var mpappid = $("#mpappid").val();
    var mpappsec = $("#mpappsec").val();
    var mpfaceurl = $("#mpfaceurl").val();
    var mpfensi = $("#mpfensi").val();

    _alert("正在提交,请稍后...");
    $.ajax({ url: "/Member/SaveMPSet",
        type: "post",
        dataType: "json",
        timeout: 10000,
        data: {
            "mpNickName": mpNickName,
            "mpOrgid": mpOrgid,
            "mpwxuser": mpwxuser,
            "mpappid": mpappid,
            "mpappsec": mpappsec,
            "mpfaceurl": mpfaceurl,
            "mpfensi": mpfensi,
            "_r": Math.random()
        },
        beforeSend: function () {
            $(".SaveMPSET").attr({ "disabled": "disabled" });
        },
        error: function (data, status, e) {
            _alert("保存失败,请稍后重试");
            $(".SaveMPSET").removeAttr("disabled");
        },
        success: function (data) {
            if (data.ErrorCode == 0) {
                if ($(".CONFIGMP").is(":visible")) {
                    $(".CONFIGMP").hide();
                    $(".CONFIGMPINFO").show();
                }
                $(".configedFace").attr("src", mpfaceurl);
                $(".configedNick").html(mpNickName);
                $(".configedUser").html(mpwxuser);
                _alert(data.ErrorStr);
            } else {
                _alert(data.ErrorStr);
            }
            $(".SaveMPSET").removeAttr("disabled");
        }
    });
});

$(".SaveCpy").live('click', function () {
    var hocpy = $("#_haioucpy").val();
    hocpy = $.trim(hocpy);

    if (hocpy == "" || hocpy.length == 0) {
        _alert("请输入版权信息");
        $('#_haioucpy').focus();
        return false;
    }

    _alert("正在保存,请稍后...");
    $.ajax({ url: "/Member/CopyRight",
        type: "post",
        dataType: "json",
        timeout: 10000,
        data: { "memcopy": hocpy,
            "_r": Math.random()
        },
        beforeSend: function () {
            $(".SaveCpy").attr({ "disabled": "disabled" });
        },
        error: function (data, status, e) {
            _alert("保存失败");
            $(".SaveCpy").removeAttr("disabled");
        },
        success: function (data) {
            if (data.ErrorCode == 0) {
                _alert(data.ErrorStr);
                $(".MemCpyData").html(hocpy);
                $(".SaveCpy").removeAttr("disabled");
            } else {
                _alert(data.ErrorStr);
                $(".SaveCpy").removeAttr("disabled");
            }
        }
    });
});
$(".SavememInfo").live('click', function () {
    var email = $("#email").val();
    if (!IsNull(email)) {
        $("#email").focus();
        _alert("请填写邮箱地址");
        return;
    }

    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email)) {
        $("#email").focus();
        _alert('您的电子邮件格式不正确');
        return;
    }
    

    

    var tel = $("#tel").val();
    var qq = $("#qq").val();

    _alert("正在保存,请稍后...");
    $.ajax({ url: "/Member/MemUser",
        type: "post",
        dataType: "json",
        timeout: 10000,
        data: {
            "email": email,
            "tel": tel,
            "qq": qq,
            "_r": Math.random()
        },
        beforeSend: function () {
            $(".SavememInfo").attr({ "disabled": "disabled" });
        },
        error: function (data, status, e) {
            _alert("保存失败");
            $(".SavememInfo").removeAttr("disabled");
        },
        success: function (data) {
            if (data.ErrorCode == 0) {
                _alert(data.ErrorStr);
                $(".SavememInfo").removeAttr("disabled");
            } else {
                _alert(data.ErrorStr);
                $(".SavememInfo").removeAttr("disabled");
            }
        }
    });
});
$(".ChanMemPwd").live('click', function () {

    var oldPwd = $("#oldPwd").val();
    var newPwd = $("#newPwd").val();
    var newPwdR = $("#newPwdR").val();
    if (!IsNull(oldPwd)) {
        $("#oldPwd").focus();
        _alert("请填写原始密码");
        return;
    }
    if (!IsNull(newPwd)) {
        $("#newPwd").focus();
        _alert("请填写新密码");
        return;
    }
    if (!IsNull(newPwdR)) {
        $("#newPwdR").focus();
        _alert("请填写新密码确认");
        return;
    }

    _alert("正在保存,请稍后...");
    $.ajax({ url: "/Member/EditPwd",
        type: "post",
        dataType: "json",
        timeout: 10000,
        data: {
            "oldPwd": oldPwd,
            "newPwd": newPwd,
            "newPwdR": newPwdR,
            "_r": Math.random()
        },
        beforeSend: function () {
            $(".ChanMemPwd").attr({ "disabled": "disabled" });
        },
        error: function (data, status, e) {
            _alert("保存失败");
            $(".ChanMemPwd").removeAttr("disabled");
        },
        success: function (data) {
            if (data.ErrorCode == 0) {
                _alert(data.ErrorStr);
                $(".ChanMemPwd").removeAttr("disabled");
            } else {
                _alert(data.ErrorStr);
                $(".ChanMemPwd").removeAttr("disabled");
            }
        }
    });
});