testLogin.html 1013 Bytes
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
    <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">
    <title>Title</title>
</head>
<body>
<button id="aaa">232323</button>
<button class="auth">1111111</button>
<a class="auth" href="http://www.baidu.com">123123</a>
<div id="uid"></div>
<div id="url"></div>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script src="../build/sdk.js"></script>
<script>
    window.yo_sdk.auth();
    document.getElementById('aaa').onclick = function (event) {
        window.yo_sdk.getUser().then(function (user) {
            console.log(user.uid);
            if (user.uid)
                document.getElementById('uid').innerText = user.uid;
            else
                window.yo_sdk.goLogin();
        })
    }
    document.getElementById('url').innerText = location.href;
</script>
</body>
</html>