test.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Camera Example</title>
  6. <script src="js/mui.js"></script>
  7. <link href="css/mui.css" rel="stylesheet" />
  8. <script type="text/javascript">
  9. // 扩展API加载完毕后调用onPlusReady回调函数
  10. document.addEventListener( "plusready", onPlusReady, false );
  11. // 扩展API加载完毕,现在可以正常调用扩展API
  12. function onPlusReady() {
  13. console.log("plusready");
  14. }
  15. var cmr=null;
  16. // 摄像
  17. function videoCapture(){
  18. cmr = plus.camera.getCamera();
  19. var res = cmr.supportedVideoResolutions[0];
  20. var fmt = cmr.supportedVideoFormats[0];
  21. console.log("Resolution: "+res+", Format: "+fmt);
  22. cmr.startVideoCapture( function( path ){
  23. alert( "Capture video success: " + path );
  24. },
  25. function( error ) {
  26. alert( "Capture video failed: " + error.message );
  27. },
  28. {resolution:res,format:fmt}
  29. );
  30. // 拍摄10s后自动完成
  31. setTimeout( stopCapture, 10000 );
  32. }
  33. // 停止摄像
  34. function stopCapture(){
  35. console.log("stopCapture");
  36. cmr.stopVideoCapture();
  37. }
  38. </script>
  39. </head>
  40. <body>
  41. <button onclick="videoCapture()">摄像</button><br/>
  42. <button onclick="stopCapture()">停止摄像</button>
  43. <button type="button" data-loading-text="获取验证码" class="mui-btn" id="btn" >确认</button>
  44. </body>
  45. <script>
  46. var i=10;
  47. mui(document.body).on('tap', '.mui-btn', function(e) {
  48. debugger
  49. mui(this).button('loading');
  50. var interval=setInterval(function() {
  51. document.getElementById("btn").innerHTML=i;
  52. i--;
  53. if(i==0){
  54. i=10;
  55. mui(this).button('reset');
  56. document.getElementById("btn").innerHTML="获取验证码";
  57. clearInterval(interval);
  58. }
  59. }.bind(this), 1000);
  60. });
  61. </script>
  62. </html>