index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var sceneReadyBehavior = require('../../behavior-scene/scene-ready');
  2. Page({
  3. behaviors:[sceneReadyBehavior],
  4. data: {
  5. captureState: 0,
  6. recordState: 0,
  7. captureQuality: 0.8,
  8. captureType: 'jpg',
  9. recordFPS: 30,
  10. recordScale: 1,
  11. recordWidth: 0,
  12. recordHeight: 0,
  13. recordBPS: 1000,
  14. sceneWidth: 0,
  15. sceneHeight: 0
  16. },
  17. handleReady: function({detail}) {
  18. this.setData({
  19. sceneWidth: detail.width,
  20. sceneHeight: detail.height,
  21. recordWidth: detail.width,
  22. recordHeight: detail.height,
  23. });
  24. },
  25. changeCaptureState(e) {
  26. if (this.data.recordState) {
  27. wx.showToast({
  28. title: '录屏中不允许!',
  29. });
  30. return;
  31. }
  32. if (this.data.captureState) {
  33. wx.showToast({
  34. title: '等待上次完成!',
  35. });
  36. return;
  37. }
  38. this.setData({captureState: 1});
  39. // hack,其实应该等待异步方法完成
  40. setTimeout(() => {
  41. this.setData({captureState: 0});
  42. }, 1000);
  43. },
  44. changeRecordState(e) {
  45. this.setData({recordState: this.data.recordState ? 0 : 1});
  46. },
  47. changeCaptureType(e) {
  48. this.setData({captureType: e.detail.value});
  49. },
  50. changeCaptureQuality(e) {
  51. this.setData({
  52. captureQuality: e.detail.value
  53. });
  54. },
  55. changeRecordFPS(e) {
  56. this.setData({
  57. recordFPS: e.detail.value
  58. });
  59. },
  60. changeRecordBPS(e) {
  61. this.setData({
  62. recordBPS: e.detail.value
  63. });
  64. },
  65. changeRecordScale(e) {
  66. const scale = e.detail.value;
  67. this.setData({
  68. recordScale: scale,
  69. recordWidth: ~~(this.data.sceneWidth * scale),
  70. recordHeight: ~~(this.data.sceneHeight * scale),
  71. });
  72. }
  73. });