|
|
|
@ -34,10 +34,7 @@ public class WxController {
|
|
|
|
|
@Operation(summary = "小程序登录-回收员端")
|
|
|
|
|
@GetMapping("/hsyLogin")
|
|
|
|
|
public String login(@RequestParam("code") String code) {
|
|
|
|
|
// System.out.println("===========小程序登录-回收员端=============");
|
|
|
|
|
// System.out.println(appid);
|
|
|
|
|
// System.out.println(appsecret);
|
|
|
|
|
// System.out.println(code2Session);
|
|
|
|
|
log.info("小程序登录-回收员端:{}",code);
|
|
|
|
|
String url = code2Session+"?appid="+appid+"&secret="+appsecret+"&js_code="+code+"&grant_type=authorization_code";
|
|
|
|
|
return HttpUtil.sendHttpGet(url);
|
|
|
|
|
}
|
|
|
|
@ -45,12 +42,17 @@ public class WxController {
|
|
|
|
|
@Operation(summary = "小程序获取绑定的手机号-回收员端")
|
|
|
|
|
@PostMapping("/hsyGetPhone")
|
|
|
|
|
public String hsyGetPhone(@RequestBody WxLoginParam wxLoginParam) {
|
|
|
|
|
// todo
|
|
|
|
|
// https://blog.csdn.net/qq_40705355/article/details/114049093
|
|
|
|
|
log.info("微信用户登录:{}",wxLoginParam.getCode());
|
|
|
|
|
String url = code2Session+"?appid="+appid+"&secret="+appsecret+"&js_code="+wxLoginParam.getCode()+"&grant_type=authorization_code";
|
|
|
|
|
String loginResult = HttpUtil.sendHttpGet(url);
|
|
|
|
|
JSONObject loginResultObject = JSONObject.parseObject(loginResult);
|
|
|
|
|
// 登录失败
|
|
|
|
|
if(null != loginResultObject.get("errcode")){
|
|
|
|
|
return loginResult;
|
|
|
|
|
}
|
|
|
|
|
// 登录成功
|
|
|
|
|
String sessionKey = (String) loginResultObject.get("session_key");
|
|
|
|
|
JSONObject decrypt = decrypt(sessionKey,wxLoginParam.getEncryptedData(), wxLoginParam.getIv());
|
|
|
|
|
decrypt.put("sessionKey",sessionKey);
|
|
|
|
|