Esempio n. 1
0
    public static string ValidatePhone(string code)
    {
        if (code.Length != 6)
        {
            return("验证码无效");
        }
        int    userId = LoginHelper.GetUserID();
        string result = string.Empty;

        try
        {
            mobile_services mobileServices = new mobile_services(); //web services
            mobileServices.UserAgent = "bulo.hujiang.com" + "|" + "hjbulo_9A263AC7F9584ffd8537655D5AB17AE4";
            result = mobileServices.ValidSMS(code, userId);
            switch (result)
            {
            case "0": result = "验证码无效"; break;      //无效验证码

            case "1": result = "ok"; break;         //验证通过

            case "-1": result = "ok"; break;        //已经验证过

            case "-2": result = "请重新获取"; break;     //尚未生成验证码

            case "-3": result = "已过期,请重新获取"; break; //30分钟内有效期

            default: break;
            }
        }
        catch (Exception)
        {
        }
        return(result);
    }
Esempio n. 2
0
    /// <summary>
    /// 检查是否绑定了手机号
    /// </summary>
    /// <param name="userID"></param>
    /// <returns></returns>
    public static bool CheckIsBinded(int userID)
    {
        string phoneNumber = string.Empty;

        bool hasMobile = false;

        try
        {
            mobile_services mobileServices = new mobile_services(); //web services
            mobileServices.UserAgent = "bulo.hujiang.com" + "|" + "hjbulo_9A263AC7F9584ffd8537655D5AB17AE4";
            mobileServices.CheckIsHasMobile(userID, out hasMobile, out phoneNumber);
        }
        catch (Exception)
        {
        }
        return(hasMobile);
    }
Esempio n. 3
0
    public static string SendValidateCode(string phoneNumber)
    {
        //数据校验
        int userId = LoginHelper.GetUserID();

        if (userId <= 0)
        {
            return("请登录");
        }
        var result = string.Empty;

        if (!System.Text.RegularExpressions.Regex.IsMatch(phoneNumber, "^[1][3-8]+\\d{9}"))
        {
            return("暂只支持大陆手机号");
        }

        try
        {
            mobile_services mobileServices = new mobile_services(); //web services
            mobileServices.UserAgent = "bulo.hujiang.com" + "|" + "hjbulo_9A263AC7F9584ffd8537655D5AB17AE4";
            result = mobileServices.SendSms(phoneNumber, userId);
            switch (result)
            {
            case "-1": result = "请1分钟后重新获取"; break;

            case "1": result = "ok"; break;

            case "-2": result = "该手机号已经被使用"; break;    //已经绑定过

            default: break;
            }
        }
        catch (Exception)
        {
        }

        return(result);
    }