zoukankan      html  css  js  c++  java
  • 微信静默授权

    <!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>
    

      

  • 相关阅读:
    信息安全
    软件体系结构原理、方法与实践总结
    软件项目管理四个核心价值观
    博客园主题修改
    测试
    Java实现人民币大写精讲
    Windows系统性能提升方法
    Oracle系列之游标
    Oracle系列之异常处理
    Oracle系列之权限
  • 原文地址:https://www.cnblogs.com/qq364735538/p/10458028.html
Copyright © 2011-2022 走看看