public DataResult BindTel(string mobile, string password, string msgCode, string inviterId) { var result = new DataResult("true", "绑定成功", null, null); var vCode = VerifyCode.GetDetail(mobile); if (vCode == null || vCode.ExpireDt < DateTime.Now) { result = new DataResult("false", "验证码已过期", null, null); } else if (vCode.Code != msgCode) { result = new DataResult("false", "验证码错误", null, null); } else { var user = App.DAL.User.Get(mobile: mobile); if (user != null) { result = new DataResult("false", "当前手机号码已被其他人使用", null, null); } else { //OAuthAccessTokenResult oauthResult = OAuthApi.GetAccessToken(WeChatHelper.AppID, WeChatHelper.AppSecret, userToken); //OAuthUserInfo userInfo = OAuthApi.GetUserInfo(oauthResult.access_token, oauthResult.openid); OAuthUserInfo userInfo = Asp.GetSession("OAuthUserInfo") as OAuthUserInfo; user = new User(); user.Name = mobile; user.Password = PasswordHelper.CreateDbPassword(password); user.NickName = userInfo.nickname; user.WechatOpenId = userInfo.openid; user.Photo = userInfo.headimgurl; user.Mobile = mobile; user.Phone = mobile; user.CreateDt = DateTime.Now; user.InUsed = true; user.Gender = userInfo.sex == 1 ? "男" : "女"; user.Roles = new List <RoleType>() { RoleType.Customer }; user.Save(); LoginSuccess(user); if (inviterId != "-1" && DESEncrypt.DecryptDES(inviterId) != inviterId)//这个解密失败,会返回传入的值 { inviterId = DESEncrypt.DecryptDES(inviterId); User inviter = User.Get(inviterId.ToInt32()); if (inviter != null) { //注册成功,才记录邀请记录 Invite invite = new Invite(); invite.InviterID = inviter.ID; invite.InviteeID = user.ID; invite.InviteeMobile = mobile; invite.Sts = InviteStatus.New; invite.Source = InviteSource.WeiXin; invite.CreateDt = DateTime.Now; invite.RegistDt = user.CreateDt; invite.Save(); result = new DataResult("true", "受邀,绑定成功", null, null); } } } } return(result); }
public static string TestSession(string info) { Asp.SetSession("info", info); return(Asp.GetSession <string>("info")); }