• 微信静默授权


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

      

  • 相关阅读:
    数组初始化 和 vector初始化
    剑指offer42 左旋转字符串
    k sum(lintcode)
    背包问题2 (lintcode)
    92.背包问题(lintcode)
    72. Edit Distance
    79 最长公共子串 (lintcode)
    77 最长公共子序列 (lintcode)
    132. Palindrome Partitioning II
    Mysql经常使用函数汇总
  • 原文地址:https://www.cnblogs.com/qq364735538/p/10458028.html
Copyright © 2020-2023  润新知