0元购项目,Web调用原生的demo

index.html 3.0KB

    <!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>调查问卷</title> </head> <body> <!-- <div class="toobar">--> <!-- <img src="./back.png"/>--> <!-- <font>调查问卷</font>--> <!-- </div>--> <div class="up"> <font class="upFont1">步骤1</font> <font class="upFont1">点击"进入填写",完成调查问卷</font> <font class="upFont2" onclick="enterBtn()">【进入填写】</font> <font class="upFont3">步骤2</font> <font class="upFont1">点击下方【确认完成】按钮</font> </div> <div class="middle"> <font class="upFont1">温馨提示:</font> <font class="upFont1">1.请在获奖后15天内提交领取申请,逾期视为放弃</font> <font class="upFont1">2.申请提交后,奖金将在3-5个工作日内发放到您填写的收款账户</font> </div> <div class="bottom"> <button onclick="commitBtn()">确认完成</button> </div> </body> <script> function enterBtn(){ alert('即将跳转到问卷网页!') } function commitBtn () { alert('提交问卷完成!') } 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>