/// <summary>/// 登录接口/// </summary>/// <param name="sessionId">客户端sessionid</param>/// <param name="code">公众号授权code</param>/// <returns>{userInfo:xxxx, token:xxxx}</returns>[HttpGet][AllowAnonymous]public async Task Login(string sessionId, string? code = null){if (string.IsNullOrEmpty(code)){string redirect_uri = HttpUtility.UrlEncode(Request.GetDisplayUrl());//授权后跳转回来Response.Redirect($"https://open.weixin.qq.com/connect/oauth2/authorize?appid={APPID}&redirect_uri={redirect_uri}&response_type=code&scope=SCOPE&state=STATE#wechat_redirect");}else{string openId = await WechatServices.GetOpenId(code);var result = adminServices.Login(openId);if (result.Code == 0){Redis_Utility.Set($"expert_admin_login_{sessionId}", result.Data, 1);string html = htmlTemp.Replace("$content", "登录成功");await Response.WriteAsync(html);}else{await Response.WriteAsync(result.Message);}}}
码字辛苦,如果觉得有参考价值请点个赞,如果有看不懂的地方欢迎提问,如果有更好更简单的办法欢迎指教!
推荐阅读
- 右键弹窗的微信截屏方法
- 微信新功能:关于微信群
- 如何自建微信外卖平台_打造微信外卖平台,就是这么简单
- 6个赞不绝口的微信小程序,免费且实用,请低调使用
- 2021最新的微信昵称有哪些?
- 幽默成熟的男微信昵称有哪些?
- 红包封面怎么弄?
- |领导在微信工作群转发文章,缺心眼立即点赞,高手从不点这6种赞
- 科技|再也不怕忘带钥匙了:男生自制人脸识别门禁还带微信推送!
- 微信背景视频怎么设置?