index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. const app = getApp();
  2. var url = app.globalData.url;
  3. Component({
  4. behaviors: [require('../../../common/share-behavior').default],
  5. properties: {
  6. markerImg: {
  7. type: String
  8. },recordState: {
  9. type: Number,
  10. value: 0,
  11. observer: function (newVal, oldVal) {
  12. if (newVal !== oldVal) {
  13. if (newVal === 1) {
  14. this.recordStart();
  15. } else if (newVal === 2) {
  16. this.recordEnd();
  17. }
  18. }
  19. }
  20. },captureState: {
  21. type: Number,
  22. value: 0,
  23. observer: function (newVal, oldVal) {
  24. console.log("observer===>"+newVal);
  25. this.capture();
  26. }
  27. },
  28. },
  29. data: {
  30. loaded: false,
  31. arReady: false,
  32. loadedSaoMiao:false,
  33. ar_2img:url+"targets/ar_2.png",
  34. baseurl:url,
  35. },
  36. lifetimes: {
  37. attached() {
  38. console.log('data', this.data)
  39. }
  40. },
  41. methods: {
  42. handleReady({
  43. detail
  44. }) {
  45. const xrScene = this.scene = detail.value;
  46. console.log('xr-scene', xrScene);
  47. },
  48. handleAssetsProgress: function ({
  49. detail
  50. }) {
  51. console.log('assets progress', detail.value);
  52. },handleTrackerSwitch: function ({detail}) {
  53. const active = detail.value;
  54. if(active)
  55. {
  56. this.triggerEvent('assetsstr',true);
  57. this.setData({loadedSaoMiao: true});
  58. // this.scene.share.captureToFriends();
  59. }
  60. },handleARTrackerState({detail}) {
  61. },
  62. handleAnimationStop: function() {
  63. console.log('animation Stop');
  64. },
  65. handleAssetsLoaded: function ({
  66. detail
  67. }) {
  68. console.log('assets loaded', detail.value);
  69. this.setData({
  70. loaded: true
  71. });
  72. },
  73. handleARReady: function ({
  74. detail
  75. }) {
  76. console.log('arReady');
  77. this.setData({
  78. arReady: true
  79. })
  80. },
  81. capture: function () {
  82. this.scene.share.captureToFriends({
  83. fileType: this.data.captureType,
  84. quality: this.data.captureQuality
  85. });
  86. },
  87. recordStart() {
  88. console.log('recordStart')
  89. wx.updateShareMenu({
  90. withShareTicket: true,
  91. success () { }
  92. })
  93. this.scene.share.recordStart({
  94. fps: 15,
  95. videoBitsPerSecond: 10000,
  96. });
  97. },
  98. recordEnd() {
  99. console.log('recordEnd')
  100. //
  101. const tempFilePath = this.scene.share.recordFinishToAlbum({
  102. fps: 15,
  103. videoBitsPerSecond: 10000,
  104. });
  105. wx.shareVideoMessage({
  106. videoPath: tempFilePath,
  107. });
  108. wx.showToast({
  109. title: '视频已经保存至相册',
  110. });
  111. }
  112. }
  113. })