/// <summary>
 /// 检查会员账号
 /// </summary>
 /// <param name="field"></param>
 /// <param name="userid"></param>
 /// <returns></returns>
 public JsonResult checkcode(string usercode)
 {
     using (var manage = new Data.CMSManage())
     {
         var userid = manage.checkUserBindCode(usercode);
         return(this.getResult(manage.Error, manage.Message, new { UserId = userid }));
     }
 }
Exemple #2
0
        public JsonResult registerAccount(string account, string password, string accounttype, Entity.UserInfo userinfo, string verifykey)
        {
            var code = Config.UserConfig.getVerifyCode(account);

            if (code != null && code.Code.Equals(verifykey.ToLower()))
            {
                if (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(accounttype))
                {
                    accounttype = accounttype.ToLower();
                    if (accounttype == "mobile")
                    {
                        if (!Utils.isMobile(account))
                        {
                            return(this.getResult(Entity.Error.错误, "手机格式正确"));
                        }
                    }
                    else if (accounttype == "email")
                    {
                        if (!Utils.isEmail(account))
                        {
                            return(this.getResult(Entity.Error.错误, "email格式不正确"));
                        }
                    }
                    using (var manage = new Data.CMSManage())
                    {
                        if (manage.checkUserBindCode(accounttype, account) > 0)
                        {
                            return(this.getResult(Entity.Error.错误, "账号已存在"));
                        }
                        if (userinfo == null)
                        {
                            userinfo = new Entity.UserInfo();
                        }
                        if (string.IsNullOrEmpty(userinfo.UserName))
                        {
                            if (accounttype == "mobile")
                            {
                                userinfo.UserName = Utils.fuzzyString(account, 3, 4);
                            }
                            else if (accounttype == "email")
                            {
                                var name = Utils.subString(account, account.IndexOf('@'));
                                userinfo.UserName = Utils.fuzzyString(account, 1, name.Length - 1);
                            }
                            else
                            {
                                userinfo.UserName = Utils.fuzzyString(account, 1, account.Length - 1);
                            }
                        }
                        else if (manage.checkUserName(userinfo.UserName, -1) > 0)
                        {
                            return(this.getResult(Entity.Error.错误, "昵称已存在"));
                        }

                        userinfo.InDate = DateTime.Now;
                        userinfo.IP     = Fetch.getClientIP();

                        //默认会员
                        if (userinfo.RoleId <= 0)
                        {
                            var roleInfo = manage.getRoleByScore("score", 0);
                            if (roleInfo != null)
                            {
                                userinfo.RoleId       = roleInfo.RoleId;
                                userinfo.VerifyMember = 1;
                            }
                        }

                        //提交注册
                        manage.updateUser(userinfo);

                        if (userinfo.UserId > 0)
                        {
                            //设置密码
                            manage.updatePassword(userinfo.UserId, Entity.passwordType.user, password);
                            //绑定会员
                            manage.updateUserBind(accounttype, userinfo.UserId, account, userinfo.UserName, 1);

                            //更改积分
                            manage.insertScoreLog(userinfo.UserId, "register");

                            //设置会员在线
                            Config.UserConfig.setUserOnline(userinfo);
                        }
                        return(this.getResult(Entity.Error.请求成功, "注册成功", new { userid = userinfo.UserId }));
                    }
                }
                else
                {
                    return(this.getResult(Entity.Error.错误, "数据不完整"));
                }
            }
            else
            {
                return(this.getResult(Entity.Error.错误, "验证码错误"));
            }
        }