mirror of
https://gitee.com/elegant_wings/dbd-meeting.git
synced 2025-06-21 18:19:36 +08:00
pc端扫码提示页面更新
This commit is contained in:
parent
43bafa8b59
commit
03c2a0e5e6
@ -13,6 +13,7 @@ import com.ics.system.service.IRoleService;
|
|||||||
import com.ics.system.service.IUserService;
|
import com.ics.system.service.IUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -22,7 +23,9 @@ import org.wf.jwtp.provider.Token;
|
|||||||
import org.wf.jwtp.provider.TokenStore;
|
import org.wf.jwtp.provider.TokenStore;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -70,6 +73,12 @@ public class WxScanController {
|
|||||||
|
|
||||||
private final static String OAUTH2_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
|
private final static String OAUTH2_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
|
||||||
|
|
||||||
|
private static String tipsHtml;
|
||||||
|
|
||||||
|
static {
|
||||||
|
tipsHtml = readHtml("tips.html");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取认证标识及url,有效期1小时
|
* 获取认证标识及url,有效期1小时
|
||||||
* 返回
|
* 返回
|
||||||
@ -80,7 +89,7 @@ public class WxScanController {
|
|||||||
@RequestMapping("/get")
|
@RequestMapping("/get")
|
||||||
public R index() throws IOException {
|
public R index() throws IOException {
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
redis.set("QR:" + uuid, "",3600);
|
redis.set("QR:" + uuid, "", 3600);
|
||||||
String redirectUrl = access + "/wxscan/goin/" + uuid;
|
String redirectUrl = access + "/wxscan/goin/" + uuid;
|
||||||
String encodedUrl = URLEncoder.encode(redirectUrl, "UTF-8");
|
String encodedUrl = URLEncoder.encode(redirectUrl, "UTF-8");
|
||||||
String url = String.format(OAUTH2_URL, appid, encodedUrl);
|
String url = String.format(OAUTH2_URL, appid, encodedUrl);
|
||||||
@ -117,10 +126,10 @@ public class WxScanController {
|
|||||||
redis.set("QR:" + unique, token.getAccessToken(), 3600);//存储token值
|
redis.set("QR:" + unique, token.getAccessToken(), 3600);//存储token值
|
||||||
return "扫码成功";
|
return "扫码成功";
|
||||||
} else {
|
} else {
|
||||||
return "未在公众号绑定手机号或者小程序账号与PC账号未关联";
|
return String.format(tipsHtml, "小程序账号与PC账号端未关联");
|
||||||
}
|
}
|
||||||
} else { //未绑定
|
} else { //未绑定
|
||||||
return "请先在公众号绑定手机号";
|
return String.format(tipsHtml, "在下面小程序注册后,再绑定手机号");
|
||||||
}
|
}
|
||||||
// System.out.println("**************************");
|
// System.out.println("**************************");
|
||||||
// System.out.println(sToken);
|
// System.out.println(sToken);
|
||||||
@ -136,9 +145,8 @@ public class WxScanController {
|
|||||||
* 轮询是否登录
|
* 轮询是否登录
|
||||||
* 参数:unique 认证标识,为get接口获取的字符串
|
* 参数:unique 认证标识,为get接口获取的字符串
|
||||||
* 返回:
|
* 返回:
|
||||||
* code 为500时表示未成功扫码
|
* code 为500时表示未成功扫码
|
||||||
* code 为0 时,表示已经成功扫码登录,可以获取token值
|
* code 为0 时,表示已经成功扫码登录,可以获取token值
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Ignore
|
@Ignore
|
||||||
@RequestMapping("/isLogin/{unique}")
|
@RequestMapping("/isLogin/{unique}")
|
||||||
@ -148,5 +156,17 @@ public class WxScanController {
|
|||||||
return R.ok().put("token", token);
|
return R.ok().put("token", token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String readHtml(String fileName) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
ClassPathResource resource = new ClassPathResource(fileName);
|
||||||
|
try (BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) {
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null) {
|
||||||
|
sb.append(line);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
50
shoot-hand/ics-web/src/main/resources/tips.html
Normal file
50
shoot-hand/ics-web/src/main/resources/tips.html
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh_CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>提示</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login {
|
||||||
|
|
||||||
|
height: 30.5rem;
|
||||||
|
background-color: white;
|
||||||
|
margin: 0rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login_bottom {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login_bottom img {
|
||||||
|
margin-top: 4rem;
|
||||||
|
border: none;
|
||||||
|
background: #3490bf;
|
||||||
|
}
|
||||||
|
.login_bottom p span {
|
||||||
|
margin-top: 2rem;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="box">
|
||||||
|
<div class="login">
|
||||||
|
<div class="login_bottom">
|
||||||
|
<p style="margin-top: 5rem">
|
||||||
|
<span id="info">%s</span>
|
||||||
|
</p>
|
||||||
|
<img src="https://www.hajgfwzx.cn/xcx.jpg" width="80%%">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user