jssdk.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSSDK 功能测试</title>
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  8. <link rel="stylesheet" href="__ROOT__/static/theme/css/mobile.css">
  9. </head>
  10. <body>
  11. <header>
  12. <h1>JSSDK 功能测试</h1>
  13. </header>
  14. <div class="content">
  15. <button type="button" id='show-alert'>调起摄像头扫码</button>
  16. </div>
  17. <style>
  18. header {
  19. padding: 35px 0
  20. }
  21. header h1 {
  22. color: #3cc51f;
  23. font-size: 34px;
  24. text-align: center;
  25. font-weight: 400;
  26. }
  27. .content {
  28. padding: 15px;
  29. text-align: center;
  30. }
  31. .content button {
  32. padding: 5px
  33. }
  34. </style>
  35. <script src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
  36. <script>
  37. wx.error(function (err) {
  38. alert(err.errMsg || '配置出错');
  39. });
  40. wx.config(JSON.parse('{$options|json_encode|raw}'));
  41. wx.ready(function () {
  42. alert('- 初始化成功 -');
  43. document.getElementById('show-alert').onclick = function () {
  44. wx.scanQRCode({
  45. needResult: 1,
  46. scanType: ["qrCode", "barCode"],
  47. success: function (res) {
  48. alert(res.resultStr);
  49. }
  50. });
  51. }
  52. });
  53. </script>
  54. </body>
  55. </html>