index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // 自定义组件
  2. import '../../xr-custom/components/AutoRotate';
  3. import '../../xr-custom/components/Particle/SystemProperty/BasicParticle';
  4. import '../../xr-custom/components/Particle/index';
  5. import '../../xr-custom/elements/xr-auto-rotate-touchable-gltf';
  6. import '../../xr-custom/elements/xr-custom-particle';
  7. // 自定义Geometry
  8. import '../../xr-custom/assets/geometry-star';
  9. import '../../xr-custom/assets/geometry-specialCylinder';
  10. // 自定义材质
  11. import '../../xr-custom/elements/xr-shining-star';
  12. // 自定义effect
  13. import '../../xr-custom/assets/effect-shining';
  14. import '../../xr-custom/assets/effect-last-record-final';
  15. import list from './data/index';
  16. let lastOpened = false;
  17. let lastCount = 0;
  18. let first = true;
  19. Page({
  20. data: {
  21. list,
  22. root: ''
  23. },
  24. onLoad() {
  25. if (first) {
  26. console.log('Entry xr-frame index page');
  27. wx.reportEvent("xr_frame", {
  28. "xr_page_path": '/pages/index/index'
  29. });
  30. first = false;
  31. }
  32. },
  33. onShareAppMessage() {
  34. return {
  35. title: 'XR-FRAME官方示例'
  36. }
  37. },
  38. onShareTimeline() {
  39. return {
  40. title: 'XR-FRAME官方示例'
  41. }
  42. },
  43. clickHandle(e) {
  44. let root = this.data.root;
  45. let { name, path } = e.detail.item;
  46. if (!path) {
  47. return;
  48. }
  49. if (path === '/pages/scene-last-record/index') {
  50. this.handleLastRecord();
  51. return;
  52. }
  53. if (path) {
  54. wx.navigateTo({
  55. url: root + path + `?path=${path}`,
  56. success: () => {
  57. },
  58. fail: () => {
  59. },
  60. });
  61. }
  62. },
  63. handleLastRecord: async function () {
  64. if (lastOpened) {
  65. return;
  66. }
  67. lastCount += 1;
  68. // if (Math.random() >= (0.34 + lastCount * 0.1)) {
  69. // return;
  70. // }
  71. let root = this.data.root;
  72. lastOpened = true;
  73. wx.request({
  74. url: 'https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/xr-frame-team/last-gate.txt',
  75. success: function (res) {
  76. wx.showModal({
  77. title: '一把钥匙',
  78. content: res.data,
  79. confirmText: '探寻真实',
  80. cancelText: '放下钥匙',
  81. success: function(res) {
  82. if (res.cancel) {
  83. wx.onAppShow((result) => {
  84. lastOpened = false;
  85. });
  86. return;
  87. }
  88. wx.navigateTo({
  89. url: root + '/pages/scene-last-record/index',
  90. success: () => {
  91. wx.onAppShow((result) => {
  92. lastOpened = false;
  93. });
  94. }
  95. });
  96. }
  97. });
  98. },
  99. fail: function (err) {
  100. lastOpened = false;
  101. }
  102. });
  103. }
  104. });