index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var sceneReadyBehavior = require('../behavior-scene/scene-ready');
  2. const app = getApp();
  3. var url = app.globalData.url;
  4. Page({
  5. data: {
  6. ar_1image:url+"targets/ar_1.png",
  7. fanhui:url+"fanhui.png",
  8. paizhao:url+"paizhao.png"
  9. }
  10. ,
  11. behaviors: [sceneReadyBehavior],
  12. handleChangeMarkerImg: function() {
  13. wx.chooseMedia({
  14. count: 1,
  15. sizeType: ['compressed'],
  16. mediaType: ['image'],
  17. sourceType: ['album'],
  18. success: res => {
  19. const fp = res.tempFiles[0].tempFilePath;
  20. this.setData({markerImg: fp});
  21. },
  22. fail: err => {
  23. console.error('[xr-demo]chooseImage failed', err);
  24. }
  25. });
  26. },
  27. handlestr: function({detail}) {
  28. this.setData({loadedSaoMiao: true});
  29. },
  30. onClickBack() {
  31. wx.navigateBack()
  32. },
  33. //touch start 手指触摸开始
  34. handleTouchStart: function(e) {
  35. this.startTime = e.timeStamp;
  36. console.log(" startTime = " + e.timeStamp);
  37. console.log(" 手指触摸开始 " , e);
  38. console.log(" this " , this);
  39. },
  40. //touch end 手指触摸结束
  41. handleTouchEnd: function(e) {
  42. this.endTime = e.timeStamp;
  43. console.log(" endTime = " + e.timeStamp);
  44. console.log(" 手指触摸结束 ", e);
  45. //判断是点击还是长按 点击不做任何事件,长按 触发结束录像
  46. if (this.endTime - this.startTime > 350) {
  47. //长按操作 调用结束录像方法
  48. this.setData({recordState: 2});
  49. }
  50. },
  51. /**
  52. * 点击按钮 - 拍照
  53. */
  54. handleClick: function(e) {
  55. console.log("endTime - startTime = " + (this.endTime - this.startTime));
  56. if (this.endTime - this.startTime < 350) {
  57. console.log("点击123");
  58. //调用拍照方法
  59. //this.capture();
  60. this.setData({captureState: this.startTime});
  61. }
  62. },
  63. /**
  64. * 长按按钮 - 录像
  65. */
  66. handleLongPress: function(e) {
  67. console.log("endTime - startTime = " + (this.endTime - this.startTime));
  68. console.log("长按");
  69. // 长按方法触发,调用开始录像方法
  70. this.setData({recordState: 1});
  71. }
  72. });