|
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" href="./common.css">
<title>活动页V1.0.0.3</title>
</head>
<body>
<h1>我是活动页V1.0.0.3</h1>
<img src="https://orgfreego.haitiand.cn/img/topbg.699e8968.png">
<button id="btn1">getUserInfo</button>
<button id="btn2">isLogin</button>
<button id="btn3">showLogin</button>
<button id="btn4">getBankInfo</button>
<button id="btn5">jumpToApplet</button>
<div id="content">我是结果</div>
</body>
<script>
function ready(callback) {
// 如果 jsbridge 已经注入则直接调用
if (window.AlipayJSBridge) {
callback && callback();
} else {
// 如果没有注入则监听注入的事件
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function () {
var content = document.getElementById('content');
var btn1 = document.getElementById('btn1');
btn1.addEventListener('click', function () {
AlipayJSBridge.call('getUserInfo', {}, function (e) {
console.log('JS接受的数据:'+e.toString);
content.innerText = JSON.stringify(e);
});
});
var btn2 = document.getElementById('btn2');
btn2.addEventListener('click', function () {
AlipayJSBridge.call('isLogin', {}, function (e) {
console.log('JS接受的数据:'+e.toString);
content.innerText = JSON.stringify(e);
});
});
var btn3 = document.getElementById('btn3');
btn3.addEventListener('click', function () {
AlipayJSBridge.call('showLogin', {}, function (e) {
console.log('JS接受的数据:'+e.toString);
content.innerText = JSON.stringify(e);
});
});
var btn4 = document.getElementById('btn4');
btn4.addEventListener('click', function () {
AlipayJSBridge.call('getBankInfo', {}, function (e) {
console.log('JS接受的数据:'+e.toString);
content.innerText = JSON.stringify(e);
});
});
var btn5 = document.getElementById('btn5');
btn5.addEventListener('click', function () {
AlipayJSBridge.call('jumpToApplet', {}, function (e) {
console.log('JS接受的数据:'+e.toString);
content.innerText = JSON.stringify(e);
});
});
});
</script>
</html>
|