|
@@ -709,7 +709,7 @@
|
|
|
<div class="report-item">
|
|
|
<form class="layui-form" lay-filter="barsearchform">
|
|
|
<input type="hidden" value="{$vo.id}" name="id">
|
|
|
- <input type="hidden" value="{$vo.project_id}" name="project_id">
|
|
|
+ <input type="hidden" value="{$vo.project_id}" name="project_id" id="project_id">
|
|
|
<div class="report-top" style="justify-content: normal;margin-bottom: 2.5vw;">
|
|
|
<img src="{__MOBILE__}/img/line.png" alt="" style="width: 5vw;height: 4vw;">
|
|
|
<span style="font-size: 2vh;"><b>预约看现场申请</b></span>
|
|
@@ -1115,12 +1115,15 @@
|
|
|
// 清除之前生成的二维码(如果有的话)
|
|
|
document.getElementById('qrcode').innerHTML = "";
|
|
|
|
|
|
- // 获取当前网址
|
|
|
- var currentUrl = window.location.href;
|
|
|
+ var project_id = "{$project_id}"
|
|
|
+
|
|
|
+ // 创建一个固定格式的URL
|
|
|
+ var baseUrl = 'https://www.yiguanfep.com/mobile/temporary/detail?id=';
|
|
|
+ var fullUrl = baseUrl + project_id;
|
|
|
|
|
|
// 生成二维码并显示在页面上
|
|
|
var qrcode = new QRCode(document.getElementById('qrcode'), {
|
|
|
- text: currentUrl,
|
|
|
+ text: fullUrl,
|
|
|
width: 250, // 设置二维码的宽度
|
|
|
height: 250 // 设置二维码的高度
|
|
|
});
|
|
@@ -1143,6 +1146,62 @@
|
|
|
alert('请先生成二维码');
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+//扫描二维码后验证
|
|
|
+ // 使用Express等框架
|
|
|
+ const express = require('express');
|
|
|
+ const axios = require('axios');
|
|
|
+ const app = express();
|
|
|
+
|
|
|
+ // 公众号配置
|
|
|
+ const WECHAT_APPID = 'wx60064e1cac4296e6';
|
|
|
+ const WECHAT_SECRET = 'bce94d361402cc535559a9bbdb908de8';
|
|
|
+
|
|
|
+ // 处理微信授权回调,判断用户是否关注
|
|
|
+ app.get('/wechat/callback', async (req, res) => {
|
|
|
+ const { code } = req.query;
|
|
|
+
|
|
|
+ // 获取access_token
|
|
|
+ try {
|
|
|
+ const tokenResponse = await axios.get(`https://api.weixin.qq.com/sns/oauth2/access_token?appid=${WECHAT_APPID}&secret=${WECHAT_SECRET}&code=${code}&grant_type=authorization_code`);
|
|
|
+ const { access_token, openid } = tokenResponse.data;
|
|
|
+
|
|
|
+ // 获取用户信息,判断是否关注公众号
|
|
|
+ const userResponse = await axios.get(`https://api.weixin.qq.com/cgi-bin/user/info?access_token=${access_token}&openid=${openid}&lang=zh_CN`);
|
|
|
+ const { subscribe } = userResponse.data;
|
|
|
+
|
|
|
+ if (subscribe === 1) {
|
|
|
+ // 已关注公众号,跳转到目标链接
|
|
|
+ res.redirect('fullUrl');
|
|
|
+ } else {
|
|
|
+ // 未关注公众号,跳转到关注页面
|
|
|
+ res.redirect('https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=your_biz_id#wechat_redirect');
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ res.send('Error occurred: ' + error.message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 监听端口
|
|
|
+ app.listen(3000, () => {
|
|
|
+ console.log('Server is running on port 3000');
|
|
|
+ });
|
|
|
+
|
|
|
+ // 引导用户进行微信OAuth授权
|
|
|
+ function redirectToWeChatAuth() {
|
|
|
+ const appId = 'wx60064e1cac4296e6';
|
|
|
+ const redirectUri = encodeURIComponent('https://yourdomain.com/wechat/callback'); // 你的回调地址
|
|
|
+ const wechatAuthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
|
|
|
+
|
|
|
+ // 跳转到微信的OAuth2.0授权页面
|
|
|
+ window.location.href = wechatAuthUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当用户扫描二维码时,调用这个函数
|
|
|
+ document.getElementById('qrcode').addEventListener('click', function() {
|
|
|
+ redirectToWeChatAuth();
|
|
|
+ });
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
</html>
|