﻿function NqV2() {
    this.result = "";
    function Ajax(view, Idata,Ifunction) {
        $.ajax({
            url: "/Ajax.aspx?action=User&View=" + view,
            data: Idata,
            type: "post",
            success: Ifunction,
            error: ajaxError
        });
    }
    this.Ajax = Ajax;
    function ajaxError(rp) {
        if (rp.status == 365) {
            eval("e=" + rp.responseText);
            alert(e.msg); return false;
        }
        //else { alert(rp.responseText); }
    }
    this.login = function(userName, passWord, CheckCode) {
        if (userName == "") {
            alert("请填写用户名！"); return false;
        }
        if (passWord == "") {
            alert("请填写登录密码！"); return false;
        }
        if (CheckCode == "") {
            alert("请填写验证码！"); return false;
        }
        var dat = "userName=" + userName + "&passWord=" + passWord + "&checkCode=" + CheckCode;
        $.ajax({
            type: "post",
            url: "/Ajax.aspx?action=User&View=Login",
            data: dat,
            success: function(res) {
                if (res == "5") {
                    alert("您输入的用户帐号或密码错误！"); return false;
                }
                else if (res == "2") {
                    alert("请输入正确的验证码！"); return false;
                }
                else if (res == "3") {
                    alert("您的帐号正在审核，请等待客服审核！"); return false;
                }
                else if (res == "4") {
                    alert("您的帐号状态不正常，请您联系客服！"); return false;
                }
                else if (res == "0") {
                    window.location = "Affiliate_Index.aspx"; return false;
                }
                else if (res == "1") {
                    window.location = "Advertiser_Index.aspx"; return false;
                }
                return false;
            },
            error: ajaxError
        });
    }
    this.webContent = function(contentID, Ifunction) {
        Ajax("GetWebContent", "contentID=" + contentID,Ifunction);
    }
    this.showHomeAd = function(Ifunc) {
        Ajax("showHomeAd", "", Ifunc);
    }
    this.GetLoginInfos = function(Ifunc) {
        Ajax("GetLoginInfos", "", Ifunc);
    }
    this.MyRound=function(num, digit) {
        return (num * Math.pow(10, digit) / Math.pow(10, digit)).toFixed(digit);
    }
    Number.prototype.toFixed = function(digit) {
        var s, temp, add = 0, s1 = this + "";
        var start = s1.indexOf(".");
        if (s1.substr(start + digit + 1, 1) >= 5) {
            add = 1;
        }
        temp = Math.pow(10, digit);
        if (this > 0) {
            s = Math.floor(this * temp) + add;
        }
        else {
            s = Math.round(this * temp) + add;
        }
        return s / temp;
    }
    this.Copy = function(str) {
        clipboardData.setData('text', str);
    }
}
var nq = new NqV2();
