如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
<?php /* 小程序扫码登陆网站设计思路 1.扫描二维码,二维码带网站参数,打开小程序 2.判断是否微信授权,如果没有授权,则授权,并绑定账号 3.使用小程序扫描二维码,获取通过用户的id,判断是否绑定账号 4.实现登陆, 扫描后 成功发送一个参数 5.网站进行轮询,判断上面传递的参数,如果获取到了,则进行登陆 */ // 相关js <script type="text/javascript"> function Wreset(){ var w = $(window).width(); var yzmw = $(".login .line").width() - 140; if($(".yzm").is(":visible") && w > 640){ $(".login").css({"height":"365px","margin-top":"-230px"}); } else{ $(".login").removeAttr("style") } $(".login .yzm .inputtxt").width(yzmw); } $(function(){ Wreset(); var setTime = ''; $.get('/public?name=app&fun=login_qrcode', function(res){ if (res.status){ $('#qrcode').qrcode({ render: "canvas", //也可以替换为table width: 150, height: 150, text: res.msg }); $('.entrance').show(); } }).error(function(res,textStatus,errorThrown) { if (res.status == 404){ $('.entrance').hide(); } }); function controlTime(){ $.get('/public?name=app&fun=is_scan_ok',function(res) { if(res.status){ layer.msg('扫码成功,请稍后...',{icon:1}); clearInterval(setTime); loginAdmin(res.msg); } }); } function loginAdmin(key){ $.get('/public?name=app&fun=set_login',{secret_key:key},function(res) { layer.msg(res.msg,{icon:res.status?1:2}) if (res.status){ layer.msg('正在安全登录中,请稍后...',{time:0,shade: [0.4,'#fff'],icon:16}); setTimeout(function(){ location.href = '/'; },1000); } }); } }) window.onresize=function(){ Wreset(); } </script>