码迷,mamicode.com
首页 > 微信 > 详细

微信静默授权

时间:2019-03-01 18:39:02      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:encode   cal   regex   rect   csharp   ash   pen   uri   OLE   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        if (isWeiXin()) {
            const APPID = ‘wx1d5f44‘
            const code  = getQueryStringByName(‘code‘)
            console.log(code)
            const local = ‘https%3A%2F%2Fm.jdy.como‘
            if (code === null || code === ‘‘) {
                window.location = ‘ https://open.weixin.qq.com/connect/oauth2/authorize?appid=‘ + APPID + ‘&redirect_uri=‘ + encodeURIComponent(local) + ‘&response_type=code&scope=snsapi_base&state=123#wechat_redirect‘
            } else {
                this.getOpenId(code)
            }
            function getQueryStringByName(name){
              var result = location.hash.match(new RegExp("[\?\&]" + name + "=([^\&]+)","i"));
              if(result == null || result.length < 1){
                return "";
              }
              return result[1];
            }
        } else {
        }
         // 判断是不是微信
        function isWeiXin(){
          var ua = window.navigator.userAgent.toLowerCase();
          if(ua.match(/MicroMessenger/i) == ‘micromessenger‘){
          return true;
          }else{
          return false;
          }
        }
    </script>
</body>
</html>

  

微信静默授权

标签:encode   cal   regex   rect   csharp   ash   pen   uri   OLE   

原文地址:https://www.cnblogs.com/qq364735538/p/10458028.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!