扫二维码自动跳转到网站 PHP从url生成二维码 可以通过扫码跳过
最近项目开发中需实现一个功能:用户可通过分享自己二维码给他人扫码注册,注册成功后成为自己的下级。其中,生成二维码是第一步二维码说白了就是一条url链接,用户扫描二维码就相当于访问url链接,跳转到指定
顺晟科技
2022-09-15 14:41:48
226
一个公号号,不同的用户,在点击同一个按钮会跳转到不同的页面。
跳转正确的是没有问题的,但是不正确的跳转像是发生了没有获取到openid从而强制跳转的。
public function __construct()
{
$openid = Session::get('openid');
if($openid){
$par_stu = new ParStu();
$res = $par_stu->where('openid',$openid)->count();
if($res){
}else{
redirect('http://zhbxsq.jiazhouedu.com.cn/binding')->send();
}
}else{
WeChat::getOpenid();
}
}
这些是关于获取openid和强制跳转的代码。
并且只有这一个页面有问题,别的页面跳转都正常
public function __construct()
{
// old Code
// $openid = Session::get('openid');
// if($openid){
// $par_stu = new ParStu();
// $res = $par_stu->where('openid',$openid)->count();
// if($res){
// }else{
// redirect('http://zhbxsq.jiazhouedu.com.cn/binding')->send();
// }
// }else{
// WeChat::getOpenid();
// }
// new Code
if(Session::has('openid')){
$openid = Session::get('openid');
$binding = new Bindings();
$res = $binding->where('openid',$openid)->count();
if($res){
}else{
redirect('http://zhbxsq.jiazhouedu.com.cn/binding')->send();
}
}else{
WeChat::getOpenid();
}
}
19
2022-10
21
2022-09
15
2022-09
23
2021-09