protected void Page_Load(object sender, EventArgs e) { redis_key = this.Request["redis_key"]; if (string.IsNullOrWhiteSpace(redis_key)) { msg = "请通过微信扫二维码打开"; return; } //this.Session["currWXOpenId"] = "o99IZtyEBvRNSv54Nt-AzpoqI2Kk"; if (this.Session["currWXOpenId"] == null) { msg = "请用微信打开"; return; } string opendId = this.Session["currWXOpenId"].ToString(); curUser = bllUser.GetUserInfoByOpenId(opendId, bllUser.WebsiteOwner); if (curUser == null) { msg = "该微信未绑定账号"; return; } int tport = ZentCloud.Common.ConfigHelper.GetConfigInt("WebSocketPort"); if (tport != 0) { port = tport; } QRCodeLoginRedis qrReids = new QRCodeLoginRedis(); try{ qrReids = RedisHelper.RedisHelper.StringGet <QRCodeLoginRedis>(redis_key); } catch (Exception ex) { msg = "redis服务错误"; return; } if (qrReids == null) { msg = "redis记录未找到"; return; } qrReids.userID = curUser.UserID; RedisHelper.RedisHelper.StringSetSerialize(redis_key, qrReids, TimeSpan.FromHours(1)); status = true; msg = "微信用户已找到,请点击登录"; }
public void ProcessRequest(HttpContext context) { string redis_key = context.Request["redis_key"]; QRCodeLoginRedis qrReids = new QRCodeLoginRedis(); try { qrReids = RedisHelper.RedisHelper.StringGet <QRCodeLoginRedis>(redis_key); } catch (Exception ex) { apiResp.code = (int)ZentCloud.BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "redis服务错误"; bllUser.ContextResponse(context, apiResp); return; } if (qrReids == null) { apiResp.code = (int)ZentCloud.BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "redis中未找到登录用户"; bllUser.ContextResponse(context, apiResp); return; } UserInfo curUser = bllUser.GetUserInfo(qrReids.userID, bllUser.WebsiteOwner); if (qrReids == null) { apiResp.code = (int)ZentCloud.BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "登录用户未找到"; bllUser.ContextResponse(context, apiResp); return; } bllUser.UpdateLastLoginInfo(curUser.UserID, "", "", "", bllUser.WebsiteOwner); context.Session[SessionKey.UserID] = curUser.UserID; context.Session[SessionKey.LoginStatu] = 1; apiResp.status = true; apiResp.code = (int)ZentCloud.BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "登录成功"; apiResp.result = new { id = curUser.AutoID, username = curUser.UserID, nickname = bllUser.GetUserDispalyName(curUser), avatar = bllUser.GetUserDispalyAvatar(curUser), im_token = curUser.IMToken }; bllUser.ContextResponse(context, apiResp); }