Commit f0eabeac authored by 曹盼盼's avatar 曹盼盼

修改

parent ec4adb06
...@@ -390,7 +390,7 @@ public class TzsAppService { ...@@ -390,7 +390,7 @@ public class TzsAppService {
public JSONObject wxUserLogin(JSONObject wx) { public JSONObject wxUserLogin(JSONObject wx) {
if (redisUtils.hasKey(WXUSER_TOKEN)) { /* if (redisUtils.hasKey(WXUSER_TOKEN)) {
Object obj= redisUtils.get(WXUSER_TOKEN); Object obj= redisUtils.get(WXUSER_TOKEN);
return JSONObject.parseObject(obj.toString()); return JSONObject.parseObject(obj.toString());
}else { }else {
...@@ -404,23 +404,27 @@ public class TzsAppService { ...@@ -404,23 +404,27 @@ public class TzsAppService {
System.out.println("666"+response.getString("session_key")); System.out.println("666"+response.getString("session_key"));
} catch (Exception e) { } catch (Exception e) {
throw new BadRequest("获取token 出错:" + e.getMessage()); throw new BadRequest("session_key 出错:" + e.getMessage());
} }
if(response.get("session_key") != null) { // 获取token 成功 if(response.get("session_key") != null) { // 获取token 成功
try { try {
redisUtils.set(WXUSER_TOKEN, response,time); redisUtils.set(WXUSER_TOKEN, response,time);
return response; return response;
} catch (Exception e) { } catch (Exception e) {
throw new BadRequest("获取token 出错:" + e.getMessage()); throw new BadRequest("session_key 出错:" + e.getMessage());
} }
} else { } else {
throw new BadRequest("获取token 出错:" + response); throw new BadRequest("session_key 出错:" + response);
} }
} }*/
StringBuffer buffer= new StringBuffer("https://api.weixin.qq.com/sns/jscode2session?appid=")
.append(wx.getString("appid")).append("&secret=").append(wx.getString("secret")).append("&js_code=").append(wx.getString("js_code"))
.append("&grant_type=").append( wx.getString("grant_type"));
String responseStr = HttpUtils.doGet(buffer.toString());
JSONObject response=JSONObject.parseObject(responseStr);
return response;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment