首页 > 其他分享 >微信公众号使用隐藏页判断登录

微信公众号使用隐藏页判断登录

时间:2023-04-25 11:06:01浏览次数:36  
标签:登录 微信 token window href location var type 隐藏

<script type="text/javascript">
   $(document).ready(function(){
      document.getElementById("over").style.display = "block";
      document.getElementById("layout").style.display = "block";
      //判断是否之前走过授权
      // var token = window.localStorage.getItem('token');
      // if(token){
      //     window.location.href='http://zhibo.cnewhl.com/pages/common/supplyHall.html '
      // }
      var urlStr = window.location.href;
      function GetRequest(urlStr) {
         if (typeof urlStr == "undefined") {
            var url = decodeURI(location.search); //获取url中"?"符后的字符串
         } else {
            var url = "?" + urlStr.split("?")[1];
         }
         var theRequest = new Object();
         if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
               theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
            }
         }
         return theRequest;
      }

var parms_1 = GetRequest();
      var type = parms_1['type'];
      if (type){
         window.localStorage.setItem('type', type);
      }
      //判断是否之前走过授权
      // var token = window.localStorage.getItem('token');
      // if(token && window.localStorage.getItem('type') == 1){
      //     window.location.href='http://zhibo.cnewhl.com/pages/common/supplyHall.html '
      // }
      var oror = parms_1['code'];
      if (oror){
         mui.ajax(site_url + 'login', {
            data: {
               code: oror
            },
            dataType: 'json', //服务器返回json格式数据
            type: 'post', //HTTP请求类型
            success: function(data) {
               window.localStorage.setItem('token', data.data.token);
               if (data.data.user.phone != null) {
                  var types = window.localStorage.getItem('type');
                  if(types == 1){
                     // window.close();
                     window.location.href = '../common/supplyHall.html';
                     // window.close();
                  }else {
                     window.location.href = '../common/person.html';
                  }
               } else {
                  window.location.href = '../person/bindMobile.html'
               }
            },
            error: function(xhr, type, errorThrown) {
               //alert(123)
            }
         });
      }else {
         window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx819031dbf71618be&redirect_uri=http://zhibo.cnewhl.com/pages/common/login.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
      }
      //$('#login').click(function(){
         // var token = window.localStorage.getItem('token');
         // // alert(token)
         // if(token){
         //     window.location.href='http://zhibo.cnewhl.com/pages/common/supplyHall.html '
         //     return
         // }
         // window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx819031dbf71618be&redirect_uri=http://zhibo.cnewhl.com/pages/person/bindMobile.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect '
      //})
   })
</script>

标签:登录,微信,token,window,href,location,var,type,隐藏
From: https://blog.51cto.com/u_13947439/6223577

相关文章

  • 答题积分小程序云开发实战-界面交互篇:注册登录页布局样式与逻辑交互开发
    微信小程序云开发实战-答题积分赛小程序界面交互篇:注册登录页布局样式与逻辑交互开发写在前面-开发调试小技巧模拟器通常默认展示的页面是首页,那么如果我们想切换到其他页面呢,那怎么办?我这里教给初学者三种方式,方便大家在搭建页面过程中,进行开发调试。点击事件跳转给页面按钮添加一......
  • 登录接口实现细节分析与登录接口代码实现
    登录接口实现细节分析登陆接口接下我们需要自定义登陆接口,然后让SpringSecurity对这个接口放行,让用户访问这个接口的时候不用登录也能访问。​在接口中我们通过AuthenticationManager的authenticate方法来进行用户认证,所以需要在SecurityConfig中配置把Authe......
  • uniapp 打包aab上传到google play的时候google 登录报异常
    因为App上传到GooglePlay后,会被重新签名(PlayAppSigning)谷歌为你生成的签名SHA-1将谷歌为你生成的签名SHA-1证书指纹复制到本应用已创建的凭据SHA-1处,点击保存后,ClientID并没有变,所以不用重新打包。现在,不用等,你可以试试Google+登录了。Google+登录ok。参考地址:https......
  • 解决企业微信在线文档里的代码复制后不能执行的问题
    【问题】某日帮同事改了个SQL,自己能执行,因为懒得另存为,就直接丢到企业微信发了。企业微信提示因为超长生成了在线文档。同事复制后,执行一直报错,类似下面的情况:【报错】 【能执行】【原因】既然语法正确,那么就把文档下载下来瞅瞅。以下是WPS的检查方法,word检查方法类似。......
  • P.4-前后端分类登录校验、P.6-SpringSecurity完整流程
    P.4-前后端分类登录校验P.6-SpringSecurity完整流程SpringSecurity的原理其实就是一个过滤器链,内部包含了提供各种功能的过滤器。(了解即可)UsernamePasswordAuthenticationFilter:负责处理我们在登陆页面填写了用户名密码后的登陆请求。入门案例的认证工作主要......
  • API接口,用户登录,获取用户信息,用户退出
    这个是前端请求的用户相关接口。路由:routers/apiRouters.go  funcApiRouter(router*gin.Engine){//会员登录router.POST("users/login",controllers.UserLogin)//使用JWT对用户的请求进行验证user:=router.Group("users/",middleware.CheckAuth......
  • SpringSecurity从入门到精通:登录接口代码实现&测试接口
    登录接口代码实现 @RestController @RestControllerpublicclassLoginController{@AutowiredprivateLoginServcieloginServcie;@PostMapping("/user/login")publicResponseResultlogin(@RequestBodyUseruser){returnloginServ......
  • gitlab 开发人员更换手机后MFA认证无法登录
    目录gitlab开发人员更换手机后MFA认证无法登录解决方法gitlab开发人员更换手机后MFA认证无法登录开发人员用mfa二次认证登录gitlab,有开发更换手机后,发现登录gitlab时必须输入mfa二次认证解决方法需要找运维管理人员,登录mfa取消二次认证,登录后自己再开启二次认证运维人员以......
  • Linux设置用户登录系统连续N次输入错误密码,自动锁定X分钟。
    一、在字符终端下,要实现某一用户连续错误登陆N次后,就锁定该用户X分钟(使用pam_tally2认证模块)编辑登录认证文件:vim/etc/pam.d/login,在#%PAM-1.0下新加一行如果限制所有用户,则可以写成如下内容:   authrequiredpam_tally2.sodeny=3unlock_time=5even_deny_rootroot_unl......
  • 达梦数据库使用disql登录, 密码包含特殊字符(@)的处理方法
    一、背景  用户密码是:dm@ABcC123,包含@这个特殊符号。 disql客户端连接数据库的方式是:disqlusername/password@IP:PORT  那么,这个时候,密码也包含@,这个符号,该怎么处理呢? 二、处理方法 1、密码用双引号括起来,"dm@ABcC123"2、对双引号加转义,\"dm@ABcC123\"......