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

index.html 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!doctype html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
  6. <meta name="format-detection" content="telephone=no" />
  7. <link rel="stylesheet" href="./common.css">
  8. <title>应用商店评论</title>
  9. </head>
  10. <body>
  11. <div class="up">
  12. <div class="up_title">
  13. <div></div>
  14. <font class="upFont1">按任务要求上传应用评论截图</font>
  15. </div>
  16. <font class="upFont2">(要求能看到评论分值,账号名)</font>
  17. <div class="up_img_p">
  18. <img class="up_img" src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=4294384182,921429809&fm=26&gp=0.jpg"/>
  19. <img class="up_img" src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=92357361,3717780087&fm=26&gp=0.jpg"/>
  20. <img class="up_img" src="add.png"/>
  21. </div>
  22. </div>
  23. <div class="middle">
  24. <div class="up_title">
  25. <div></div>
  26. <font class="upFont1">任务介绍</font>
  27. </div>
  28. <img id="screenshot" src="https://s3.cn-northwest-1.amazonaws.com.cn/s3.jianos.com/screenshot.png"/>
  29. </div>
  30. <div class="bottom">
  31. <button onclick="commitBtn()">提交任务</button>
  32. </div>
  33. </body>
  34. <script>
  35. var userAg = navigator.userAgent.toLowerCase();
  36. // iOS 系统 ->
  37. if (/iphone|ipad|ipod/.test(userAg) && userAg.indexOf('mac') < 0) {
  38. var imgView = document.getElementById('screenshot')
  39. imgView.src = 'https://s3.cn-northwest-1.amazonaws.com.cn/s3.jianos.com/screenshot_ios.png';
  40. }
  41. function commitBtn () {
  42. alert('提交问卷完成!')
  43. }
  44. function ready(callback) {
  45. // 如果 jsbridge 已经注入则直接调用
  46. if (window.AlipayJSBridge) {
  47. callback && callback();
  48. } else {
  49. // 如果没有注入则监听注入的事件
  50. document.addEventListener('AlipayJSBridgeReady', callback, false);
  51. }
  52. }
  53. ready(function () {
  54. var content = document.getElementById('content');
  55. var btn1 = document.getElementById('btn1');
  56. btn1.addEventListener('click', function () {
  57. AlipayJSBridge.call('getUserInfo', {}, function (e) {
  58. console.log('JS接受的数据:'+e.toString);
  59. content.innerText = JSON.stringify(e);
  60. });
  61. });
  62. var btn2 = document.getElementById('btn2');
  63. btn2.addEventListener('click', function () {
  64. AlipayJSBridge.call('isLogin', {}, function (e) {
  65. console.log('JS接受的数据:'+e.toString);
  66. content.innerText = JSON.stringify(e);
  67. });
  68. });
  69. var btn3 = document.getElementById('btn3');
  70. btn3.addEventListener('click', function () {
  71. AlipayJSBridge.call('showLogin', {}, function (e) {
  72. console.log('JS接受的数据:'+e.toString);
  73. content.innerText = JSON.stringify(e);
  74. });
  75. });
  76. var btn4 = document.getElementById('btn4');
  77. btn4.addEventListener('click', function () {
  78. AlipayJSBridge.call('getBankInfo', {}, function (e) {
  79. console.log('JS接受的数据:'+e.toString);
  80. content.innerText = JSON.stringify(e);
  81. });
  82. });
  83. var btn5 = document.getElementById('btn5');
  84. btn5.addEventListener('click', function () {
  85. AlipayJSBridge.call('jumpToApplet', {}, function (e) {
  86. console.log('JS接受的数据:'+e.toString);
  87. content.innerText = JSON.stringify(e);
  88. });
  89. });
  90. });
  91. </script>
  92. </html>