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

index.html 3.3KB

    <!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="up"> <div class="up_title"> <div></div> <font class="upFont1">按任务要求上传应用评论截图</font> </div> <font class="upFont2">(要求能看到评论分值,账号名)</font> <div class="up_img_p"> <img class="up_img" src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=4294384182,921429809&fm=26&gp=0.jpg"/> <img class="up_img" src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=92357361,3717780087&fm=26&gp=0.jpg"/> <img class="up_img" src="add.png"/> </div> </div> <div class="middle"> <div class="up_title"> <div></div> <font class="upFont1">任务介绍</font> </div> <img id="screenshot" src="https://s3.cn-northwest-1.amazonaws.com.cn/s3.jianos.com/screenshot.png"/> </div> <div class="bottom"> <button onclick="commitBtn()">提交任务</button> </div> </body> <script> var userAg = navigator.userAgent.toLowerCase(); // iOS 系统 -> if (/iphone|ipad|ipod/.test(userAg) && userAg.indexOf('mac') < 0) { var imgView = document.getElementById('screenshot') imgView.src = 'https://s3.cn-northwest-1.amazonaws.com.cn/s3.jianos.com/screenshot_ios.png'; } 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>