本次实现微信登录功能,主要根据微信官方文档,流程如下
1微信登录接口实现思路,根据申请的,
wx.open.app_id, wx.open.app_secret, wx.open.redirect_url, baseUrl,进行封装,具体如下可参考使用
//生成微信扫描的二维码,在前段显示,弹出框方式 @GetMapping("get") @ResponseBody public Result wxLogin(HttpSession session) throws UnsupportedEncodingException { try { String redirectUri = URLEncoder.encode(ConstantWxPropertiesUtils.WX_OPEN_REDIRECT_URL, "UTF-8"); Map<String, Object> map = new HashMap<>(); map.put("appid", ConstantWxPropertiesUtils.WX_OPEN_APP_ID); map.put("redirectUri", redirectUri); map.put("scope", "snsapi_login"); //可省略 map.put("state", System.currentTimeMillis()+"");//System.currentTimeMillis()+"" return Result.ok(map); } catch (UnsupportedEncodingException e) { e.printStackTr